• This repository has been archived on 15/Nov/2023
  • Stars
    star
    618
  • Rank 72,605 (Top 2 %)
  • Language
    Rust
  • License
    GNU General Publi...
  • Created almost 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Write Parachains on Substrate

Cumulus ☁️

Doc

This repository contains both the Cumulus SDK and also specific chains implemented on top of this SDK.

Cumulus SDK

A set of tools for writing Substrate-based Polkadot parachains. Refer to the included overview for architectural details, and the Connect to a relay chain how-to guide for a guided walk-through of using these tools.

It's easy to write blockchains using Substrate, and the overhead of writing parachains' distribution, p2p, database, and synchronization layers should be just as low. This project aims to make it easy to write parachains for Polkadot by leveraging the power of Substrate.

Cumulus clouds are shaped sort of like dots; together they form a system that is intricate, beautiful and functional.

Consensus

parachain-consensus is a consensus engine for Substrate that follows a Polkadot relay chain. This will run a Polkadot node internally, and dictate to the client and synchronization algorithms which chain to follow, finalize, and treat as best.

Collator

A Polkadot collator for the parachain is implemented by the polkadot-parachain binary (previously called polkadot-collator).

Relay Chain Interaction

To operate a parachain node, a connection to the corresponding relay chain is necessary. This can be achieved in one of two ways:

  1. Run a full relay chain node within the parachain node (default)
  2. Connect to an external relay chain node via WebSocket RPC

In-process Relay Chain Node

If an external relay chain node is not specified (default behavior), then a full relay chain node is spawned within the same process.

This node has all of the typical components of a regular Polkadot node and will have to fully sync with the relay chain to work.

Example command
polkadot-parachain \
	--chain parachain-chainspec.json \
	--tmp \
	-- \
	--chain relaychain-chainspec.json

External Relay Chain Node

An external relay chain node is connected via WebsSocket RPC by using the --relay-chain-rpc-urls command line argument. This option accepts one or more space-separated WebSocket URLs to a full relay chain node. By default, only the first URL will be used, with the rest as a backup in case the connection to the first node is lost.

Parachain nodes using this feature won't have to fully sync with the relay chain to work, so in general they will use fewer system resources.

Note: At this time, any parachain nodes using this feature will still spawn a significantly cut-down relay chain node in-process. Even though they lack the majority of normal Polkadot subsystems, they will still need to connect directly to the relay chain network.

Example command
polkadot-parachain \
	--chain parachain-chainspec.json \
	--tmp \
	--relay-chain-rpc-urls \
		"ws://relaychain-rpc-endpoint:9944" \
		"ws://relaychain-rpc-endpoint-backup:9944" \
	-- \
	--chain relaychain-chainspec.json

Installation and Setup

Before building Cumulus SDK based nodes / runtimes prepare your environment by following Substrate installation instructions.

To launch a local network, you can use zombienet for quick setup and experimentation or follow the manual setup.

Zombienet

We use Zombienet to spin up networks for integration tests and local networks. Follow these installation steps to set it up on your machine. A simple network specification with two relay chain nodes and one collator is located at zombienet/examples/small_network.toml.

Which provider should I use?

Zombienet offers multiple providers to run networks. Choose the one that best fits your needs:

  • Podman: Choose this if you want to spin up a network quick and easy.
  • Native: Choose this if you want to develop and deploy your changes. Requires compilation of the binaries.
  • Kubernetes: Choose this for advanced use-cases or running on cloud-infrastructure.

How to run

To run the example network, use the following commands:

# Podman provider
zombienet --provider podman spawn ./zombienet/examples/small_network.toml

# Native provider, assumes polkadot and polkadot-parachains binary in $PATH
zombienet --provider native spawn ./zombienet/examples/small_network.toml

Manual Setup

Launch the Relay Chain

# Clone
git clone https://github.com/paritytech/polkadot
cd polkadot

# Compile Polkadot with the real overseer feature
cargo build --release --bin polkadot

# Generate a raw chain spec
./target/release/polkadot build-spec --chain rococo-local --disable-default-bootnode --raw > rococo-local-cfde.json

# Alice
./target/release/polkadot --chain rococo-local-cfde.json --alice --tmp

# Bob (In a separate terminal)
./target/release/polkadot --chain rococo-local-cfde.json --bob --tmp --port 30334

Launch the Parachain

# Clone
git clone https://github.com/paritytech/cumulus
cd cumulus

# Compile
cargo build --release --bin polkadot-parachain

# Export genesis state
./target/release/polkadot-parachain export-genesis-state > genesis-state

# Export genesis wasm
./target/release/polkadot-parachain export-genesis-wasm > genesis-wasm

# Collator1
./target/release/polkadot-parachain --collator --alice --force-authoring --tmp --port 40335 --rpc-port 9946 -- --chain ../polkadot/rococo-local-cfde.json --port 30335

# Collator2
./target/release/polkadot-parachain --collator --bob --force-authoring --tmp --port 40336 --rpc-port 9947 -- --chain ../polkadot/rococo-local-cfde.json --port 30336

# Parachain Full Node 1
./target/release/polkadot-parachain --tmp --port 40337 --rpc-port 9948 -- --chain ../polkadot/rococo-local-cfde.json --port 30337

Register the parachain

image

Asset Hub 🪙

This repository also contains the Asset Hub runtimes. Asset Hub is a system parachain providing an asset store for the Polkadot ecosystem.

Build & Launch a Node

To run an Asset Hub node, you will need to compile the polkadot-parachain binary:

cargo build --release --locked --bin polkadot-parachain

Once the executable is built, launch the parachain node via:

CHAIN=asset-hub-westend # or asset-hub-kusama
./target/release/polkadot-parachain --chain $CHAIN

Refer to the setup instructions to run a local network for development.

Contracts 📝

See the contracts-rococo readme for details.

Bridge-hub 📝

See the bridge-hubs readme for details.

Rococo 👑

Rococo is becoming a Community Parachain Testbed for parachain teams in the Polkadot ecosystem. It supports multiple parachains with the differentiation of long-term connections and recurring short-term connections, to see which parachains are currently connected and how long they will be connected for see here.

Rococo is an elaborate style of design and the name describes the painstaking effort that has gone into this project.

Build & Launch Rococo Collators

Collators are similar to validators in the relay chain. These nodes build the blocks that will eventually be included by the relay chain for a parachain.

To run a Rococo collator you will need to compile the following binary:

cargo build --release --locked --bin polkadot-parachain

Otherwise you can compile it with Parity CI docker image:

docker run --rm -it -w /shellhere/cumulus \
                    -v $(pwd):/shellhere/cumulus \
                    paritytech/ci-linux:production cargo build --release --locked --bin polkadot-parachain
sudo chown -R $(id -u):$(id -g) target/

If you want to reproduce other steps of CI process you can use the following guide.

Once the executable is built, launch collators for each parachain (repeat once each for chain tick, trick, track):

./target/release/polkadot-parachain --chain $CHAIN --validator

Parachains

The network uses horizontal message passing (HRMP) to enable communication between parachains and the relay chain and, in turn, between parachains. This means that every message is sent to the relay chain, and from the relay chain to its destination parachain.

Containerize

After building polkadot-parachain with cargo or with Parity CI image as documented in this chapter, the following will allow producing a new docker image where the compiled binary is injected:

./docker/scripts/build-injected-image.sh

Alternatively, you can build an image with a builder pattern:

docker build --tag $OWNER/$IMAGE_NAME --file ./docker/polkadot-parachain_builder.Containerfile .

You may then run your new container:

```bash
docker run --rm -it $OWNER/$IMAGE_NAME --collator --tmp --chain /specs/westmint.json

More Repositories

1

substrate

Substrate: The platform for blockchain innovators
Rust
8,212
star
2

polkadot

Polkadot Node Implementation
Rust
6,865
star
3

ink

Parity's ink! to write smart contracts.
Rust
1,316
star
4

wasmi

WebAssembly (Wasm) interpreter.
Rust
1,269
star
5

polkadot-sdk

The Parity Polkadot Blockchain SDK
Rust
979
star
6

jsonrpc

Rust JSON-RPC implementation
Rust
752
star
7

parity-bitcoin

The Parity Bitcoin client
Rust
726
star
8

parity-signer

Air-gapped crypto wallet.
Rust
539
star
9

frontier

Ethereum compatibility layer for Substrate.
Rust
496
star
10

polkadot-launch

Simple CLI tool to launch a local Polkadot test network
TypeScript
458
star
11

jsonrpsee

Rust JSON-RPC library on top of async/await
Rust
457
star
12

parity-wasm

WebAssembly serialization/deserialization in rust
Rust
395
star
13

subxt

Submit extrinsics (transactions) to a substrate node via RPC
Rust
317
star
14

parity-bridge

Rust
317
star
15

substrate-telemetry

Polkadot Telemetry service
Rust
303
star
16

smoldot

Alternative client for Substrate-based chains.
Rust
286
star
17

parity-common

Collection of crates used in Parity projects
Rust
284
star
18

parity-bridges-common

Collection of Useful Bridge Building Tools 🏗️
Rust
265
star
19

parity-db

Experimental blockchain database
Rust
263
star
20

banana_split

Shamir's Secret Sharing for people with friends
TypeScript
259
star
21

substrate-api-sidecar

REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.
TypeScript
245
star
22

parity-scale-codec

Lightweight, efficient, binary serialization and deserialization codec
Rust
244
star
23

substrate-connect

Run Wasm Light Clients of any Substrate based chain directly in your browser.
TypeScript
230
star
24

cargo-contract

Setup and deployment tool for developing Wasm based smart contracts via ink!
Rust
226
star
25

trie

Base-16 Modified Patricia Merkle Tree (aka Trie)
Rust
201
star
26

substrate-archive

Blockchain Indexing Engine
Rust
197
star
27

shasper

Parity Shasper beacon chain implementation using the Substrate framework.
Rust
196
star
28

parity-zcash

Rust implementation of Zcash protocol
Rust
184
star
29

cachepot

cachepot is `sccache` with extra sec, which in turn is `ccache` with cloud storage
Rust
174
star
30

libsecp256k1

Pure Rust Implementation of secp256k1.
Rust
172
star
31

homebrew-paritytech

Homebrew tap for ethcore
Ruby
160
star
32

zombienet

A cli tool to easily spawn ephemeral Polkadot/Substrate networks and perform tests against them.
TypeScript
158
star
33

polkadot-staking-dashboard

A dashboard for Polkadot staking and nomination pools.
TypeScript
152
star
34

xcm-format

Polkadot Cross Consensus-system Message format.
143
star
35

finality-grandpa

finality gadget for blockchains using common prefix agreement
Rust
139
star
36

substrate-contracts-node

Minimal Substrate node configured for smart contracts via pallet-contracts.
Rust
124
star
37

capi

[WIP] A framework for crafting interactions with Substrate chains
TypeScript
105
star
38

grandpa-bridge-gadget

A Bridge Gadget to Grandpa Finality.
Rust
99
star
39

substrate-debug-kit

A collection of debug tools, scripts and libraries on top of substrate.
Rust
94
star
40

ink-examples

A set of examples for ink! smart contract language. Happy hacking!
Rust
89
star
41

subport

Parity Substrate(-based) chains usage and development support
Rust
84
star
42

wasm-utils

Rust
82
star
43

trappist

Rust
82
star
44

txwrapper-core

Tools for FRAME chain builders to publish chain specific offline transaction generation libraries.
TypeScript
77
star
45

substrate-playground

Start hacking your substrate runtime in a web based VSCode like IDE
TypeScript
74
star
46

scale-info

Info about SCALE encodable Rust types
Rust
73
star
47

parity-tokio-ipc

Parity tokio-ipc
Rust
73
star
48

substrate-light-ui

Minimal, WASM-light-client-bundled Substrate wallet for balance transfers
TypeScript
72
star
49

substrate-ui

Bondy Polkadot UI
JavaScript
72
star
50

statemint

Statemint Node Implementation
Rust
71
star
51

canvas

Node implementation for Canvas ‒ a Substrate parachain for smart contracts.
Rust
69
star
52

substrate-up

Scripts for working with new Substrate projects
Shell
66
star
53

useink

A React hooks library for ink!
TypeScript
62
star
54

stateless-blockchain

Stateless Blockchain on Substrate using RSA Accumulators
Rust
60
star
55

txwrapper

Helper funtions for offline transaction generation.
TypeScript
58
star
56

contracts-ui

Web application for deploying wasm smart contracts on Substrate chains that include the FRAME contracts pallet
TypeScript
58
star
57

awesome-ink

A curated list of awesome projects related to Parity's ink!.
56
star
58

srtool

A fork of chevdor's srtool
Shell
56
star
59

cargo-unleash

cargo release automatisation tooling for massiv mono-repos
Rust
55
star
60

ss58-registry

Registry for SS58 account types
Rust
55
star
61

oo7

The Bonds framework along with associated modules.
JavaScript
53
star
62

diener

Diener - dependency diener is a tool for easily changing https://github.com/paritytech/substrate or https://github.com/paritytech/polkadot dependency versions
Rust
52
star
63

lunarity

Lunarity - a Solidity parser in Rust
Rust
50
star
64

nohash-hasher

An implementation of `std :: hash :: Hasher` which does not hash at all.
Rust
49
star
65

arkworks-extensions

Library to integrate arkworks-rs/algebra into Substrate
Rust
47
star
66

wasm-instrument

Instrument and transform wasm modules.
Rust
47
star
67

asset-transfer-api

Typescript API aiming to provide clear, and simple to use tools for transferring assets across common good parachains.
TypeScript
43
star
68

fleetwood

Testbed repo for trying out ideas of what a smart contract API in Rust would look like
Rust
41
star
69

scripts

Collection of Dockerfiles, scripts and related resources
Dockerfile
40
star
70

trappist-extra

Dart
38
star
71

polkadot-introspector

A collection of tools focused on debugging and monitoring the relay chain and parachain progress from a 🐦-view
Rust
38
star
72

parity-extension

Parity Chrome Extension
JavaScript
37
star
73

rhododendron

Asynchronously safe BFT consensus, implementation in Rust
Rust
36
star
74

desub

Decode Substrate with Backwards-Compatible Metadata
Rust
36
star
75

ethkey

Ethereum key generator
Rust
35
star
76

psvm

Polkadot SDK Version Manager
Rust
35
star
77

substrate-open-working-groups

The Susbstrate Open Working Groups (SOWG) are community-based mechanisms to develop standards, specifications, implementations, guidelines or general initiatives in regards to the Substrate framework. It could, but not restricted to, lead to new Polkadot Standards Proposals. SOWG is meant as a place to find and track ongoing efforts and enable everybody with similar interests to join and contribute.
35
star
78

substrate-bip39

Rust
34
star
79

primitives

Rust
34
star
80

parity-config-generator

Parity Config Generator
JavaScript
34
star
81

zombienet-sdk

ZombieNet SDK
Rust
33
star
82

Nomidot

Staking Portal for Polkadot and Kusama
TypeScript
32
star
83

subdb

Experimental domain-specific database for Substrate
Rust
32
star
84

polkadot-api

TypeScript
31
star
85

polkadot-testnet-faucet

TypeScript
30
star
86

polkassembly

Polkassembly now has a new home:
TypeScript
30
star
87

pallet-contracts-waterfall

Collection of simple Substrate smart contract examples written in Rust, AssemblyScript, Solang and the smart contract language ink! to test substrates pallet-contracts module
TypeScript
30
star
88

metadata-portal

Metadata portal for Parity Signer
TypeScript
29
star
89

polkadot-onboard

A wallet integration SDK to facilitate adding different type of wallets (extension, WC, Ledger) to Dapps.
TypeScript
28
star
90

vscode-substrate

Substrate Marketplace VSCode Plugin
TypeScript
28
star
91

oo7-bare

The Bond API.
JavaScript
27
star
92

bigint

Rust
27
star
93

extended-parachain-template

Node template to build parachains with all the required pallets. Slightly opinionated based on what majority of parachain teams are using.
Rust
27
star
94

orchestra

A partial actor pattern with a global orchestrator.
Rust
27
star
95

polkadot-scripts

Collection of random scripts and utilities written for Polkadot
TypeScript
27
star
96

sub-flood

Flooding substrate node with transactions
TypeScript
26
star
97

polkadot-cloud

[BETA] A library and automated platform for developing and publishing assets for Polkadot dapps.
TypeScript
25
star
98

ink-playground

Browser Based Playground for editing, sharing & compiling ink! Smart Contracts
Rust
25
star
99

link

Unstoppable URL shortener built with the ink! smart contract language.
TypeScript
25
star
100

sms-verification

SMS verification for Parity.
JavaScript
25
star