Creating a local cluster
This tutorial has been updated to work with cardano-node v.8.0.0.
In certain situations, it may be necessary to set up a local cluster. To simplify this process, there are user-friendly tools that require minimal effort to deploy. However, to help with a deeper comprehension of the automated tools and the underlying processes involved, this tutorial will begin by setting up the cluster manually. This hands-on approach will provide valuable insights into the steps required.
The following example will initiate a cluster during the Byron era and subsequently upgrade it progressively until it reaches the Babbage era. This step-by-step process will demonstrate the evolution and advancements of the cluster in its transition through different eras.
Configuring the network and nodes
Requirements:
A Linux or macOS machine, see the Requirements for details
cardano-node
andcardano-cli
in your $PATH
Note: This section of the course will minimize the use of scripts. The intention is to make the process as transparent and clear as possible.
The cardano-cli genesis create-cardano
command will be used to simplify the process. It will create most of the necessary files for the local cluster. You only need to supply the following template files as a starting point:
Configuration
Byron genesis template
Shelley genesis template
Alonzo genesis template
Conway genesis template
1. The configuration files
Cardano World testnet templates is the source for the template files. These are the templates that IOG uses to deploy a new testnet.
Create a directory for the project:
Download the template files and save them in the template folder you just created:
The system will start in the Byron era and will have only two block-producing nodes. You will add two stake pools later when you transition to the Shelley era. Make a directory for each of the nodes and a configuration folder for your configuration files:
The nodes must connect to each other. Each of the nodes requires a topology file that tells it which nodes to connect to.
The node bft0 will run on port 3000, and node bft1 – on port 3001. For now, use the classic topology (not P2P).
Create the topology file for bft0 with:
And for bft1 with:
2. The genesis files
Use the byron.json
template file together with cardano-cli
to generate a byron-genesis.json
file. The template looks like this:
Note that this template uses 200 millisecond slots in the Byron era. Mainnet slots lasted 20 seconds during the Byron era and one second during Shelley and later eras.
Slots were 20 times longer in the Byron era because there was a block in every slot. This was necessary to ensure that each block had enough time to travel the world and that everybody received the block before forging the next block. In Shelley and later eras, slots are shorter but not all slots have a block. On mainnet, only 5% of the slots have a block; this is the active slot coefficient. This selection of parameters allows for Byron and Shelley epochs to have approximately the same number of blocks.
The local cluster uses two-second slots in Byron and 0.1-second slots in the following eras. The cardano-cli genesis create-cardano
command automatically generates configuration files with this 20:1 ratio.
The rest of the parameters will match the mainnet ones. For detailed information about the parameters, see:
You can now make a few changes to the shelley.json
template. Since there are only two nodes, bring updateQuorum
down to 2, reduce the epoch length to 9000, the security parameter k to 45, and the Shelley era slots will last 1/10th of a second. To help the cluster match the progression of mainnet protocol versions, set major (protocol version) to 2. On mainnet, Shelley era is protocol version 2.0:
A few changes are also needed to the config.json
template. For now, disable P2P topology and disable the EnableDevelopment
options so you can update your cluster using proper update proposals. Initially, state that your nodes are ready to move to protocol version 1.0.0 (PBFT). Logs will come very fast, so keep the minSeverity
in info:
Also, change a couple of Byron parameters for your local cluster. Change minThd
to "1000000000000000"
so that update proposals need positive votes from both genesis keys to be approved. And change "updateImplicit"
to 450, so that update proposals expire if they have not accumulated enough votes after 450 slots:
Now you can use the magic of cardano-cli genesis create-cardano
:
Move genesis files to the configuration directory to keep things in order:
And move your genesis delegate keys to their corresponding delegate nodes:
To simplify the process, create bash scripts to start your nodes. Bft0 will run on port 3000:
And bft1 on port 3001:
Now give your scripts executable permission:
Open a new terminal for each of the nodes. Go to the corresponding bft folder, and run the script from there:
Repeat for bft1. The nodes will idle until the start time is reached, and then they will start producing blocks.
Now you can set the environment variable CARDANO_NODE_SOCKET_PATH
:
Next, query the tip of the chain to make sure everything is working as expected:
Great, you have a network on the Byron era running locally!
Last updated