This repo provides simple scripts, inspired by polkadot/cumulus, to set up a network with:-
- Relay Chain with 3 validators (Alice, Bob, Charlie)
- Generic parachain (parachain with generic-assets-token-dealer, assets and balances pallets)
- Subdex parachain (parachain with dex-xcmp and dex-pallet)
The relay chain chain-specs is rococo-3.json
from cumulus-workshop
This is a part of the submission for Open Grant awarded by the Web3Foundation
- subdex-ui (React frontend providing friendly UI)
- pallet-subdex & pallet-dex-xcmp
- pallet-generic-token-dealer
- Helper Repo - subdex-xc-network (current repo)
- Helper Repo - subdex-parachain (Parachains using the Cumulus framework with the dex-xcmp and dex-pallet)
- Helper Repo - generic-parachain (Parachains using the Cumulus framework with the generic-assets-token-dealer and assets pallet)
You can checkout the blog post for an overview.
The subdex testnet can be interacted with through
- Subdex Parachain - wss://subdex.link/dex
- Relay Chain - wss://subdex.link/relay
- Generic Parachain - wss://subdex.link/generic
We are also serving a polkadot.js apps web application v0.69.1 on https://subdex.link
- Subdex Parachain - Please visit our dex UI here to connect to the Subdex Parachain
If you are using the subdex.link - A polkadotJs Apps web application, please make sure you add the following types
{
"Address": "AccountId",
"LookupSource": "AccountId",
"RefCount": "u8",
"AssetId": "u64",
"Shares": "Balance",
"ParaChainAssetId": "Option<AssetId>",
"DexAssetId": "AssetIdOf<T>",
"AssetIdOf": "AssetId",
"TreasuryFee": "Option<Balance>",
"ValidationFunction": "Vec<u8>",
"ValidationFunctionParams": {
"max_code_size": "u32",
"relay_chain_height": "RelayChainBlockNumber",
"code_upgrade_allowed": "Option<RelayChainBlockNumber>"
},
"Exchange": {
"first_asset_pool": "Balance",
"second_asset_pool": "Balance",
"invariant": "Balance",
"total_shares": "Balance",
"last_timestamp": "IMoment",
"price1_cumulative_last": "Balance",
"price2_cumulative_last": "Balance",
"shares": "BTreeMap<AccountId, Balance>"
},
"IMoment": "u64",
"DexTreasury": {
"dex_account": "AccountId",
"treasury_fee_rate_nominator": "Balance",
"treasury_fee_rate_denominator": "Balance"
},
"Asset": {
"_enum": {
"MainNetworkCurrency": null,
"ParachainAsset": "(AssetId)"
}
},
}
The parachain account is tied to the parachain_id
encoded
The relay account is tied to the binary representation of relay
here
Parachain id: Id(100) Generic Parachain
Parachain Account: 5Ec4AhP7HwJNrY2CxEcFSy1BuqAY3qxvCQCfoois983TTxDA
...
Parachain id: Id(200) Dex Parachain
Parachain Account: 5Ec4AhPTL6nWnUnw58QzjJvFd3QATwHA3UJnvSD4GVSQ7Gop
Relay Account on Parachain: 5Dvjuthoa1stHkMDTH8Ljr9XaFiVLYe4f9LkAQLDjL3KqHoX
For this milestone we demostrate the use of pallet-generic-token-dealer in a Generic Parachain, this parachain includes the assets pallet which we use to demostrate the many parachains in the future with their own currencies without having to deploy many parachains.
The pallet-subdex creates a map or any parachain id + asset id to para_asset_id
, however, since supporting dynamic amount assets in the UI is not part of the scope. Therefore we have created the mapping on the subdex-parachain such that:
On Generic Parachain
AssetId 0 -> ParaAssetID 1
AssetID 1 -> ParaAssetID 2
On Subdex Parachain
ParaAssetID 1 -> BTC
ParaAssetID 2 -> EDG
The native currency of the subdex parachain is the testnet KSM from the relay chain.
It is of course possible to interact with the subdex-parachain through other api clients to test all the currencies.
# in the root of this directory
docker-compose --file docker-compose-xc.yml up
# To stop it and remove all data
docker-compose --file docker-compose-xc.yml down -v
- Docker version 19.03.8, build afacb8b
- execute access for the
.sh
files in this repo
NOTE: - we are not using the script provided in cumulus because we want 2 parachains, also, need to be able to build and rebuild the parachain binaries as we experiment. But when we get more familiar / more stable versions of the parachains, we can build a similar script to do all steps.
Steps required are:-
- set up relay chain validators
- set up default cumulus parachain
- register parachains
- run subdex and generic parachains
docker-compose -f docker-compose-validatorsOnly.yml up
will set up alice, bob and charlie
./build_collators_from_local.sh
This will set up 2 repositories parallel to this one if they are not already setup, one is generic-parachain and the other the subdex-chain
./register_parachain.sh
# Run whichever you need
./start_generic_chain.sh
./start_subdex_chain.sh
./run_network_tests.sh
docker-compose -f docker-compose-validatorsOnly.yml down -v
./clear_all.sh
- PolkadotJS App - localhost:8080
- Subdex Parachain - localhost:9944
- Relay Chain - localhost:6644
- Generic Parachain - localhost:7744
- subdex-ui - you can use https://subdex.network or run subdex-ui
- Base images - this is to compile the binary / wasm file from branches of subdex_cumulus
# To build
# same for generic-parachain
git clone https://github.com/subdarkdex/subdex_parachain.git dex-parachain
cd dex-parachain
docker build --tag subdarkdex/subdex-chain:<version>
- Collators, WASM Runtime Volume, Registrar
- collators - both dex and generic parachains
- wasm runtime volume - this is a copy of the wasm runtime for the collators, used to register parachain, we also have the genesis state volume built during docker-compose up for this purpose
- registrar - simple polkadotjs cli container to register the parachains using sudo
cd docker
./build-containers.sh v0.2.0
# or other versions