Skip to content

Commit e134564

Browse files
committed
mdBook generated from gitorial
1 parent 0abb37d commit e134564

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+6495
-196
lines changed

src/0/source/README.md

+55-19
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,69 @@
1-
# polkadot-sdk-workshop-xcm
2-
3-
This project is a workshop for learning about Polkadot SDK's XCM.
4-
5-
## Overview
6-
7-
This workshop aims to teach students about XCM following the philosophy of "discovery through experience".
1+
# XCM Workshop
82

93
Students will first go through, learn, and use all the fundamental building blocks for XCM:
104

11-
- Location / Topography
5+
1. [Location / Topography](location.md)
126
- Learn how to construct relative and absolute locations for common objects and types used in XCM.
13-
- Assets and Filters
7+
2. Assets and Filters
148
- Learn how to represent various types of assets like fungible tokens and non-fungible tokens.
159
- Constructing asset filters to target pools of assets.
16-
- Asset Holding
10+
3. Asset Holding
1711
- Learn how we can manage multiple assets in memory using the `AssetsInHolding` abstraction.
18-
- Instructions
12+
4. Instructions
1913
- Construct common XCM messages through individual XCM instructions.
20-
- The XCM Executor
14+
5. The XCM Executor
2115
- Learn how the XCM Executor actually functions, and loosely implement a few common instructions needed to complete end to end scenarios.
22-
- Pallet XCM
16+
6. Pallet XCM
2317
- Learn how Pallet XCM provides a simple to access wrapper to the underlying XCM Executor to perform common tasks like send, execute, and teleport transfers.
2418

25-
After learning the fundamentals, students should feel confident they have strong understanding of how these underlying XCM primitives function and are constructed. With this knowledge, they will be able to investigate the real implementations of XCM to learn more deeply if needed.
2619

27-
The next step after fundamentals is using the XCM Simulator an investigating the different ways we can configure XCM for various common scenarios. This workshop will not be comprehensive to all possible interactions, but will focus on a few key scenarios that we commonly expect to see in the Polkadot Ecosystem.
20+
## Prerequisite Knowledge
21+
22+
Before we can even start teaching the low level concepts of XCM, we need to provide some high level knowledge about Polkadot, cross consensus messages, and tokens, and more...
23+
24+
## Parachains
25+
26+
Truthfully, we cannot in fine detail go over Polkadot and Parachains in this workshop. That would be its own educational endeavour.
27+
28+
However, for the context of understanding common end to end scenarios that we will try to cover in this XCM Workshop, you will need to have a basic understanding of Parachains in the Polkadot Ecosystem.
29+
30+
### System Parachains
31+
32+
Polkadot uses parachains to scale itself through the creation of "system parachains".
33+
34+
System parachains use the same parachain technology stack used to create and secure self-sovereign parachains. But in this case, rather than these parachains being their own sovereign entity,
35+
36+
A very relevant example of this is the Asset Hub. This is a System Parachain for
37+
38+
## Transfers
39+
40+
We can argue that one of the native operations of any blockchain is to transfer assets and keep track of the ownership of those assets. Within a single consensus system, this is a solved problem.
41+
42+
However, in a multi-chain, multi-token, multi-consensus ecosystem, this is a problem still being solved.
43+
44+
Within the XCM world, we have established two different kinds of transfers which can be used across consensus systems, and based on their trust assumptions.
45+
46+
### Teleport Transfers
47+
48+
In high trust scenarios, we
49+
50+
Teleport:
51+
52+
Destroying an asset (or amount of funds/token/currency) in one place and minting a corresponding amount in a second place. Imagine the teleporter from Star Trek. The two places need not be equivalent in nature (e.g. could be a UTXO chain that destroys assets and an account-based chain that mints them). Neither place acts as a reserve or derivative for the other. Though the nature of the tokens may be different, neither place is more canonical than the other. This is only possible if there is a bilateral trust relationship both of the STF and the validity/finality/availability between them.
53+
54+
### Reserved Backed Transfers
55+
56+
## XCM
57+
58+
### Principles
59+
60+
XCM is designed around four 'A's:
61+
62+
- Asynchronous: XCM messages in no way assume that the sender will be blocking on its completion.
63+
- Absolute: XCM messages are guaranteed to be delivered and interpreted accurately, in order and in a timely fashion.
64+
- Asymmetric: XCM messages do not have results. Any results must be separately communicated to the sender with an additional message.
65+
- Agnostic: XCM makes no assumptions about the nature of the Consensus System between which messages are being passed.
2866

29-
As a parachain:
67+
### Messages
3068

31-
1. Accepting and using the native asset of your relay chain.
32-
2. Accepting and using the native asset of other parachains.
33-
3. Accessing pallets of the relay chain or other parachains.
69+
### XCM Virtual Machine

src/1/solution/README.md

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1-
# polkadot-sdk-workshop-xcm
1+
# XCM Workshop
22

3-
This project is a workshop for learning about Polkadot SDK's XCM.
4-
5-
## Overview
6-
7-
This workshop aims to teach students about XCM following the philosophy of "discovery through experience".
8-
9-
Students will first go through, learn, and use all the fundamental building blocks for XCM:
10-
11-
- Location / Topography
12-
- Learn how to construct relative and absolute locations for common objects and types used in XCM.
13-
- Assets and Filters
14-
- Learn how to represent various types of assets like fungible tokens and non-fungible tokens.
15-
- Constructing asset filters to target pools of assets.
16-
- Asset Holding
17-
- Learn how we can manage multiple assets in memory using the `AssetsInHolding` abstraction.
18-
- Instructions
19-
- Construct common XCM messages through individual XCM instructions.
20-
- The XCM Executor
21-
- Learn how the XCM Executor actually functions, and loosely implement a few common instructions needed to complete end to end scenarios.
22-
- Pallet XCM
23-
- Learn how Pallet XCM provides a simple to access wrapper to the underlying XCM Executor to perform common tasks like send, execute, and teleport transfers.
24-
25-
After learning the fundamentals, students should feel confident they have strong understanding of how these underlying XCM primitives function and are constructed. With this knowledge, they will be able to investigate the real implementations of XCM to learn more deeply if needed.
26-
27-
The next step after fundamentals is using the XCM Simulator an investigating the different ways we can configure XCM for various common scenarios. This workshop will not be comprehensive to all possible interactions, but will focus on a few key scenarios that we commonly expect to see in the Polkadot Ecosystem.
28-
29-
As a parachain:
30-
31-
1. Accepting and using the native asset of your relay chain.
32-
2. Accepting and using the native asset of other parachains.
33-
3. Accessing pallets of the relay chain or other parachains.
3+
Solution to Fundamentals Location

src/1/template/README.md

+71-24
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,80 @@
1-
# polkadot-sdk-workshop-xcm
1+
# Locations
22

3-
This project is a workshop for learning about Polkadot SDK's XCM.
3+
In the world of XCM, the first fundamental primitive you need to learn about is Locations.
44

5-
## Overview
5+
As a software developer, Locations are most similar to filepaths in a filesystem.
66

7-
This workshop aims to teach students about XCM following the philosophy of "discovery through experience".
7+
When writing a program, filepaths can help you locate folders, which contain many items, and the items themselves.
88

9-
Students will first go through, learn, and use all the fundamental building blocks for XCM:
9+
This is very similar to Locations in XCM, which can be used to locate consensus systems, like Relay Chains, Parachains, Smart Contracts, etc... and also specific users, assets, applications, and groups.
1010

11-
- Location / Topography
12-
- Learn how to construct relative and absolute locations for common objects and types used in XCM.
13-
- Assets and Filters
14-
- Learn how to represent various types of assets like fungible tokens and non-fungible tokens.
15-
- Constructing asset filters to target pools of assets.
16-
- Asset Holding
17-
- Learn how we can manage multiple assets in memory using the `AssetsInHolding` abstraction.
18-
- Instructions
19-
- Construct common XCM messages through individual XCM instructions.
20-
- The XCM Executor
21-
- Learn how the XCM Executor actually functions, and loosely implement a few common instructions needed to complete end to end scenarios.
22-
- Pallet XCM
23-
- Learn how Pallet XCM provides a simple to access wrapper to the underlying XCM Executor to perform common tasks like send, execute, and teleport transfers.
11+
Let's explore how Locations work inside of XCM.
2412

25-
After learning the fundamentals, students should feel confident they have strong understanding of how these underlying XCM primitives function and are constructed. With this knowledge, they will be able to investigate the real implementations of XCM to learn more deeply if needed.
13+
## Relative Locations
2614

27-
The next step after fundamentals is using the XCM Simulator an investigating the different ways we can configure XCM for various common scenarios. This workshop will not be comprehensive to all possible interactions, but will focus on a few key scenarios that we commonly expect to see in the Polkadot Ecosystem.
15+
By default, locations in XCM are always relative.
2816

29-
As a parachain:
17+
This means, when considering how to construct a location, you must first establish your relative perspective.
3018

31-
1. Accepting and using the native asset of your relay chain.
32-
2. Accepting and using the native asset of other parachains.
33-
3. Accessing pallets of the relay chain or other parachains.
19+
For example, take the following topography:
20+
21+
```text
22+
┌───────────┐
23+
│ Relay A │
24+
│ Polkadot │
25+
└─────┬─────┘
26+
27+
┌──────────┴──────────┐
28+
│ │
29+
┌─────┴─────┐ ┌─────┴─────┐
30+
│ Para A │ │ Para B │
31+
│ Id 1000 │ │ Id 1337 │
32+
└─────┬─────┘ └─────┬─────┘
33+
│ │
34+
┌──────┴──────┐ ├───────────┐
35+
│ │ │ │
36+
┌─────┴─────┐ ┌─────┴─────┐ ┌──────┴────┐ ┌────┴──────┐
37+
│ Alice │ │ Pallet │ │ Bob │ │ Pallet │
38+
│ AcctKey32 │ │ Assets │ │ AcctKey20 │ │ EVM │
39+
│ │ │ │ │ │ │ │
40+
│ 0x11111...│ │ Pallet #2 │ │ 0x22222...│ │ Pallet #5 │
41+
└───────────┘ └─────┬─────┘ └───────────┘ └─────┬─────┘
42+
│ │
43+
┌─────┴─────┐ ┌─────┴─────┐
44+
│ Asset │ │ Smart │
45+
│ wBTC │ │ Contract │
46+
│ │ │ │
47+
│ Id 21 │ │ 0x55555...│
48+
└───────────┘ └───────────┘
49+
```
50+
51+
Let's treat this like a file system, and say we want to locate `Asset wBTC - ID 21`.
52+
53+
From the perspective of the Polkadot relay chain:
54+
55+
```text
56+
./{Para A}/{Pallet Assets}/{Asset wBTC}
57+
```
58+
59+
But from the perspective of Smart Contract `0x555...`, which might be a DEX used to trade `wBTC`:
60+
61+
```text
62+
../../../{Para A}/{Pallet Assets}/{Asset wBTC}
63+
```
64+
65+
## The Location Format
66+
67+
So nothing new to learn about with locations, we just need to break down how they are represented in the XCM system.
68+
69+
### Junction
70+
71+
The building blocks of a location are Junctions.
72+
73+
```rust
74+
pub enum Junction {
75+
Parachain(#[codec(compact)] u32),
76+
PalletInstance(u8),
77+
GeneralIndex(#[codec(compact)] u128),
78+
// ... there are more junctions
79+
}
80+
```

src/2/solution/README.md

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1-
# polkadot-sdk-workshop-xcm
1+
# XCM Workshop
22

3-
This project is a workshop for learning about Polkadot SDK's XCM.
4-
5-
## Overview
6-
7-
This workshop aims to teach students about XCM following the philosophy of "discovery through experience".
8-
9-
Students will first go through, learn, and use all the fundamental building blocks for XCM:
10-
11-
- Location / Topography
12-
- Learn how to construct relative and absolute locations for common objects and types used in XCM.
13-
- Assets and Filters
14-
- Learn how to represent various types of assets like fungible tokens and non-fungible tokens.
15-
- Constructing asset filters to target pools of assets.
16-
- Asset Holding
17-
- Learn how we can manage multiple assets in memory using the `AssetsInHolding` abstraction.
18-
- Instructions
19-
- Construct common XCM messages through individual XCM instructions.
20-
- The XCM Executor
21-
- Learn how the XCM Executor actually functions, and loosely implement a few common instructions needed to complete end to end scenarios.
22-
- Pallet XCM
23-
- Learn how Pallet XCM provides a simple to access wrapper to the underlying XCM Executor to perform common tasks like send, execute, and teleport transfers.
24-
25-
After learning the fundamentals, students should feel confident they have strong understanding of how these underlying XCM primitives function and are constructed. With this knowledge, they will be able to investigate the real implementations of XCM to learn more deeply if needed.
26-
27-
The next step after fundamentals is using the XCM Simulator an investigating the different ways we can configure XCM for various common scenarios. This workshop will not be comprehensive to all possible interactions, but will focus on a few key scenarios that we commonly expect to see in the Polkadot Ecosystem.
28-
29-
As a parachain:
30-
31-
1. Accepting and using the native asset of your relay chain.
32-
2. Accepting and using the native asset of other parachains.
33-
3. Accessing pallets of the relay chain or other parachains.
3+
Solution to Assets

src/2/template/README.md

+5-29
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,9 @@
1-
# polkadot-sdk-workshop-xcm
1+
# Assets
22

3-
This project is a workshop for learning about Polkadot SDK's XCM.
3+
Now that you are familiar with XCM Locations, we can take a look at how we use these locations to identify particular Assets within a consensus system.
44

5-
## Overview
5+
## Fungible Tokens
66

7-
This workshop aims to teach students about XCM following the philosophy of "discovery through experience".
7+
## Non-Fungible Tokens
88

9-
Students will first go through, learn, and use all the fundamental building blocks for XCM:
10-
11-
- Location / Topography
12-
- Learn how to construct relative and absolute locations for common objects and types used in XCM.
13-
- Assets and Filters
14-
- Learn how to represent various types of assets like fungible tokens and non-fungible tokens.
15-
- Constructing asset filters to target pools of assets.
16-
- Asset Holding
17-
- Learn how we can manage multiple assets in memory using the `AssetsInHolding` abstraction.
18-
- Instructions
19-
- Construct common XCM messages through individual XCM instructions.
20-
- The XCM Executor
21-
- Learn how the XCM Executor actually functions, and loosely implement a few common instructions needed to complete end to end scenarios.
22-
- Pallet XCM
23-
- Learn how Pallet XCM provides a simple to access wrapper to the underlying XCM Executor to perform common tasks like send, execute, and teleport transfers.
24-
25-
After learning the fundamentals, students should feel confident they have strong understanding of how these underlying XCM primitives function and are constructed. With this knowledge, they will be able to investigate the real implementations of XCM to learn more deeply if needed.
26-
27-
The next step after fundamentals is using the XCM Simulator an investigating the different ways we can configure XCM for various common scenarios. This workshop will not be comprehensive to all possible interactions, but will focus on a few key scenarios that we commonly expect to see in the Polkadot Ecosystem.
28-
29-
As a parachain:
30-
31-
1. Accepting and using the native asset of your relay chain.
32-
2. Accepting and using the native asset of other parachains.
33-
3. Accessing pallets of the relay chain or other parachains.
9+
## Asset Filters

src/3/solution/README.md

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1-
# polkadot-sdk-workshop-xcm
1+
# XCM Workshop
22

3-
This project is a workshop for learning about Polkadot SDK's XCM.
4-
5-
## Overview
6-
7-
This workshop aims to teach students about XCM following the philosophy of "discovery through experience".
8-
9-
Students will first go through, learn, and use all the fundamental building blocks for XCM:
10-
11-
- Location / Topography
12-
- Learn how to construct relative and absolute locations for common objects and types used in XCM.
13-
- Assets and Filters
14-
- Learn how to represent various types of assets like fungible tokens and non-fungible tokens.
15-
- Constructing asset filters to target pools of assets.
16-
- Asset Holding
17-
- Learn how we can manage multiple assets in memory using the `AssetsInHolding` abstraction.
18-
- Instructions
19-
- Construct common XCM messages through individual XCM instructions.
20-
- The XCM Executor
21-
- Learn how the XCM Executor actually functions, and loosely implement a few common instructions needed to complete end to end scenarios.
22-
- Pallet XCM
23-
- Learn how Pallet XCM provides a simple to access wrapper to the underlying XCM Executor to perform common tasks like send, execute, and teleport transfers.
24-
25-
After learning the fundamentals, students should feel confident they have strong understanding of how these underlying XCM primitives function and are constructed. With this knowledge, they will be able to investigate the real implementations of XCM to learn more deeply if needed.
26-
27-
The next step after fundamentals is using the XCM Simulator an investigating the different ways we can configure XCM for various common scenarios. This workshop will not be comprehensive to all possible interactions, but will focus on a few key scenarios that we commonly expect to see in the Polkadot Ecosystem.
28-
29-
As a parachain:
30-
31-
1. Accepting and using the native asset of your relay chain.
32-
2. Accepting and using the native asset of other parachains.
33-
3. Accessing pallets of the relay chain or other parachains.
3+
Solution to Holding

0 commit comments

Comments
 (0)