Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DOBEN/4c2ff7852a0b9785a384f24ba54b488b to your computer and use it in GitHub Desktop.
Save DOBEN/4c2ff7852a0b9785a384f24ba54b488b to your computer and use it in GitHub Desktop.
Running a Concordium node from the source code

If you don't need to run the node from the source code, use the public docker images and guides:

Guide to run published nodes

Download Node Distributions

Step 1:

Ensure you have all dependencies installed:

Step 2:

Get or generate the genesis data:

Option 1 (Generate the genesis data):

If you generate new genesis data, you start a new blockchain network. Your node will not be able to join devnet, stagenet, testnet or mainnet. Use the genesis-creator tool for generating fresh genesis data.

You can use the newest example (at the time of writing that was protocol level 9) to start a network with the newest features.

Recommended is to change the number of validators in the genesis9.toml file to 1 if you just want to start the most basic network with just one node:

E.g. change

[[accounts]]
kind = "fresh"
balance = "1000000000000000"
stake = "500000000000000"
template = "baker"
identityProvider = 0
numKeys = 1
threshold = 1
repeat = 5

to

[[accounts]]
kind = "fresh"
balance = "1000000000000000"
stake = "500000000000000"
template = "baker"
identityProvider = 0
numKeys = 1
threshold = 1
repeat = 1

You can now generate the genesis data:

cd concordium-misc-tools/genesis-creator
cargo run -- generate --config ./examples/genesis9.toml

Option 2 (Get the genesis data - only for internal Concordium members/employees - private repo):

Look up the devnet, stagenet, testnet or mainnet genesis data to start your node. This will allow your node to join the respective network and you can re-use funded (or special authorized) genesis keys/accounts for testing from these networks. existing genesis data

Step 3:

Clone the node repo and initialize the submodule dependencies:

git clone --recurse-submodules [email protected]:Concordium/concordium-node.git

Step 4:

Build the haskell dependencies of the node first. Everytime files in the consensus folder get changed, re-build the haskell dependencies before running the node.

cd concordium-consensus
stack build

Step 5:

Build and run the Rust part of the node and setting up the network.

Running the first validator:

./concordium-node-network-setup.sh 0 15000

Running the second validator and connecting it to the network:

./concordium-node-network-setup.sh 1 15001 --connect-to 0.0.0.0:15000

Running the third validator and connecting it to the network:

./concordium-node-network-setup.sh 2 15002 --connect-to 0.0.0.0:15000  --connect-to 0.0.0.0:15001

...

where the concordium-node-network-setup.sh is the following shell script. Update the [path-on-your-machine] value and the envionmental variables GENESIS_DATA_FILE_PATH and NODE_BAKER_PATH respectively.

#!/usr/bin/env bash

set -euo pipefail
IFS=$'\n\t'

USAGE="Usage: $0 <baker-id> <port>"

if [ "$#" -lt "2" ]; then
	echo "$USAGE"
	exit 1
fi
BAKER_ID=$1
NODE_PORT=$2

shift 2

NODE_CONFIG_DIR=./config_dir/baker-$BAKER_ID
# The genesis.dat file needs to be specified relative to the NODE_CONFIG_DIR
GENESIS_DATA_FILE_PATH=../../../../../concordium-misc-tools/genesis-creator/genesis.dat
NODE_BAKER_PATH=../../../concordium-misc-tools/genesis-creator/bakers/baker-$BAKER_ID-credentials.json

mkdir -p $NODE_CONFIG_DIR
cd ./[path-on-your-machine]/concordium-node/concordium-node
cargo run -- \
    --no-bootstrap true\
    --config-dir $NODE_CONFIG_DIR\
    --data-dir $NODE_CONFIG_DIR\
    --genesis-data-file $GENESIS_DATA_FILE_PATH\
    --listen-address "0.0.0.0"\
    --listen-port $NODE_PORT\
    --validator-credentials-file $NODE_BAKER_PATH\
    --grpc2-enable-grpc-web true \
    --grpc2-listen-addr 0.0.0.0 \
    --grpc2-listen-port 25000 
    $@

Note: If your genesis data specified only one valiator, your running node should immediatly start the consensus algorithm. If your genesis data specified several valiators, your nodes will start the consensus algorithm once enough validators (stake) have joined the network.

Step 6:

Interact with your running node via the its grpc interface.

grpc API repo

grpc API documentation

I recommend to download the graphic UI grpcui to interact with the node.

grpcui -plaintext -import-path ./[path-on-your-machine]/concordium-grpc-api/ -proto ./[path-on-your-machine]/concordium-grpc-api/v2/concordium/service.proto "localhost:25000"

Note: If you want to interact with a remote node that has TLS enabled, remove the -plaintext option in above command.

Step 7 (Optional):

You can also interact with your running node via the command-line-tool concordium-client which can be downloaded here.

e.g.

concordium-client consensus status --grpc-port 25000 --grpc-ip 0.0.0.0

Step 8 (Optional):

You can also interact with your running node via the SDKs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment