Skip to content

blue-freedom-technologies/test-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 

Repository files navigation

Local Test Networks

All the setups demonstrated in this document were done using ubuntu-22-04-3-lts. It's assumed that Rust is installed and running.

Table of Contents

Requirements

Manual setup

Zombienet setup


Polkadot SDK

Login as root

su root

And follow the instructions in here

Test the setup

polkadot --version

image

The Polkadot Parachain Host Implementers' Guide


Zombienet

Install Zombienet executable

chmod +x zombienet-linux-x64
sudo cp zombienet-linux-x64 /usr/local/bin

Test the setup

zombienet-linux-x64 version

image

Zombienet Book


Manual setup

Relay Chain

We should have at least two validators (relay chain nodes) running for every collator (parachain block authoring nodes) on our network.

Create the directories

mkdir test-network
cd test-network
mkdir binaries

Generate a raw chain spec

polkadot build-spec --chain rococo-local --disable-default-bootnode --raw > ./tmp/raw-relay-chainspec.json

image

Start the Alice node(new terminal)

polkadot --chain ./tmp/raw-relay-chainspec.json --alice --validator --tmp --port 30333

image

Start the Bob node(new terminal)

polkadot --chain ./tmp/raw-relay-chainspec.json --bob --validator --tmp --port 30334

image

Connect to the relay chain

image

Reserve a paraid

image

Confirm the events

image

Parachain

Clone the repo to get the Cumulus SDK

git clone --branch polkadot-v1.3.0 https://github.com/paritytech/polkadot-sdk.git

image

Compile the polkadot parachain node

cd polkadot-sdk/cumulus/polkadot-parachain
cargo build --release --bin polkadot-parachain

Copy the polkadot-parachain binary

cd ../../../
cp -r ./polkadot-sdk/target/release/ ./binaries/polkadot-parachain

Generate the plain text chain specification

./binaries/polkadot-parachain/polkadot-parachain build-spec --disable-default-bootnode > ./tmp/plain-parachain-chainspec.json

image

Modify the plain text chain specification

image

Generate a raw chain specification file from the modified plain text chain specification

./binaries/polkadot-parachain/polkadot-parachain build-spec --chain ./tmp/plain-parachain-chainspec.json --disable-default-bootnode --raw > ./tmp/raw-parachain-chainspec.json

image

Export the WebAssembly runtime

./binaries/polkadot-parachain/polkadot-parachain export-genesis-wasm --chain ./tmp/raw-parachain-chainspec.json ./tmp/para-2000-wasm

image

Generate a parachain genesis state

./binaries/polkadot-parachain/polkadot-parachain export-genesis-state --chain ./tmp/raw-parachain-chainspec.json ./tmp/para-2000-genesis-state

image

Start the collator node alice

./binaries/polkadot-parachain/polkadot-parachain --alice --collator --force-authoring --chain ./tmp/raw-parachain-chainspec.json --base-path ./tmp/parachain/alice --port 40333 --rpc-port 8844 -- --execution wasm --chain ./tmp/raw-relay-chainspec.json --port 30343 --rpc-port 9977

image

Register the parachain with the local relay chain

image

Sudo transaction

Note: We are bypassing the steps required to acquire a parachain or parathread slot which normally is a parachain auction.

image

Testing the parachain.

image

Relay Chain (Private network of trusted validators)

We should have at least two validators (relay chain nodes) running for every collator (parachain block authoring nodes) on our network. Keys are generated in a air-gapped computer that is deliberately separated from the internet for security reasons. This means that the computer does not have any physical or wireless connections to any other network that is connected to the internet.

Session keys for Node I(validator)

Session keys are hot keys that must be kept online by a validator to perform network operations.

Generate a session key using the Sr25519 scheme.

polkadot key generate --scheme Sr25519 --password-interactive
Key password:********
Secret phrase:       sick cry forget enroll retreat female slab uncover remember neutral time stadium
  Network ID:        substrate
  Secret seed:       0x6f1a8e2665eeec408ad9efd4d5ae5e38737f8b7777d58d063364a61584a42d19
  Public key (hex):  0xf6fb2baa764e9c7e1d6c27324f55dc585b89e1e74b8d7a409d84c5bccf818341
  Account ID:        0xf6fb2baa764e9c7e1d6c27324f55dc585b89e1e74b8d7a409d84c5bccf818341
  Public key (SS58): 5HeYFTPrAufPytrEGQUvSSLHbKSqb9e2NVaBRDTBvZ769kq3
  SS58 Address:      5HeYFTPrAufPytrEGQUvSSLHbKSqb9e2NVaBRDTBvZ769kq3

Derive the grandpa key using Ed25519 scheme.

polkadot key inspect --password-interactive --scheme Ed25519 "sick cry forget enroll retreat female slab uncover remember neutral time stadium"
Key password:********
Secret phrase:       sick cry forget enroll retreat female slab uncover remember neutral time stadium
  Network ID:        substrate
  Secret seed:       0x6f1a8e2665eeec408ad9efd4d5ae5e38737f8b7777d58d063364a61584a42d19
  Public key (hex):  0xd020bc843ece07f62adafd6e73fd59fbb4983eb37308b00302b9b68784141a11
  Account ID:        0xd020bc843ece07f62adafd6e73fd59fbb4983eb37308b00302b9b68784141a11
  Public key (SS58): 5GmbYPGYH1KxnHw1nXunNQjKJMfeFf2vtmAJJLKq9B856Nfx
  SS58 Address:      5GmbYPGYH1KxnHw1nXunNQjKJMfeFf2vtmAJJLKq9B856Nfx

Derive the beefy key using EdDSA scheme.

polkadot key inspect --password-interactive --scheme Ecdsa "sick cry forget enroll retreat female slab uncover remember neutral time stadium"
Key password:********
Secret phrase:       sick cry forget enroll retreat female slab uncover remember neutral time stadium
  Network ID:        substrate
  Secret seed:       0x6f1a8e2665eeec408ad9efd4d5ae5e38737f8b7777d58d063364a61584a42d19
  Public key (hex):  0x03e6f4ff962acbc87abca901754e5aa4caa78169150cd3caa0a9955b6e4a74a856
  Account ID:        0x8dd3e3b15d3cf068ec8b23bcba4883a0ed0db744eabcd9e117b1a85001ff6a48
  Public key (SS58): KWDw8nyTtutLkcAyJE6jFsaZFVPUkoZjzXF5U8XaYX4kAKGwD
  SS58 Address:      5FGfZ3FhBZCQFNh1BZyNzC1Hv3aPhw2jATnKz9NbkNxLuNc6

Generate the babe key using Sr25519 scheme.

polkadot key generate --scheme Sr25519 --password-interactive
Key password:********
Secret phrase:       vanish street orphan print magic atom link census clever sound quote logic
  Network ID:        substrate
  Secret seed:       0xfeb1e206b7394fdff897a2243c8b2ae113e0b6fded4a9d2f42f691851dcc0745
  Public key (hex):  0x2c9b041e0d7f686834958607c306b900701c07cf10265eb67d1aaf1cf2e23407
  Account ID:        0x2c9b041e0d7f686834958607c306b900701c07cf10265eb67d1aaf1cf2e23407
  Public key (SS58): 5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf
  SS58 Address:      5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf

Node I(validator) keys:

  • Id key(Sr25519):5HeYFTPrAufPytrEGQUvSSLHbKSqb9e2NVaBRDTBvZ769kq3
  • grandpa (gran/Ed25519):5GmbYPGYH1KxnHw1nXunNQjKJMfeFf2vtmAJJLKq9B856Nfx
  • beefy (beef/EdDSA):KWDw8nyTtutLkcAyJE6jFsaZFVPUkoZjzXF5U8XaYX4kAKGwD
  • babe (babe/Sr25519):5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf
  • im_online (imon/Sr25519):5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf
  • para_validator (para/Sr25519):5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf
  • para_assignment (asgn/Sr25519):5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf
  • authority_discovery (audi/Sr25519):5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf
"session": {
  "keys": [
    [
    "5HeYFTPrAufPytrEGQUvSSLHbKSqb9e2NVaBRDTBvZ769kq3",
    "5HeYFTPrAufPytrEGQUvSSLHbKSqb9e2NVaBRDTBvZ769kq3",
      {
        "grandpa": "5GmbYPGYH1KxnHw1nXunNQjKJMfeFf2vtmAJJLKq9B856Nfx",
        "babe": "5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf",
        "im_online": "5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf",
        "para_validator": "5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf",
        "para_assignment": "5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf",
        "authority_discovery": "5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf",
        "beefy": "KWDw8nyTtutLkcAyJE6jFsaZFVPUkoZjzXF5U8XaYX4kAKGwD"
      }
    ]
},

Session keys for Node II(validator)

Session keys are hot keys that must be kept online by a validator to perform network operations.

Generate a session key using the Sr25519 scheme.

polkadot key generate --scheme Sr25519 --password-interactive
Key password:********
Secret phrase:       voice now jewel reopen distance notice cry output dwarf broccoli hint gaze
  Network ID:        substrate
  Secret seed:       0xe05300a2a2233a5ae2620737f7c96e61b9d98e8e027cda8f467de3160cfe0320
  Public key (hex):  0x6e7b0b13b3f316a794a644b50953b14b6238c7daddda688601a09e27dc662b13
  Account ID:        0x6e7b0b13b3f316a794a644b50953b14b6238c7daddda688601a09e27dc662b13
  Public key (SS58): 5EZZgACHStMKRERaEV6xdrB459SEunYxkNhWEiCBZB3WZ8WG
  SS58 Address:      5EZZgACHStMKRERaEV6xdrB459SEunYxkNhWEiCBZB3WZ8WG

Derive the grandpa key using Ed25519 scheme.

polkadot key inspect --password-interactive --scheme Ed25519 "voice now jewel reopen distance notice cry output dwarf broccoli hint gaze"
Key password:********
Secret phrase:       voice now jewel reopen distance notice cry output dwarf broccoli hint gaze
  Network ID:        substrate
  Secret seed:       0xe05300a2a2233a5ae2620737f7c96e61b9d98e8e027cda8f467de3160cfe0320
  Public key (hex):  0xf18e8c9d4ef09dc3cdb87ed3a893a711949349e5582e26f2bbfc22f3ea338e0d
  Account ID:        0xf18e8c9d4ef09dc3cdb87ed3a893a711949349e5582e26f2bbfc22f3ea338e0d
  Public key (SS58): 5HXRk4txhxjAGHPVTyPgpu1zDeWtGruJWyPmih5bDq1rSkZf
  SS58 Address:      5HXRk4txhxjAGHPVTyPgpu1zDeWtGruJWyPmih5bDq1rSkZf

Derive the beefy key using EdDSA scheme.

polkadot key inspect --password-interactive --scheme Ecdsa "voice now jewel reopen distance notice cry output dwarf broccoli hint gaze"
Key password:********
Secret phrase:       voice now jewel reopen distance notice cry output dwarf broccoli hint gaze
  Network ID:        substrate
  Secret seed:       0xe05300a2a2233a5ae2620737f7c96e61b9d98e8e027cda8f467de3160cfe0320
  Public key (hex):  0x027742dd115c12ea392832333fc36bedc943df190b0fe585c310241fc5bd284f53
  Account ID:        0x0f8fd6db89bfd4554c6efac2273b3f0621d88790262b881d958e113253fc2b7b
  Public key (SS58): KW5d2JWTUEQTPFvLgDQVuj3w1Ww6cqrwCn8vN4pt7hbtm7i3H
  SS58 Address:      5CR7Jd1YoKuKkEQ3dZn7X18tNcJFQPi4zVHTchJwGQTtyVmq

Generate the babe key using Sr25519 scheme.

polkadot key generate --scheme Sr25519 --password-interactive
Key password:********
Secret phrase:       expire sleep seminar sad eager faculty inflict great arm slice champion similar
  Network ID:        substrate
  Secret seed:       0xc35d77c56c05ff2365af8b8974403e1ac2c16c9da0958245efd63ea9a0f0372b
  Public key (hex):  0x0ca09f828a324f1161064a9508057e742f87abd4fc8624a8485a18f90b13982a
  Account ID:        0x0ca09f828a324f1161064a9508057e742f87abd4fc8624a8485a18f90b13982a
  Public key (SS58): 5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K
  SS58 Address:      5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K

Node II(validator) keys:

  • key(Sr25519):5EZZgACHStMKRERaEV6xdrB459SEunYxkNhWEiCBZB3WZ8WG
  • grandpa (gran/Ed25519):5HXRk4txhxjAGHPVTyPgpu1zDeWtGruJWyPmih5bDq1rSkZf
  • beefy (beef/EdDSA):KW5d2JWTUEQTPFvLgDQVuj3w1Ww6cqrwCn8vN4pt7hbtm7i3H
  • babe (babe/Sr25519):5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K
  • im_online (imon/Sr25519):5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K
  • para_validator (para/Sr25519):5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K
  • para_assignment (asgn/Sr25519):5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K
  • authority_discovery (audi/Sr25519):5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K
"session": {
  "keys": [
    [
    "5EZZgACHStMKRERaEV6xdrB459SEunYxkNhWEiCBZB3WZ8WG",
    "5EZZgACHStMKRERaEV6xdrB459SEunYxkNhWEiCBZB3WZ8WG",
      {
        "grandpa": "5HXRk4txhxjAGHPVTyPgpu1zDeWtGruJWyPmih5bDq1rSkZf",
        "babe": "5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K",
        "im_online": "5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K",
        "para_validator": "5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K",
        "para_assignment": "5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K",
        "authority_discovery": "5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K",
        "beefy": "KW5d2JWTUEQTPFvLgDQVuj3w1Ww6cqrwCn8vN4pt7hbtm7i3H"
      }
    ]
},

Create a custom chain specification

Generate a raw chain spec

polkadot build-spec --disable-default-bootnode --chain rococo-local > ./tmp/plain-relay-chain-spec-private-network.json

image

Modify the local relay chain specification

"session": {
  "keys": [
    [
      "5HeYFTPrAufPytrEGQUvSSLHbKSqb9e2NVaBRDTBvZ769kq3",
      "5HeYFTPrAufPytrEGQUvSSLHbKSqb9e2NVaBRDTBvZ769kq3",
      {
        "grandpa": "5GmbYPGYH1KxnHw1nXunNQjKJMfeFf2vtmAJJLKq9B856Nfx",
        "babe": "5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf",
        "im_online": "5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf",
        "para_validator": "5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf",
        "para_assignment": "5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf",
        "authority_discovery": "5D5C1jcLDnzV4KXDsrbKpeM1bzBrCXJywAJk1DHraSdvBmQf",
        "beefy": "KWDw8nyTtutLkcAyJE6jFsaZFVPUkoZjzXF5U8XaYX4kAKGwD"
      }
    ],
    [
      "5EZZgACHStMKRERaEV6xdrB459SEunYxkNhWEiCBZB3WZ8WG",
      "5EZZgACHStMKRERaEV6xdrB459SEunYxkNhWEiCBZB3WZ8WG",
      {
        "grandpa": "5HXRk4txhxjAGHPVTyPgpu1zDeWtGruJWyPmih5bDq1rSkZf",
        "babe": "5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K",
        "im_online": "5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K",
        "para_validator": "5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K",
        "para_assignment": "5CMG9U65GY9gR4qoKHdZbSfAu9NEUo2CXAg9uSeZiv1ENM1K",
        "authority_discovery": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty",
        "beefy": "KW5d2JWTUEQTPFvLgDQVuj3w1Ww6cqrwCn8vN4pt7hbtm7i3H"
      }
    ]
  ]
},

Generate the plain text chain specification

polkadot build-spec --chain=./tmp/plain-relay-chain-spec-private-network.json --raw --disable-default-bootnode > ./tmp/raw-relay-chain-spec-private-network.json

image

Start Node I validator.

polkadot --base-path ./tmp/node01 --chain ./tmp/raw-relay-chain-spec-private-network.json --port 30333 --rpc-port 9945 --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" --validator --rpc-methods Unsafe --name MyNode01 --password-interactive

image

Add grandpa key to the keystore(in a new terminal).

polkadot key insert --base-path ./tmp/node01 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Ed25519 --suri "sick cry forget enroll retreat female slab uncover remember neutral time stadium" --password-interactive --key-type gran

Add beefy key to the keystore.

polkadot key insert --base-path ./tmp/node01 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Ecdsa --suri "sick cry forget enroll retreat female slab uncover remember neutral time stadium" --password-interactive --key-type beef

Add babe key to the keystore.

polkadot key insert --base-path ./tmp/node01 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Sr25519 --suri "vanish street orphan print magic atom link census clever sound quote logic" --password-interactive --key-type babe

Add imon key to the keystore.

polkadot key insert --base-path ./tmp/node01 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Sr25519 --suri "vanish street orphan print magic atom link census clever sound quote logic" --password-interactive --key-type imon

Add para key to the keystore.

polkadot key insert --base-path ./tmp/node01 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Sr25519 --suri "vanish street orphan print magic atom link census clever sound quote logic" --password-interactive --key-type para

Add asgn key to the keystore.

polkadot key insert --base-path ./tmp/node01 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Sr25519 --suri "vanish street orphan print magic atom link census clever sound quote logic" --password-interactive --key-type asgn

Add audi key to the keystore.

polkadot key insert --base-path ./tmp/node01 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Sr25519 --suri "vanish street orphan print magic atom link census clever sound quote logic" --password-interactive --key-type audi

Verify the seven files holding the keys created in the keystore.

ls -l ./tmp/node01/chains/rococo_local_testnet/keystore/

image

Restart Node I.

polkadot --base-path ./tmp/node01 --chain ./tmp/raw-relay-chain-spec-private-network.json --port 30333 --rpc-port 9945 --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" --validator --rpc-methods Unsafe --name MyNode01 --password-interactive

PeerId

12D3KooWRVmQxg1iqCb92GPLETct2t1qPNpscQXe8YkLdyfNnZwx

Start Node II validator.

polkadot --base-path ./tmp/node02 --chain ./tmp/raw-relay-chain-spec-private-network.json --port 30334 --rpc-port 9946 --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" --validator --rpc-methods Unsafe --name MyNode02 --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWRVmQxg1iqCb92GPLETct2t1qPNpscQXe8YkLdyfNnZwx --password-interactive

image

Add grandpa key to the keystore(in a new terminal).

polkadot key insert --base-path ./tmp/node02 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Ed25519 --suri "voice now jewel reopen distance notice cry output dwarf broccoli hint gaze" --password-interactive --key-type gran

Add beefy key to the keystore.

polkadot key insert --base-path ./tmp/node02 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Ecdsa --suri "voice now jewel reopen distance notice cry output dwarf broccoli hint gaze" --password-interactive --key-type beef

Add babe key to the keystore.

polkadot key insert --base-path ./tmp/node02 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Sr25519 --suri "expire sleep seminar sad eager faculty inflict great arm slice champion similar" --password-interactive --key-type babe

Add imon key to the keystore.

polkadot key insert --base-path ./tmp/node02 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Sr25519 --suri "expire sleep seminar sad eager faculty inflict great arm slice champion similar" --password-interactive --key-type imon

Add para key to the keystore.

polkadot key insert --base-path ./tmp/node02 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Sr25519 --suri "expire sleep seminar sad eager faculty inflict great arm slice champion similar" --password-interactive --key-type para

Add asgn key to the keystore.

polkadot key insert --base-path ./tmp/node02 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Sr25519 --suri "expire sleep seminar sad eager faculty inflict great arm slice champion similar" --password-interactive --key-type asgn

Add audi key to the keystore.

polkadot key insert --base-path ./tmp/node02 --chain ./tmp/raw-relay-chain-spec-private-network.json --scheme Sr25519 --suri "expire sleep seminar sad eager faculty inflict great arm slice champion similar" --password-interactive --key-type audi

Verify the seven files holding the keys created in the keystore.

ls -l ./tmp/node02/chains/rococo_local_testnet/keystore/

image

Restart Node II.

polkadot --base-path ./tmp/node02 --chain ./tmp/raw-relay-chain-spec-private-network.json --port 30334 --rpc-port 9946 --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" --validator --rpc-methods Unsafe --name MyNode02 --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWRVmQxg1iqCb92GPLETct2t1qPNpscQXe8YkLdyfNnZwx --password-interactive

Connect to the relay chain

image

Reserve a paraid

image

Confirm the events

image

Parachain (Private network of trusted collatores)

Clone the repo to get the Cumulus SDK

git clone --branch polkadot-v1.3.0 https://github.com/paritytech/polkadot-sdk.git

image

Compile the polkadot parachain node

cd polkadot-sdk/cumulus/polkadot-parachain
cargo build --release --bin polkadot-parachain

Copy the polkadot-parachain binary

cd ../../../
cp -r ./polkadot-sdk/target/release/ ./binaries/polkadot-parachain

Generate two session keys using the Sr25519 scheme for aura

./binaries/polkadot-parachain/polkadot-parachain key generate --scheme Sr25519 --password-interactive
Key password:********
Secret phrase:       elevator exotic trick couple pave trend rude income spider leader first churn
  Network ID:        substrate
  Secret seed:       0xd3bb290be811bc5d9fb1762236edced9b43edac30e71a739dc3f90a8424d9a56
  Public key (hex):  0xaabf7651b017d3ffbe23674ea434f297ea468ffee560cfb55b03cbe505cb8d2f
  Account ID:        0xaabf7651b017d3ffbe23674ea434f297ea468ffee560cfb55b03cbe505cb8d2f
  Public key (SS58): 5FvasdQkzcgBBWVMTjminfi3Nk4s9ymZEJLxrcB3L9KikpRm
  SS58 Address:      5FvasdQkzcgBBWVMTjminfi3Nk4s9ymZEJLxrcB3L9KikpRm
Key password:********
Key password: 
Secret phrase:       enemy bus social knock parrot maple into actress pause brisk know bracket
  Network ID:        substrate
  Secret seed:       0x8b334e8c01fe1542ccb715ad7f3cb9f2585106a8dd78aa0698564c2c9f42a1e6
  Public key (hex):  0x187e85ee44a439442b11d423f1aadbc3d1016f1208317326d1ad67d8bc9fe82c
  Account ID:        0x187e85ee44a439442b11d423f1aadbc3d1016f1208317326d1ad67d8bc9fe82c
  Public key (SS58): 5CcpbGUiNjeHH9tsCMQQBNwNxfTPGSWMV2i9uY9kx7MjCh9p
  SS58 Address:      5CcpbGUiNjeHH9tsCMQQBNwNxfTPGSWMV2i9uY9kx7MjCh9p

Generate the plain text chain specification

./binaries/polkadot-parachain/polkadot-parachain build-spec --disable-default-bootnode > ./tmp/plain-parachain-chain-spec-private-network.json

image

Modify the plain text chain specification

image

"aura": {
  "authorities":
    [
      "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
      "5CcpbGUiNjeHH9tsCMQQBNwNxfTPGSWMV2i9uY9kx7MjCh9p"
    ]
},

Generate a raw chain specification file from the modified plain text chain specification

./binaries/polkadot-parachain/polkadot-parachain build-spec --chain ./tmp/plain-parachain-chain-spec-private-network.json --disable-default-bootnode --raw > ./tmp/raw-parachain-chain-spec-private-network.json

image

Start the collator node

./binaries/polkadot-parachain/polkadot-parachain --collator --force-authoring --chain ./tmp/raw-parachain-chain-spec-private-network.json --base-path ./tmp/parachain/coll01 --port 40333 --rpc-port 8844 -- --execution wasm --chain ./tmp/raw-relay-chain-spec-private-network.json --port 30343 --rpc-port 9977 --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWRVmQxg1iqCb92GPLETct2t1qPNpscQXe8YkLdyfNnZwx --password-interactive

image

Add aura key to the keystore.

./binaries/polkadot-parachain/polkadot-parachain key insert --base-path ./tmp/parachain/coll01 --chain ./tmp/raw-parachain-chain-spec-private-network.json  --scheme Sr25519 --suri "elevator exotic trick couple pave trend rude income spider leader first churn" --password-interactive --key-type aura

Verify the file holding the key created in the keystore.

ls -l ./tmp/parachain/coll01/chains/local_testnet/keystore/

image

Restart collator node.

./binaries/polkadot-parachain/polkadot-parachain --collator --force-authoring --chain ./tmp/raw-parachain-chain-spec-private-network.json --base-path ./tmp/parachain/coll01 --port 40333 --rpc-port 8844 -- --execution wasm --chain ./tmp/raw-relay-chain-spec-private-network.json --port 30343 --rpc-port 9977 --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWRVmQxg1iqCb92GPLETct2t1qPNpscQXe8YkLdyfNnZwx --password-interactive

Export the WebAssembly runtime

./binaries/polkadot-parachain/polkadot-parachain export-genesis-wasm --chain ./tmp/raw-parachain-chain-spec-private-network.json ./tmp/parachain-private-network-wasm

Generate a parachain genesis state

./binaries/polkadot-parachain/polkadot-parachain export-genesis-state --chain ./tmp/raw-parachain-chain-spec-private-network.json ./tmp/parachain-private-network-state

Register the parachain with the local relay chain

image

Sudo transaction

Note: We are bypassing the steps required to acquire a parachain or parathread slot which normally is a parachain auction.

image

Testing the parachain.

image


Zombienet setup

Simple network

A simple network specification with two relay chain validators nodes and one collator.

Create the network specification file

[relaychain]
default_command = "polkadot"
chain = "rococo-local"

  [[relaychain.nodes]]
  name = "node01"
  validator = true

  [[relaychain.nodes]]
  name = "node02"
  validator = true

[[parachains]]
id = 2000
cumulus_based = true

  [parachains.collator]
  name = "collator01"
  command = "./binaries/polkadot-parachain/polkadot-parachain"
  args = ["--force-authoring","-lparachain=debug"]

Spawn a local testing network

zombienet-linux-x64 spawn network-specification.toml -p native

image

Testing the parachain

image


Network with HRMP Channels

A network specification with tree relay chain validators nodes and two parahachains with four collators. This type of setup is used for building with the hrmp-channels

Create the network specification file

[settings]
node_spawn_timeout = 240

[relaychain]
default_command = "polkadot"
default_args = [ "-lparachain=debug,xcm=trace" ]
chain = "rococo-local"

	[[relaychain.nodes]]
	name = "node01"
	validator = true
	rpc_port = 9932
	ws_port = 9942
	balance = 2000000000000

	[[relaychain.nodes]]
	name = "node02"
	validator = true
	rpc_port = 9933
	ws_port = 9943
	balance = 2000000000000

	[[relaychain.nodes]]
	name = "node03"
	validator = true
	rpc_port = 9934
	ws_port = 9944
	balance = 2000000000000

[[parachains]]
id = 1013
cumulus_based = true

	[[parachains.collators]]
	name = "collator01-1013"
	validator = true
	command = "./binaries/polkadot-parachain/polkadot-parachain"
	rpc_port = 8933
	ws_port = 8943
	args = [
		"-lparachain=debug,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace",
		"--force-authoring"
	]

	# run bob as parachain collator
	[[parachains.collators]]
	name = "collator02-1013"
	validator = true
	command = "./binaries/polkadot-parachain/polkadot-parachain"
	rpc_port = 8934
	ws_port = 8944
	args = [
		"-lparachain=trace,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace",
		"--force-authoring"
	]

[[parachains]]
id = 1000
cumulus_based = true

	[[parachains.collators]]
	name = "collator01-1000"
	rpc_port = 9911
	ws_port = 9910
	command = "./binaries/polkadot-parachain/polkadot-parachain"
	args = [
		"-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace"
	]

	[[parachains.collators]]
	name = "collator02-1000"
	command = "./binaries/polkadot-parachain/polkadot-parachain"
	args = [
		"-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace"
	]

#[[hrmp_channels]]
#sender = 1000
#recipient = 1013
#max_capacity = 4
#max_message_size = 524288
#
#[[hrmp_channels]]
#sender = 1013
#recipient = 1000
#max_capacity = 4
#max_message_size = 524288

Spawn a local testing network

zombienet-linux-x64 spawn network-specification-hrmp.toml -p native

image

Testing the parachains

image


Network with the contracts-rococo parachain

A network specification with two relay chain validators nodes and one parahachain with one collator.This is a parachain node for ink! smart contracts. It contains a default configuration of Substrate's module for smart contracts ‒ the pallet-contracts.

Create the network specification file

[settings]
timeout = 1000

[relaychain]
default_command = "polkadot"
default_args = [ "-lparachain=debug" ]
chain = "rococo-local"

	[[relaychain.nodes]]
	name = "node01"
	validator = true
	rpc_port = 9932
	ws_port = 9942
	balance = 2000000000000

	[[relaychain.nodes]]
	name = "node02"
	validator = true
	rpc_port = 9933
	ws_port = 9943
	balance = 2000000000000

[[parachains]]
id = 2000
cumulus_based = true
chain = "contracts-rococo"

	[[parachains.collators]]
	name = "collator01-2000"
	validator = true
	command = "./binaries/polkadot-parachain/polkadot-parachain"
	rpc_port = 8933
	ws_port = 8943
	args = [
	    "-lparachain=debug",
            "--force-authoring"
	]

Spawn a local testing network

zombienet-linux-x64 spawn network-specification-ink.toml -p native

image

Testing the parachain

image


References:

Polkadot SDK(v1.3.0)
Cumulus SDK
Polkado(v1.3.0)
Zombienet