Bootstrapping new testnet

1. Prepare your env

This guide assumes you have environment capable of building the substrate node. Follow Build, run & test using source code guide to setup it.

2. Prepare release

Tag the commit from which you'll build the chain spec and run initial nodes. Use this version of code for all following commands.

3. Preparing your initial nodes' keys

For each of your initial nodes/validators, you need following keys:

  • controller account, that will allow starting/stopping validation

  • stash account, that will actually hold staked LLD

  • sessions keys:

    • grandpa (ed25519)

    • babe (sr25519)

    • im_online (sr25519)

    • authority_discovery (sr25519)

4. Preparing shell

Commands below require the LIBERLAND_NODE variable to be set to command of node binary. Examples:

Scripts also respect the LIBERLAND_NODE variable, but default to running cargo if variable is unset.

Generating Controller and stash keys

These are regular accounts, you can use Polkadot Extension to generate them.

If you prefer, you can also generate them manually from seed:

Generating session keys

Make sure you're using different seed for each node.

Option 1: using script

Use the get_session_keys_from_seed.sh:

Option 2: manually

Notice that first command (for grandpa) uses ed25519 scheme and others use sr25519 scheme.

4. Building chain spec

While it's possible to create the spec file manually, it's recommended to build it from code.

Make sure you have the correct version of code checked out. Go to bin/node/cli/src/chain_spec.rs and find the fn staging_testnet_config_genesis() function. In there, do the following changes:

  1. Update initial_authorities. This is the place were you need to put your initial nodes' keys from Step 2. The order for each item is:

    • Stash's public key (SS58)

    • Controller's public key (SS58)

    • Grandpa public key (hex)

    • Babe public key (hex)

    • Im_online public key (hex)

    • Authority_discovery public key (hex)

  2. Update the citizens. Each address on this list will be a valid citizen with a KnownGood judgement and will receive 10^18 LLD.

  3. Update the registrar_key - it's the address of Citizenship Registrar that will be able to provide identity judgements for citizenship.

  4. Update the root_key - it's the account capable of executing sudo calls

  5. Update the technical_committee

After updating the code, we may now generate the human-readable template for spec:

Open the generated new_chain_spec.json file in your editor. You may want to adjust things like name, id, properties.displayName to match your new testnet.

Generate the raw chain spec:

The generated new_chain_spec.raw.json is the file that should be distributed to all participants of the network and will be used to run our initial nodes.

5. Running our first node

Inserting session keys

Option 1: using script

If you've generated session keys using get_session_keys_from_seed.sh, you may now run insert_session_keys_from_seed.sh with the same seed. Make sure you pass the correct chain spec and path where node should store its data:

Option 2: manually

Run following commands. Make sure you pass proper chain spec file, path to node storage and insert the same seed as one used for preparing keys for chain spec. Notice that first command (for grandpa) uses ed25519 scheme and others use sr25519 scheme.

Running the first node

Make sure you pass the same chain spec and path to data as when inserting session keys:

Note the Local node identity is: 12D3KooWL8az46KDc6d4iMCtwwx2RW7fxP7DfNYMVQRX7STWzBcj in output. Copy this ID from your output, we'll need it later.

6. Running remaining initial nodes

Inserting session keys

Follow the same procedure as for the first node. Make sure you're using different seed for each node.

Running the node

Create the bootstrap node address. The format is:

Where:

  • <IP_ADDRESS> must be replaced with the IP address of your initial node

  • ID must be replaced with the Local node identity printed in startup log of your initial node.

Make sure you pass the same chain spec and path to data as when inserting session keys.

Make sure it shows (1 peers) (or more) in the logs after a minute. If not, verify that your initial node is running and bootnode address is correct. It's OK if it doesn't produce/finalize blocks yet, we need all nodes for that.

6. Verify

Now that we've added all initial nodes, we should see that blocks are getting finalized.

Good (notice finalized #9):

Bad (notice finalized #0):

If blocks aren't finalized, verify that correct session keys were inserted to each node.

Last updated