Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shawntabrizi/polkadot-launch
Simple CLI tool to launch a local Polkadot test network
https://github.com/shawntabrizi/polkadot-launch
Last synced: about 1 month ago
JSON representation
Simple CLI tool to launch a local Polkadot test network
- Host: GitHub
- URL: https://github.com/shawntabrizi/polkadot-launch
- Owner: paritytech
- License: mit
- Created: 2020-09-03T10:47:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-04T03:16:40.000Z (almost 2 years ago)
- Last Synced: 2024-06-24T04:54:56.280Z (6 months ago)
- Language: TypeScript
- Size: 244 MB
- Stars: 458
- Watchers: 18
- Forks: 92
- Open Issues: 43
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-substrate - `polkadot-launch` - Simple CLI tool to launch a local Polkadot test network. (Tools)
- awesome-substrate - `polkadot-launch` - Simple CLI tool to launch a local Polkadot test network. (Tools)
README
# ⚠️ Deprecated ⚠️
This project has been deprecated. Please use one of the following alternatives:
- [zombienet](https://github.com/paritytech/zombienet)
- [parachain-launch](https://github.com/open-web3-stack/parachain-launch)# polkadot-launch
Simple CLI tool to launch a local [Polkadot](https://github.com/paritytech/polkadot/) test network.
## Install
```
yarn global add polkadot-launch
```Or, if you use `npm`:
```bash
npm i polkadot-launch -g
```## Binary Files
To use polkadot-launch, you need to have binary files for a `polkadot` relay chain and a
`polkadot-parachain` in the bin folder.> If you are on an Apple M1 ARM chip, make sure you are using the `stable-aarch64-apple-darwin` toolchain to compile the binaries.
You can generate these files by cloning the `rococo-v1` branch of these projects in the same root as the polkadot-launch repo
and building them with the specific flags below:```bash
git clone https://github.com/paritytech/polkadot
cd polkadot
cargo build --release
cp ./target/release/polkadot ../polkadot-launch/bin/polkadot-relaychain
```and
```
git clone https://github.com/paritytech/cumulus
cd cumulus
cargo build --release -p polkadot-parachain
cp ./target/release/polkadot-parachain ../polkadot-launch/bin/polkadot-parachain
```## Use
```bash
polkadot-launch config.json
```### Configuration File
The required configuration file defines the properties of the network you want to set up.
You may use a json or a js file.You can see the examples:
- [config.json](config.json)
- [config.js](config.js)You may find the .js alternative more convenient if you need comments, trailing commas or if you prefer do dedup some portions of the config.
#### `relaychain`
- `bin`: The path of the [Polkadot relay chain binary](https://github.com/paritytech/polkadot/) used
to setup your test network. For example `/target/release/polkadot`.
- `chain`: The chain you want to use to generate your spec (probably `rococo-local`).
- `nodes`: An array of nodes that will be validators on the relay chain.
- `name`: Must be one of `alice`, `bob`, `charlie`, or `dave`.
- `wsPort`: The websocket port for this node.
- `port`: The TCP port for this node.
- `nodeKey`: a secret key used for generating libp2p peer identifier. Optional.
- `basePath`: The directory used for the blockchain db and other outputs. When unspecified, we use
`--tmp`.
- `flags`: Any additional command line flags you want to add when starting your node.
- `genesis`: A JSON object of the properties you want to modify from the genesis configuration.
Non-specified properties will be unchanged from the original genesis configuration.These variable are fed directly into the Polkadot binary and used to spawn a node:
```bash
\
--chain=-raw.json \
--tmp \
--ws-port= \
--port= \
-- \
```An example of `genesis` is:
```json
"genesis": {
"runtime": {
"runtime_genesis_config": {
"configuration": {
"config": {
"validation_upgrade_frequency": 10,
"validation_upgrade_delay": 10
}
},
"palletCollective": {
"members": ["5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", "5DbKjhNLpqX3zqZdNBc9BGb4fHU1cRBaDhJUskrvkwfraDi6"]
}
},
"session_length_in_blocks": 10
}
}
```All `genesis` properties can be found in the chainspec output:
```bash
./polkadot build-spec --chain=rococo-local --disable-default-bootnode
```#### `parachains`
`parachains` is an array of objects that consists of:
- `bin`: The path of the [collator node
binary](https://github.com/substrate-developer-hub/substrate-parachain-template) used to create
blocks for your parachain. For example
`/target/release/polkadot-parachain`.
- `id`: The id to assign to this parachain. Must be unique.
- `wsPort`: The websocket port for this node.
- `port`: The TCP port for this node.
- `balance`: (Optional) Configure a starting amount of balance on the relay chain for this chain's
account ID.
- `chain`: (Optional) Configure an alternative chain specification to be used for launching the
parachain.
- `basePath`: The directory used for the blockchain db and other outputs. When unspecified, we use
`--tmp`.
- `flags`: Any additional command line flags you want to add when starting your node.These variables are fed directly into the collator binary and used to spawn a node:
```bash
\
--tmp \
--ws-port= \
--port= \
--parachain-id= \
--validator \
--chain=
-- \
--chain=-raw.json \
```#### `simpleParachains`
This is similar to `parachains` but for "simple" collators like the adder-collator, a very simple
collator that lives in the polkadot repo and is meant just for simple testing. It supports a subset
of configuration values:- `bin`: The path to the collator binary.
- `id`: The id to assign to this parachain. Must be unique.
- `port`: The TCP port for this node.
- `balance`: (Optional) Configure a starting amount of balance on the relay chain for this chain's
account ID.#### `hrmpChannels`
Open HRMP channels between the specified parachains so that it's possible to send messages between
those. Keep in mind that an HRMP channel is unidirectional and in case you need to communicate both
ways you need to open channels in both directions.```json
"hrmpChannels": [
{
"sender": "200",
"recipient": "300",
"maxCapacity": 8,
"maxMessageSize": 512
}
]
```#### `types`
These are the Polkadot JS types you might need to include so that Polkadot JS will be able to
interface properly with your runtime.```json
"types": {
"HrmpChannelId": {
"sender": "u32",
"receiver": "u32"
}
}
```Or you can specify a path to the type definition json file instead:
```json
"types": "./typedefs.json"
```#### `finalization`
A simple boolean flag for whether you want to make sure all of the transactions submitted in
polkadot-launch wait for finalization.## How Does It Work?
This tool just automates the steps needed to spin up multiple relay chain nodes and parachain nodes
in order to create a local test network.You can add the `-v` or `--verbose` flag to see what processes it is invoking and with which arguments.
- [`child_process`](https://nodejs.org/api/child_process.html) is used to execute commands on your
node:
- We build a fresh chain spec using the `chain` parameter specified in your config.
- Includes the authorities you specified.
- Includes changes to the `paras`.
- Includes parachains you have added.
- `wasm` is generated using the ` export-genesis-wasm` subcommand.
- `header` is retrieved by calling `api.rpc.chain.getHeader(genesis_hash)`.
- The final file is named `-raw.json`.
- We spawn new node instances using the information provided in your config. Each node produces a
`.log` file in your working directory that you can use to track the output. For example:
```bash
tail -f alice.log # Alice validator on the relay chain
# or
tail -f 9988.log # Collator for Parachain ID 200 on wsPort 9988
```
- [`polkadot-js api`](https://polkadot.js.org/api/) is used to connect to these spawned nodes over
their WebSocket endpoint.## Development
To work on this project, you will need [`yarn`](https://yarnpkg.com/).
Install all NodeJS dependencies with:
```bash
yarn
```Start the application with:
```bash
yarn start config.json
```When you have finished your changes, make a [pull
request](https://github.com/paritytech/polkadot-launch/pulls) to this repo.## Get Help
Open an [issue](https://github.com/paritytech/polkadot-launch/issues) if you have problems or
feature requests!