Create a Local Dijets Network
Introduction#
This quickstart tutorial covers two main methods for creating a local dijets test network.
The two options to launch a local dijets network are:
- Using the Dijets-Up Command Line Interface (recommended method)
- Starting each Dijets node in the network manually (not recommended)
Dijets-Up#
This tutorial assumes that you have minimum go@v1.18 installed on your system.
Follow the official guide on how to install GoLang
Installation Steps#
Dijets-Up repository is hosted at https://github.com/Dijets-Inc/dijets-up
Download the repo into a local folder first:
_10git clone https://github.com/Dijets-Inc/dijets-up
Run the installer script to build the binary.
_10cd dijets-up_10./scripts/build.sh
Successfully built binary is placed inside the ~/bin
directory. If the directory doesn't exist,
it will be auto-created.
Setting ~/bin
in your $PATH#
Run the following command to make sure that ~/bin
is in your $PATH
:
_10export PATH=~/bin:$PATH
To add it to your path permanently, add an export command to your shell initialization script. If
you run bash
, use .bashrc
. And if you run zsh
, use .zshrc
.
Please ensure that an option for DIJETSNODE_EXEC_PATH
has been set properly in all the shells you will be using to interact with Dijets-up CLI.
Alternatively, you can put the following in to your shell's configuration file.
_10DIJETSNODE_EXEC_PATH="${HOME}/go/src/github.com/Dijets-Inc/dijetsnodego/build/dijetsnodego"
Replace execPath with the path to the DijetsNode Binary on your machine.
Unless otherwise specified, file paths given below are relative to the root of this repository.
Dijets-up
requires the use of two separate terminals as follows:
- To run an RPC server that listens for API calls and handles them accordingly.
- To issue the aforementioned API calls from.
Start the Server#
_10dijets-up server \_10--log-level debug \_10--port=":8080" \_10--grpc-gateway-port=":8081"
Please note that the command above will continue running in the background until you explicitly stop it by typing CTRL + C
within the same terminal.
Any other commands to interact with the RPC server will have to be run in a separate terminal.
The RPC server listens to two ports:
port
: the main gRPC port (see gRPC).grpc-gateway-port
: the gRPC gateway port (see gRPC-gateway), which allows for HTTP requests.
If dijets-up
binary is used to issue calls, then the main port will be queried. In this mode, the binary executes compiled
code to issue calls. Alternatively, plain HTTP can be used to issue calls, without the need to use the
binary. In this mode, the grpc-gateway-port
should be queried.
Start a New Dijets Network with Five Nodes (in a Cluster)#
Example commands below show both modes (dijets-up CLI & http request) for starting the server:
A simple HTTP request using cUrl
:
_10curl -X POST -k http://localhost:8081/v1/control/start -d '{"execPath":"'/path/to/dijetsnodego/binary'","numNodes":5,"logLevel":"INFO"}'
Use the following commands to check if all the nodes in the cluster are healthy and gossipping.
A simple HTTP request using cUrl
:
_10curl -X POST -k http://localhost:8081/v1/control/health -d ''
The response to this call is quite large because the request doesn't specify a single node, instead it contains the state of the whole cluster.
Look for the text healthy:true
in the last few lines of the response.
It would say false
if any of the nodes in the cluster aren't healthy.
To Get API Endpoints of All Nodes in the Cluster
A simple HTTP request using cUrl
:
_10curl -X POST -k http://localhost:8081/v1/control/uris -d ''
You should now have a 5-node network with HTTP ports (where API calls should be sent) 80801
, 81072
, 39910
,
60100
, and 34470
.
Manually starting each Node to run a Local Dijets Network#
The below commands assume that:
- You have Golang installed on the system you will be using.
- DijetsNodeGo is installed at
$GOPATH/src/github.com/Dijets-Inc/dijetsnodego/build/dijetsnodego
. - The staking keys for these nodes are in the default folder location of
$GOPATH/src/github.com/Dijets-Inc/dijetsnodego/staking/local/staker1.crt
, - The http ports (where API calls should be sent)
9650
,9652
,9654
,9656
, and9658
are not in use by any other programs.
To start the network:
_10git clone https://github.com/Dijets-Inc/dijetsnodego
_10cd $GOPATH/src/github.com/Dijets-Inc/dijetsnodego
_10./scripts/build.sh
_10./build/dijetsnodego --public-ip=127.0.0.1 --http-port=9650 --staking-port=9651 --db-dir=db/dijetscub1 --network-id=local --staking-tls-cert-file=$(pwd)/staking/local/staker1.crt --staking-tls-key-file=$(pwd)/staking/local/staker1.key
_10./build/dijetsnodego --public-ip=127.0.0.1 --http-port=9652 --staking-port=9653 --db-dir=db/dijetscub2 --network-id=local --bootstrap-ips=127.0.0.1:9651 --bootstrap-ids=DijetsNode-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg --staking-tls-cert-file=$(pwd)/staking/local/staker2.crt --staking-tls-key-file=$(pwd)/staking/local/staker2.key
_10./build/dijetsnodego --public-ip=127.0.0.1 --http-port=9654 --staking-port=9655 --db-dir=db/dijetscub3 --network-id=local --bootstrap-ips=127.0.0.1:9651 --bootstrap-ids=DijetsNode-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg --staking-tls-cert-file=$(pwd)/staking/local/staker3.crt --staking-tls-key-file=$(pwd)/staking/local/staker3.key
_10./build/dijetsnodego --public-ip=127.0.0.1 --http-port=9656 --staking-port=9657 --db-dir=db/dijetscub4 --network-id=local --bootstrap-ips=127.0.0.1:9651 --bootstrap-ids=DijetsNode-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg --staking-tls-cert-file=$(pwd)/staking/local/staker4.crt --staking-tls-key-file=$(pwd)/staking/local/staker4.key
_10./build/dijetsnodego --public-ip=127.0.0.1 --http-port=9658 --staking-port=9659 --db-dir=db/dijetscub5 --network-id=local --bootstrap-ips=127.0.0.1:9651 --bootstrap-ids=DijetsNode-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg --staking-tls-cert-file=$(pwd)/staking/local/staker5.crt --staking-tls-key-file=$(pwd)/staking/local/staker5.key
Next Step#
Check out Fund a Local Test Network.