CoinCashew
English
English
  • Home
  • About Us
  • Donations
  • Contributing
    • Contributor Covenant Code of Conduct
    • Style Guide
  • Disclaimer
  • Wallets
    • Guide: Crypto Wallet Tips 101 - Do's and Don'ts
      • Review: Metal Bitcoin Seed Storage by jlopp
  • Coins
    • Ethereum: ETH
      • 🛡️EthPillar: one-liner setup tool and node management TUI
      • 🥩Guide | How to setup a validator for Ethereum staking on mainnet
        • Overview - Manual Installation
        • PART I - INSTALLATION
          • Step 1: Prerequisites
          • Step 2: Configuring Node
          • Step 3: Installing execution client
            • Nethermind
            • Besu
            • Geth
            • Erigon
            • Reth
          • Step 4: Installing consensus client
            • Lighthouse
            • Lodestar
            • Teku
            • Nimbus
            • Prysm
          • Step 5: Installing Validator
            • Setting up Validator Keys
            • Installing Validator
              • Lighthouse
              • Lodestar
              • Teku
              • Nimbus
              • Prysm
            • Next Steps
          • Monitoring your validator with Grafana and Prometheus
          • Mobile App Node Monitoring by beaconcha.in
          • Monitoring with Uptime Check by Google Cloud
        • PART II - MAINTENANCE
          • Updating Execution Client
          • Updating Consensus Client
          • Backups Checklist: Critical Staking Node Data
          • Uninstalling Staking Node
          • Finding the longest attestation slot gap
          • Checking my eth validator's sync committee duties
          • Checklist | Confirming a healthy functional ETH staking node
        • PART III - TIPS
          • Voluntary Exiting a Validator
          • Verifying Your Mnemonic Phrase
          • Adding a New Validator to an Existing Setup with Existing Seed Words
          • Switching / Migrating Consensus Client
          • 🛡️Switching / Migrating Execution Client
          • ⚡Using Node as RPC URL endpoint
          • Using All Available LVM Disk Space
          • Reducing Network Bandwidth Usage
          • How to re-sync using checkpoint sync
          • Important Directory Locations
          • Improving Validator Attestation Effectiveness
          • EIP2333 Key Generator by iancoleman.io
          • 😁Geth - Enabling path-based state storage
          • Disk Usage by Execution / Consensus Client
          • Dealing with Storage Issues on the Execution Client
        • Join the Community
        • Credits
        • See Also
        • Changelog
      • 🌠Guide | How to setup a validator for Ethereum staking on testnet HOODI
        • Overview - Manual Installation
        • Step 1: Prerequisites
        • Step 2: Configuring Node
        • Step 3: Installing execution client
          • Nethermind
          • Besu
          • Geth
          • Erigon
          • Reth
        • Step 4: Installing consensus client
          • Lighthouse
          • Lodestar
          • Teku
          • Nimbus
          • Prysm
        • Step 5: Installing Validator
          • Setting up Validator Keys
          • Installing Validator
            • Lighthouse
            • Lodestar
            • Teku
            • Nimbus
            • Prysm
          • Next Steps
        • Maintenance
          • Updating Execution Client
          • Updating Consensus Client
          • Backups Checklist: Critical Staking Node Data
          • Uninstalling Staking Node
      • ⛓️Guide | How to setup a validator for Ethereum staking on testnet HOLESKY
        • Overview - Manual Installation
        • Step 1: Prerequisites
        • Step 2: Configuring Node
        • Step 3: Installing execution client
          • Nethermind
          • Besu
          • Geth
          • Erigon
          • Reth
        • Step 4: Installing consensus client
          • Lighthouse
          • Lodestar
          • Teku
          • Nimbus
          • Prysm
        • Step 5: Installing Validator
          • Setting up Validator Keys
          • Installing Validator
            • Lighthouse
            • Lodestar
            • Teku
            • Nimbus
            • Prysm
          • Next Steps
        • Maintenance
          • Updating Execution Client
          • Updating Consensus Client
          • Backups Checklist: Critical Staking Node Data
          • Uninstalling Staking Node
      • 💰Guide | MEV-boost for Ethereum Staking
        • MEV Relay List
      • 🔎Guide | Recover Ethereum Validator Mnemonic Seed
      • 🦉Update Withdrawal Keys for Ethereum Validator (BLS to Execution Change or 0x00 to 0x01) with ETHDO
      • 📜Archived Guides
        • Guide Version 1 | How to setup a validator for Ethereum staking on MAINNET
          • PART I - INSTALLATION
            • Step 1: Prerequisites
            • Step 2: Configuring Node
            • Step 3: Setting up Validator Keys
            • Step 4: Installing execution client
            • Step 5: Installing consensus client
            • Monitoring your validator with Grafana and Prometheus
            • Mobile App Node Monitoring by beaconcha.in
            • Security Best Practices for your ETH staking validator node
            • Synchronizing time with Chrony
            • Monitoring with Uptime Check by Google Cloud
          • PART II - MAINTENANCE
            • Updating your consensus client
            • Updating your execution client
            • Uninstalling V1 Staking Node
            • Finding the longest attestation slot gap
            • Checking my eth validator's sync committee duties
            • Pruning the execution client to free up disk space
            • Checklist | Confirming a healthy functional ETH staking node
          • PART III - TIPS
            • 🛡️Switching / Migrating Execution Client
            • Voluntary Exiting a Validator
            • Verifying Your Mnemonic Phrase
            • Adding a New Validator to an Existing Setup with Existing Seed Words
            • Switching / Migrating Consensus Client
            • Using All Available LVM Disk Space
            • Reducing Network Bandwidth Usage
            • How to re-sync using checkpoint sync
            • Important Directory Locations
            • Hosting Execution client on a Different Machine
            • Adding or Changing Graffiti flag
            • Improving Validator Attestation Effectiveness
            • EIP2333 Key Generator by iancoleman.io
            • Disk Usage by Execution / Consensus Client
            • Dealing with Storage Issues on the Execution Client
          • Join the Community
          • Credits
          • See Also
          • Changelog
        • Guide Version 1 | How to setup a validator for Ethereum staking on testnet GOERLI
          • Step 1: Prerequisites
          • Step 2: Configuring Node
          • Step 3: Setting up Validator Keys
          • Step 4: Installing execution client
          • Step 5: Installing consensus client
        • Guide Version 2 | How to setup a validator for Ethereum staking on testnet GOERLI
          • Step 1: Prerequisites
          • Step 2: Configuring Node
          • Step 3: Installing execution client
            • Nethermind
            • Besu
            • Geth
            • Erigon
          • Step 4: Installing consensus client
            • Lighthouse
            • Lodestar
            • Teku
            • Nimbus
            • Prysm
          • Step 5: Installing Validator
            • Setting up Validator Keys
            • Installing Validator
              • Lighthouse
              • Lodestar
              • Teku
              • Nimbus
              • Prysm
            • Next Steps
          • Maintenance
            • Updating Execution Client
            • Updating Consensus Client
            • Backups Checklist: Critical Staking Node Data
            • Uninstalling Staking Node
        • Guide | Ethereum Staking on Zhejiang Testnet
        • Guide | Besu + Lodestar | Most Viable Diverse Client | Staking Ethereum on Kiln testnet
        • Guide | How to setup a validator for Ethereum staking on Pithos testnet in 10 minutes or less
        • Ethereum Merge Upgrade Checklist for Home Stakers and Validators
        • Guide | Operation Client Diversity: Migrate Prysm to Teku
      • Guide: How to buy ETH
    • Cardano: ADA
      • Guide: How to Set Up a Cardano Stake Pool
        • Benefits of Operating a Cardano Stake Pool
        • PART I - INSTALLATION
          • Prerequisites
          • Hardening an Ubuntu Server
          • Setting Up chrony
          • Installing the Glasgow Haskell Compiler and Cabal
          • Compiling Cardano Node
        • PART II - CONFIGURATION
          • Downloading Configuration Files
          • Configuring Topology
          • Configuring an Air-gapped, Offline Computer
          • Creating Startup Scripts and Services
        • PART III - OPERATION
          • Starting the Nodes
          • Accessing Built-in Help
          • Generating Keys for the Block-producing Node
          • Setting Up Payment and Stake Keys
          • Registering Your Stake Address
          • Registering Your Stake Pool
          • Verifying Stake Pool Operation
          • Setting Up Dashboards
          • Configuring Slot Leader Calculations
          • Securing Your Stake Pool Using a Hardware Wallet
          • Setting up a Mithril Signer
        • PART IV - ADMINISTRATION & MAINTENANCE
          • Checking Stake Pool Rewards
          • Claiming Stake Pool Rewards
          • Delegating to a Stake Pool
          • Delegating to a Representative
          • Issuing a New Operational Certificate
          • Updating Stake Pool Information
          • Upgrading a Node
          • Retiring Your Stake Pool
          • Auditing Your nodes configuration
          • KES Key Rotation / Operational Certificate Companion Script
        • PART V - TIPS
          • Submitting a Simple Transaction
          • Transferring Files Using SSH
          • Updating Configuration Files
          • Implementing Peer Sharing
          • Uploading Pool Metadata to GitHub Pages
          • Obtaining a PoolTool API Key
          • Configuring Glasgow Haskell Compiler Runtime System Options
          • Reducing Missed Slot Leader Checks and Improving Cardano Node Performance
          • Increasing Swap File Size
          • Setting Up an External Passive Relay Node
          • Setting Up WireGuard
          • Monitoring Node Security Using OSSEC Server and Slack
          • Resetting an Installation
          • Fixing a Corrupt Blockchain
          • Verifying an ITN Stake Pool
          • Fixing the Mnemonic Staking Balance Bug
        • Appendix A - Best Practices Checklist
        • Appendix B - Cardano Resource Index
        • Discord Chat Channel
        • See Also
        • Credits
      • Guide: How to buy ADA
      • Guide: How to stake ADA
    • Monero: XMR
      • Guide | How to run your own Monero node
      • Guide: How to mine Monero
      • Create a XMR paper wallet
      • External Reading Material
        • Movie: Monero Means Money
        • Guide: Zero to Monero
        • Book: Mastering Monero
Powered by GitBook
On this page
Edit on GitHub
  1. Coins
  2. Cardano: ADA
  3. Guide: How to Set Up a Cardano Stake Pool
  4. PART III - OPERATION

Configuring Slot Leader Calculations

PreviousSetting Up DashboardsNextSecuring Your Stake Pool Using a Hardware Wallet

Last updated 6 months ago

Hot tip: You can calculate your slot leader schedule, which tells you when it's your stake pools turn to mint a block. This can help you know what time is best to schedule maintenance on your stake pool. It can also help verify your pool is minting blocks correctly when it is your pool's turn. This is to be setup and run on the block producer node.

Since version 1.34, it is possible to check the slot leadership schedule for the current and next epoch using cardano-cli.

Next epoch's leadership schedule becomes available 1.5 days (36 hours) before the end of the current epoch.


Next epoch's leadership schedule is obtained with the following:

cardano-cli conway query leadership-schedule \
--mainnet \
--genesis $NODE_HOME/shelley-genesis.json \
--stake-pool-id $(cat $NODE_HOME/stakepoolid.txt) \
--vrf-signing-key-file $NODE_HOME/vrf.skey \
--next

Current epoch's leadership schedule is obtained with the following:

cardano-cli conway query leadership-schedule \
--mainnet \
--genesis $NODE_HOME/shelley-genesis.json \
--stake-pool-id $(cat $NODE_HOME/stakepoolid.txt) \
--vrf-signing-key-file $NODE_HOME/vrf.skey \
--current

Example leadership schedule output:

SlotNo                          UTC Time
-------------------------------------------------------------
     4073                   2021-12-29 17:26:54.998001755 UTC
     4126                   2021-12-29 17:27:00.298001755 UTC
     4206                   2021-12-29 17:27:08.298001755 UTC
     4256                   2021-12-29 17:27:13.298001755 UTC
     4309                   2021-12-29 17:27:18.598001755 UTC
     4376                   2021-12-29 17:27:25.298001755 UTC
     4423                   2021-12-29 17:27:29.998001755 UTC
     4433                   2021-12-29 17:27:30.998001755 UTC

The automation of this process will work with the following method, as said, next epoch blocks can be checked 1.5 days before the start of the next epoch or at the 75% of the current epoch's completion. What the script will do, is to calculate the correct day and hour to run the command, then wait until it is possible to do that and once the selected time comes, run the check listed below. Once finished, it will redirect the output into a log file that can be analyzed.

Keep in mind that running the leadership-schedule command, listed below and used by the script, with the cardano-node at the same time, will use approximately 17GB of RAM at the time of writing this guide (April 2022).

The possible solutions to avoid a node crash are:

  • Increase the RAM of the node

Create the leaderScheduleCheck.sh script file in the block producer (script can also be run on a relay node but vrf.skey needs to be exported there) and paste the following code inside of it:

#!/bin/bash

# cardano node directory
DIRECTORY=

if [[ ! -d "$DIRECTORY/logs" ]]; then mkdir $DIRECTORY/logs; fi 

# create a pid, this way you can ps aux | grep leaderScheduleCheck.sh to see if script is running     
echo $$ > "$DIRECTORY/logs/leaderScheduleCheck.pid"; 

# Set your own stake pool ID
STAKE_POOL_ID=""

TESTNET="testnet"
MAINNET="mainnet"

# Set the network magic value as needed for the testnet environment that you want to use
# For details on available testnet environments, see https://book.world.dev.cardano.org/environments.html
MAGICNUMBER="1"

# Edit variable with $TESTNET for Testnet and $MAINNET for Mainnet
network=$TESTNET

# check for vrf.skey presence
if [[ ! -f "$DIRECTORY/vrf.skey" ]]; then echo "vrf.skey not found"; exit 127; fi

CCLI=$(which cardano-cli)
if [[ -z $CCLI ]]; then echo "cardano-cli command cannot be found, exiting..."; exit 127; fi

JQ=$(which jq)
if [[ -z $JQ ]]; then echo "jq command cannot be found, exiting..."; exit 127; fi

read -ra BYRON_GENESIS <<< "$(jq -r '[ .startTime, .protocolConsts.k, .blockVersionData.slotDuration ] |@tsv' < $DIRECTORY/$network-byron-genesis.json)"
if [[ -z $BYRON_GENESIS ]]; then echo "BYRON GENESIS config file not loaded correctly"; exit 127; fi

network_magic=""
if [ $network = $TESTNET ]; then
    network_magic="--testnet-magic $MAGICNUMBER"
elif [ $network = $MAINNET ]; then
    network_magic="--mainnet"
else
    echo "Incorrect network selected, please use $TESTNET or $MAINNET network type"; exit 1
fi


# Check that node is synced
function isSynced(){
    isSynced=false

    sync_progress=$($CCLI query tip $network_magic | jq -r ".syncProgress")
    if [[ $sync_progress == "100.00" ]]; then
        isSynced=true
    fi

    echo $isSynced
}

# Get current epoch
function getCurrentEpoch(){
    echo $($CCLI query tip $network_magic | jq -r ".epoch")
}

# Get epoch start time based on current one
function getEpochStartTime(){
    byron_genesis_start_time=${BYRON_GENESIS[0]}
    byron_k=${BYRON_GENESIS[1]}
    byron_epoch_length=$(( 10 * byron_k ))
    byron_slot_length=${BYRON_GENESIS[2]}

    echo $(( $byron_genesis_start_time + (($(getCurrentEpoch) * $byron_epoch_length * $byron_slot_length) / 1000) ))
}

# Get epoch end time based on the current one
function getEpochEndTime(){
    #calculate currentEpoch Start time + 5 days of epoch duration - 10 minutes(600s) to not overlap with next epoch
    echo $(( $(getEpochStartTime)+(5*86400)-(600) ))
}

# Get current timestamp
function getCurrentTime(){
    echo $(printf '%(%s)T\n' -1)
}

# Convert timestamps to UTC time
function timestampToUTC(){
    timestamp=$1
    echo $(date +"%D %T" -ud @$timestamp)
}

# Find the correct time to run the leaderslot check command
function getLeaderslotCheckTime(){
    epochStartTime=$(getEpochStartTime)
    epochEndTime=$(getEpochEndTime)

    # epoch completion percent to check for --next epoch leaderslots
    percentage=75
    checkTimestamp=$(( $epochStartTime+($percentage*($epochEndTime-$epochStartTime)/100) ))

    echo $checkTimestamp
}

# Function to make the script sleep until check need to be executed
function sleepUntil(){
    sleepSeconds=$1
    if [[ $sleepSeconds -gt 0 ]]; then
        echo "Script is going to sleep for: $sleepSeconds seconds"
        sleep $sleepSeconds
    fi
}

# Check leaderschedule of next epoch
function checkLeadershipSchedule(){
    next_epoch=$(( $(getCurrentEpoch)+1 ))
    currentTime=$(getCurrentTime)

    echo "Check is running at: $(timestampToUTC $currentTime) for epoch: $next_epoch"
    $CCLI query leadership-schedule $network_magic --genesis "$DIRECTORY/$network-shelley-genesis.json" --stake-pool-id $STAKE_POOL_ID --vrf-signing-key-file "$DIRECTORY/vrf.skey" --next > "$DIRECTORY/logs/leaderSchedule_$next_epoch.txt"
}

if [ isSynced ];then
    echo "Current epoch: $(getCurrentEpoch)"

    epochStartTimestamp=$(getEpochStartTime)
    echo "Epoch start time: $(timestampToUTC $epochStartTimestamp)"

    epochEndTimestamp=$(getEpochEndTime)
    echo "Epoch end time: $(timestampToUTC $epochEndTimestamp)"

    currentTime=$(getCurrentTime)
    echo "Current cron execution time: $(timestampToUTC $currentTime)"

    timestampCheckLeaders=$(getLeaderslotCheckTime)
    echo "Next check time: $(timestampToUTC $timestampCheckLeaders)"

    timeDifference=$(( $timestampCheckLeaders-$currentTime ))
    if [ -f "$DIRECTORY/logs/leaderSchedule_$(( $(getCurrentEpoch)+1 )).txt" ]; then
                echo "Check already done, check logs for results"; exit 1
    elif [[ $timeDifference -gt 86400 ]]; then
                echo "Too early to run the script, wait for next cron scheduled job"; exit 1
    elif [[ $timeDifference -gt 0 ]] && [[ $timeDifference -le 86400 ]]; then
        sleepUntil $timeDifference
        echo "Check is starting on $(timestampToUTC $(getCurrentTime))"
            checkLeadershipSchedule
        echo "Script ended, schedule logged inside file: leaderSchedule_$(( $(getCurrentEpoch)+1 )).txt"
    elif [[ $timeDifference -lt 0 ]] && [ ! -f "$DIRECTORY/logs/leaderSchedule_$(( $(getCurrentEpoch)+1 )).txt" ]; then
                echo "Check is starting on $(timestampToUTC $(getCurrentTime))"
                checkLeadershipSchedule
                echo "Script ended, schedule logged inside file: leaderSchedule_$(( $(getCurrentEpoch)+1 )).txt"
    else
        echo "There were problems on running the script, check that everything is working fine"; exit 1
    fi
else
    echo "Node not fully synced."; exit 1
fi

Set the following variables with your data:

# cardano node directory, directory where all files needed for running a cardano-node are located
DIRECTORY=

# Set your own stake pool ID
STAKE_POOL_ID=""

# Set variable with $TESTNET for Testnet and $MAINNET for Mainnet
network=

Add execution permissions and test that the script is running without errors:

chmod +x leaderScheduleCheck.sh
./leaderScheduleCheck.sh

If everything is working correctly, an output as the follow will be presented:

Current epoch: 199 Epoch start time: 04/14/22 20:20:16 Epoch end time: 04/19/22 20:10:16 Current cron execution time: 04/18/22 15:37:51 Next check time: 04/18/22 14:12:46 [...] Cutted output cause it can vary based on time when the script is ran

Configure Cronjob to make the script run automatically:

To configure the job at the start of an epoch, keep in mind the following information:

  • Epoch in MAINNET starts at 21:45 UTC

Find the time when the cronjob should start:

Cronjobs run based on local timezone, not on UTC hours. \

Find timezone:

timedatectl | grep "Time zone"

Once you found your timezone, you need to understand when run the job (It isn't mandatory to run it at epoch's starting hour). Here is an example with a UTC+2 timezone for Mainnet:

Epoch starting hour UTC: 21:45 Epoch starting hour for requested timezone: 23:45 Cronjob will be set to run at 23:45

Add cronjob and edit parameters based on your needs, PATH, NODE_HOME, NODE_CONFIG, CARDANO_NODE_SOCKET_PATH, MM, HH, path_to_script and desired_log_folder:

cat > $NODE_HOME/crontab-fragment.txt << EOF
# disable MTA use
MAILTO=""
# linux path, needed because cron doesn't know where to find cardano-cli
PATH=
# folder with cardano-node files
NODE_HOME=
# testnet or mainnet
NODE_CONFIG=
# path to the socket of cardano node, should be under db/ folder under NODE_HOME
CARDANO_NODE_SOCKET_PATH=

MM HH * * * path_to_script/leaderScheduleCheck.sh > desired_log_folder/leaderSchedule_logs.txt 2>&1
EOF
crontab -l | cat - ${NODE_HOME}/crontab-fragment.txt > ${NODE_HOME}/crontab.txt && crontab ${NODE_HOME}/crontab.txt
rm ${NODE_HOME}/crontab-fragment.txt

Once the cronjob is set, the script will be run every day and it will check if in the next 24H, it will be the correct time to run the command and see if there are scheduled blocks in the next epoch. For every epoch, there will be a file called leaderSchedule_epoch.txt

A community-based cardano-node CLI tool. It's a collection of utilities to enhance and extend beyond those available with cardano-cli.

###
### On blockproducer
###
RELEASETAG=$(curl -s https://api.github.com/repos/cardano-community/cncli/releases/latest | jq -r .tag_name)
VERSION=$(echo ${RELEASETAG} | cut -c 2-)
echo "Installing release ${RELEASETAG}"
curl -sLJ https://github.com/cardano-community/cncli/releases/download/${RELEASETAG}/cncli-${VERSION}-ubuntu22-x86_64-unknown-linux-gnu.tar.gz -o /tmp/cncli-${VERSION}-ubuntu22-x86_64-unknown-linux-gnu.tar.gz
sudo tar xzvf /tmp/cncli-${VERSION}-ubuntu22-x86_64-unknown-linux-gnu.tar.gz -C /usr/local/bin/

Confirming That CNCLI is Properly Installed

Run the following command to check if cncli is correctly installed and available in your system PATH variable:

command -v cncli

It should return /usr/local/bin/cncli

This command calculates a stake pool's expected slot list.

  • prev and current logs are available as long as you have a synchronized database.

  • next logs are only available 1.5 days (36 hours) before the end of the epoch.

  • You need to use poolStakeMark and activeStakeMark for next, poolStakeSet and activeStakeSet for current, poolStakeGo and activeStakeGo for prev.

Example usage with the stake-snapshot approach for next epoch:

Run this command 1.5 days (36 hours) before the next epoch begins.

/usr/local/bin/cncli sync --host 127.0.0.1 --port 6000 --no-service

MYPOOLID=$(cat $NODE_HOME/stakepoolid.txt)
echo "LeaderLog - POOLID $MYPOOLID"

SNAPSHOT=$(/usr/local/bin/cardano-cli conway query stake-snapshot --stake-pool-id $MYPOOLID --mainnet)
POOL_STAKE=$(echo "$SNAPSHOT" | jq -r ".pools.$MYPOOLID.stakeMark")
ACTIVE_STAKE=$(echo "$SNAPSHOT" | jq -r ".total.stakeMark")
MYPOOL=`/usr/local/bin/cncli leaderlog --consensus praos --pool-id $MYPOOLID --pool-vrf-skey ${NODE_HOME}/vrf.skey --byron-genesis ${NODE_HOME}/byron-genesis.json --shelley-genesis ${NODE_HOME}/shelley-genesis.json --pool-stake $POOL_STAKE --active-stake $ACTIVE_STAKE --ledger-set next`
echo $MYPOOL | jq .

EPOCH=`echo $MYPOOL | jq .epoch`
echo "\`Epoch $EPOCH\` 🧙🔮:"

SLOTS=`echo $MYPOOL | jq .epochSlots`
IDEAL=`echo $MYPOOL | jq .epochSlotsIdeal`
PERFORMANCE=`echo $MYPOOL | jq .maxPerformance`

echo "\`MYPOOL - $SLOTS \`🎰\`,  $PERFORMANCE% \`🍀max, \`$IDEAL\` 🧱ideal"

Example usage with the stake-snapshot approach for current epoch:

/usr/local/bin/cncli sync --host 127.0.0.1 --port 6000 --no-service

MYPOOLID=$(cat $NODE_HOME/stakepoolid.txt)
echo "LeaderLog - POOLID $MYPOOLID"

SNAPSHOT=$(/usr/local/bin/cardano-cli conway query stake-snapshot --stake-pool-id $MYPOOLID --mainnet)
POOL_STAKE=$(echo "$SNAPSHOT" | jq -r ".pools.$MYPOOLID.stakeSet")
ACTIVE_STAKE=$(echo "$SNAPSHOT" | jq -r ".total.stakeSet")
MYPOOL=`/usr/local/bin/cncli leaderlog --consensus praos --pool-id $MYPOOLID --pool-vrf-skey ${NODE_HOME}/vrf.skey --byron-genesis ${NODE_HOME}/byron-genesis.json --shelley-genesis ${NODE_HOME}/shelley-genesis.json --pool-stake $POOL_STAKE --active-stake $ACTIVE_STAKE --ledger-set current`
echo $MYPOOL | jq .

EPOCH=`echo $MYPOOL | jq .epoch`
echo "\`Epoch $EPOCH\` 🧙🔮:"

SLOTS=`echo $MYPOOL | jq .epochSlots`
IDEAL=`echo $MYPOOL | jq .epochSlotsIdeal`
PERFORMANCE=`echo $MYPOOL | jq .maxPerformance`

echo "\`MYPOOL - $SLOTS \`🎰\`,  $PERFORMANCE% \`🍀max, \`$IDEAL\` 🧱ideal"

Example usage with the stake-snapshot approach for previous epoch:

/usr/local/bin/cncli sync --host 127.0.0.1 --port 6000 --no-service

MYPOOLID=$(cat $NODE_HOME/stakepoolid.txt)
echo "LeaderLog - POOLID $MYPOOLID"

SNAPSHOT=$(/usr/local/bin/cardano-cli conway query stake-snapshot --stake-pool-id $MYPOOLID --mainnet)
POOL_STAKE=$(echo "$SNAPSHOT" | jq -r ".pools.$MYPOOLID.stakeGo")
ACTIVE_STAKE=$(echo "$SNAPSHOT" | jq -r ".total.stakeGo"))
MYPOOL=`/usr/local/bin/cncli leaderlog --consensus praos --pool-id $MYPOOLID --pool-vrf-skey ${NODE_HOME}/vrf.skey --byron-genesis ${NODE_HOME}/byron-genesis.json --shelley-genesis ${NODE_HOME}/shelley-genesis.json --pool-stake $POOL_STAKE --active-stake $ACTIVE_STAKE --ledger-set prev`
echo $MYPOOL | jq .

EPOCH=`echo $MYPOOL | jq .epoch`
echo "\`Epoch $EPOCH\` 🧙🔮:"

SLOTS=`echo $MYPOOL | jq .epochSlots`
IDEAL=`echo $MYPOOL | jq .epochSlotsIdeal`
PERFORMANCE=`echo $MYPOOL | jq .maxPerformance`

echo "\`MYPOOL - $SLOTS \`🎰\`,  $PERFORMANCE% \`🍀max, \`$IDEAL\` 🧱ideal"

Integrating with PoolTool

  • Current block height

  • The number of slots in which your stake pool is currently elected to mint blocks

To send data to PoolTool using CNCLI utilities without using the cncli.sh script, create a configuration file containing your PoolTool API key and stake pool details.

To create a configuration file, update values in the following example with your pool information. To follow the example, save the configuration file at $NODE_HOME/scripts/pooltool.json

cat > ${NODE_HOME}/scripts/pooltool.json << EOF
{
    "api_key": "<UPDATE WITH YOUR API KEY FROM POOLTOOL PROFILE PAGE>",
    "pools": [
        {
            "name": "<UPDATE TO MY POOL TICKER>",
            "pool_id": "$(cat ${NODE_HOME}/stakepoolid.txt)",
            "host" : "127.0.0.1",
            "port": 6000
        }
    ]
}
EOF

Creating systemd Services

CNCLI sync and sendtip can be easily enabled as systemd services. When enabled as systemd services:

  • sync will continuously keep the cncli.db database synchronized.

  • sendtip will continuously send your stake pool tip to PoolTool.

To set up systemd:

  • Create the following and move to/etc/systemd/system/cncli-sync.service

cat > ${NODE_HOME}/cncli-sync.service << EOF
[Unit]
Description=CNCLI Sync
After=multi-user.target

[Service]
User=$USER
Type=simple
Restart=always
RestartSec=5
LimitNOFILE=131072
ExecStart=/usr/local/bin/cncli sync --host 127.0.0.1 --port 6000 --db ${NODE_HOME}/scripts/cncli.db
KillSignal=SIGINT
SuccessExitStatus=143
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=cncli-sync

[Install]
WantedBy=multi-user.target
EOF
sudo mv ${NODE_HOME}/cncli-sync.service /etc/systemd/system/cncli-sync.service
  • Create the following and move to /etc/systemd/system/cncli-sendtip.service

cat > ${NODE_HOME}/cncli-sendtip.service << EOF
[Unit]
Description=CNCLI Sendtip
After=multi-user.target

[Service]
User=$USER
Type=simple
Restart=always
RestartSec=5
LimitNOFILE=131072
ExecStart=/usr/local/bin/cncli sendtip --cardano-node /usr/local/bin/cardano-node --config ${NODE_HOME}/scripts/pooltool.json
KillSignal=SIGINT
SuccessExitStatus=143
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=cncli-sendtip

[Install]
WantedBy=multi-user.target
EOF
sudo mv ${NODE_HOME}/cncli-sendtip.service /etc/systemd/system/cncli-sendtip.service
  • To enable and run the above services, run:

sudo systemctl daemon-reload
sudo systemctl start cncli-sync.service
sudo systemctl start cncli-sendtip.service
RELEASETAG=$(curl -s https://api.github.com/repos/cardano-community/cncli/releases/latest | jq -r .tag_name)
VERSION=$(echo ${RELEASETAG} | cut -c 2-)
echo "Installing release ${RELEASETAG}"
curl -sLJ https://github.com/cardano-community/cncli/releases/download/${RELEASETAG}/cncli-${VERSION}-x86_64-unknown-linux-gnu.tar.gz -o /tmp/cncli-${VERSION}-x86_64-unknown-linux-gnu.tar.gz
sudo tar xzvf /tmp/cncli-${VERSION}-x86_64-unknown-linux-gnu.tar.gz -C /usr/local/bin/

Confirming CNCLI Upgrades

cncli -V

It should return the updated version number.

Check if you have python installed.

python3 --version

Otherwise, install python3.

sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install -y python3.9

Check if you have pip installed.

pip3 --version

Install pip3 if needed.

sudo apt-get install -y python3-pip

Install pytz which handles timezones.

pip3 install pytz

Verify python and pip are setup correctly before continuing.

python3 --version
pip3 --version
cd $HOME/git
git clone https://github.com/papacarp/pooltool.io
cd pooltool.io/leaderLogs

Calculate your slot leader schedule for the latest current epoch.

python3 leaderLogs.py \
--pool-id $(cat ${NODE_HOME}/stakepoolid.txt) \
--tz America/Los_Angeles \
--vrf-skey ${NODE_HOME}/vrf.skey
cd $HOME/git/pooltool.io/leaderLogs
git pull

If your pool is scheduled to mint blocks, you should hopefully see output similar to this. Listed by date and time, this is your slot leader schedule or in other words, when your pool is eligible to mint a block.

Checking leadership log for Epoch 222 [ d Param: 0.6 ]
2020-10-01 00:11:10 ==> Leader for slot 121212, Cumulative epoch blocks: 1
2020-10-01 00:12:22 ==> Leader for slot 131313, Cumulative epoch blocks: 2
2020-10-01 00:19:55 ==> Leader for slot 161212, Cumulative epoch blocks: 3

Your slot leader log should remain confidential. If you share this information publicly, an attacker could use this information to attack your stake pool.

Automate the process with Cronjob:

Credits to for developing the .

by , ,

Installing the Binary

Running LeaderLog with stake-snapshot

provides to submit the following data for your stake pool:

The following figure shows the green badge that PoolTool displays next to your stake pool when your node is fully synchronized with the blockchain (image credit to ):

You can also use developed by the Cardano Community to send the block height and slot count to PoolTool.

maintain the companion script to help stake pool operators use the Cardano Community's CNCLI utilities.

For details on requesting an API key from PoolTool, see the topic .

Upgrading CNCLI

Credits for inventing this process goes to the hard work by (developer of JorManager and operator of BCSH family of stake pools).

Clone the leaderLog scripts from git repo.

Official documentation for this LeaderLogs tool can be

Set the timezone name to format the schedule's times properly. Use the --tz option. [Default: America/Los_Angeles]')

Pro Tip: 1.5 days before the end of the current epoch, you can find the next epoch's schedule.

Pro Tip #2: Add the flag --epoch <INTEGER #> to find a specific epoch's slot schedule.

Pro Tip #3: Ensure your slot leader scripts are up to date.

🔥
🔁
🧬
⛏️
🛠️
🤖
🤖
🤖
Increase the SWAP partition of the node
Techs2help
script
CNCLI
BCSH
SAND
SALAD
PoolTool
example scripts
QCPOL
CNCLI utilities
Guild Operators
cncli.sh
Obtaining a PoolTool API Key
Andrew Westberg @amw7
papacarp/pooltool.io
read here.
Refer to the official documentation for more info.
Your pool's tip on pooltool.io