You can install CNCLI using either the release binaries or compiling the Rust code. Both installation examples hereby illustrated are instructions for an Ubuntu Linux server and use standard system paths from the Linux File System Hierarchy Standard.
To install CNCLI from a binary release, download the latest release and extract it in the /usr/local/bin/ directory of the block producing node server of your stake pool. Adjust the <latest_release_version> variable in the command to the latest release available:
curl -sLJ https://github.com/AndrewWestberg/cncli/releases/download/v<latest_release_version>/cncli-<latest_release_version>-x86_64-unknown-linux-gnu.tar.gz -o /tmp/cncli-<latest_release_version>-x86_64-unknown-linux-gnu.tar.gztar xzvf /tmp/cncli-<latest_release_version>-x86_64-unknown-linux-gnu.tar.gz -C /usr/local/bin/mkdir -p $HOME/.cargo/binchown -R $USER\: $HOME/.cargotouch $HOME/.profilechown $USER\: $HOME/.profilecurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shsource $HOME/.cargo/envrustup install stablerustup default stablerustup updaterustup component add clippy rustfmtAdjust the <latest_tag_name> variable in the command to the latest tag available:
source $HOME/.cargo/envsudo apt-get update -y && sudo apt-get install -y automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconfgit clone --recurse-submodules https://github.com/AndrewWestberg/cnclicd cncligit checkout <latest_tag_name>cargo install --path . --forcecncli --versionRun the following command to check if cncli is correctly installed and available in your system PATH variable:
command -v cncliIt should return /usr/local/bin/cncli.
Adjust the <latest_tag_name> variable in the command to the latest tag available:
rustup updatecd cncligit fetch --all --prunegit checkout <latest_tag_name>cargo install --path . --forcecncli --versionThis automation section of the guide assumes:
- that you have installed
cardano-nodeandcardano-cliin the standard path/usr/local/bin/ - that you have installed
cncliin the standard path/usr/local/bin/ - that your block producing node port is
3000 - that you sync the
cncli.dbin/root/scripts/ - that you dump the
ledger-state.jsonin/root/scripts/ - that you have placed and are running the helper scripts as
rootfrom/root/scripts/ - that you setup the
cronjobsin thecrontabof userroot - that you have placed your pool
pooltool.jsonfile in/root/scripts/ - that your
cardano-nodeuser home is/home/cardano-node/ - that your
/home/cardano-node/directory contains allcardano-nodedirectories (config,db,keysandsocket) - that your socket is
/home/cardano-node/socket/node.socket
Note: should you need to adjust paths, please do so after downloading the scripts and before configuring the services.
The helper scripts rely on jq, please install it with:
sudo apt-get install -y jqCNCLI can send your tip and block slots to PoolTool. To do this, it requires that you set up a pooltool.json file containing your PoolTool API key and stake pool details. Your PoolTool API key can be found on your pooltool profile page. Here's an example pooltool.json file. Please update with your pool information:
{
"api_key": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"pools": [
{
"name": "BCSH2",
"pool_id": "00beef284975ef87856c1343f6bf50172253177fdebc756524d43fc1",
"host" : "127.0.0.1",
"port": 3000
}
]
}CNCLI sync and sendtip can be easily enabled as systemd services. When enabled as systemd services:
syncwill continuously keep thecncli.dbdatabase synchronized.sendtipwill continuously send your stake pooltipto PoolTool.
To set up systemd:
- Copy the following to
/etc/systemd/system/cncli-sync.service
[Unit]
Description=CNCLI Sync
After=multi-user.target
[Service]
Type=simple
Restart=always
RestartSec=5
LimitNOFILE=131072
ExecStart=/usr/local/bin/cncli sync --host 127.0.0.1 --port 3000 --db /root/scripts/cncli.db
KillSignal=SIGINT
SuccessExitStatus=143
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=cncli-sync
[Install]
WantedBy=multi-user.target
- Copy the following to
/etc/systemd/system/cncli-sendtip.service
[Unit]
Description=CNCLI Sendtip
After=multi-user.target
[Service]
Type=simple
Restart=always
RestartSec=5
LimitNOFILE=131072
ExecStart=/usr/local/bin/cncli sendtip --cardano-node /usr/local/bin/cardano-node --config /root/scripts/pooltool.json
KillSignal=SIGINT
SuccessExitStatus=143
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=cncli-sendtip
[Install]
WantedBy=multi-user.target
- To enable and run the above services, run:
sudo systemctl daemon-reloadsudo systemctl start cncli-sync.servicesudo systemctl start cncli-sendtip.serviceBesides setting up the systemd services, there are a couple of more automation that CNCLI can help you with. We have devised a few scripts that will be invoked daily with crontab and that will take care of:
- calculating the
nextepoch assigned slots (withcncli leaderlog) - send the
previousandcurrentassigned slots to PoolTool (withcncli sendslots). - optionally: query the
ledger-stateand save it to aledger-state.jsonfile.
Although, by default, the cncli-leaderlog.sh script will calculate the next epoch leaderlog, it can also be run manually to also calculate the previous and current epoch slots (adjust the time zone to better suit your location):
bash /root/scripts/cncli-leaderlog.sh previous UTCbash /root/scripts/cncli-leaderlog.sh current UTCbash /root/scripts/cncli-leaderlog.sh next UTCYou can get the scripts from here. Place them under /root/scripts/ of the block producing node server of your pool. If you don't have that directory, create it by running the following command as root:
mkdir /root/scripts/Important: at the very least, remember to change the pool id in the cncli-leaderlog.sh script to match your pool.
To set up the cronjobs, run crontab -e as root and paste the following into it and save.
# calculate slots assignment for the next epoch
15 21 * * * /root/scripts/cncli-fivedays.sh && /root/scripts/cncli-leaderlog.sh
# send previous and current epochs slots to pooltool
15 22 * * * /root/scripts/cncli-fivedays.sh && /root/scripts/cncli-sendslots.sh
Optionally set up a cronjob to dump the ledger-state, every day at 3:15 PM.
# query ledger-state and dump to /root/scripts/ledger-state.json
15 15 * * * /root/scripts/ledger-dump.sh