Hi Community,
i built my TEST enviroment along the Official stake course & documentation.
Now i’d like to figure out how to obtain upcoming assigned Blocks. (cncli leaderlog)
When i follow the official guide for INSTALL it takes me to the downloadable scripts which only contains information for the mainnet. i cannot figure out, how to run this script on testnet.
i highlighted customization and shorted output:
SCRIPT
#!/bin/bash
export CARDANO_NODE_SOCKET_PATH=/home/obi/core/db/node.socket
/usr/local/bin/cncli sync --host 127.0.0.1 --port 3000 --no-service
echo "BCSH"
SNAPSHOT=$(/usr/local/bin/cardano-cli query stake-snapshot --stake-pool-id 9d20dda05a44eca8ebee4e8fcecd566b47a40b79f3738db6e615b838 --testnet-magic 1097911063)
POOL_STAKE=$(echo "$SNAPSHOT" | grep -oP '(?<= "poolStakeSet": )\d+(?=,?)')
ACTIVE_STAKE=$(echo "$SNAPSHOT" | grep -oP '(?<= "activeStakeSet": )\d+(?=,?)')
BCSH=`/usr/local/bin/cncli leaderlog --pool-id 9d20dda05a44eca8ebee4e8fcecd566b47a40b79f3738db6e615b838 --pool-vrf-skey /home/obi/pool-keys/vrf.skey --byron-genesis /home/obi/core/testnet-byron-genesis.json --shelley-genesis /home/obi/core/testnet-shelley-genesis.json --pool-stake $POOL_STAKE --active-stake $ACTIVE_STAKE --ledger-set current`
echo $BCSH | jq .
EPOCH=`echo $BCSH | jq .epoch`
echo "\`Epoch $EPOCH\` 🧙🔮:"
SLOTS=`echo $BCSH | jq .epochSlots`
IDEAL=`echo $BCSH | jq .epochSlotsIdeal`
PERFORMANCE=`echo $BCSH | jq .maxPerformance`
echo "\`BCSH - $SLOTS \`🎰\`, $PERFORMANCE% \`🍀max, \`$IDEAL\` 🧱ideal"
EXECUTE
sudo /root/scripts/cncli-leaderlog-current.sh
2022-02-02T11:08:51.095Z ERROR cncli::nodeclient::sync > version data mismatch: NodeToNodeVersionData {networkMagic = NetworkMagic {unNetworkMagic = 1097911063}, diffusionMode = InitiatorAndResponderDiffusionMode} /= NodeToNodeVersionData {networkMagic = NetworkMagic {unNetworkMagic = 764824073}, diffusionMode = InitiatorAndResponderDiffusionMode}
How do i properly set the testnet in the script? i cannot find any documentation about it.
Found solution by navigating step-by-step through manual and help pages
Posting Solution just in case someone is struggling with the same topic
correct SCRIPT for Testnet (current)
#!/bin/bash
export CARDANO_NODE_SOCKET_PATH=/home/obi/core/db/node.socket
/usr/local/bin/cncli sync --host 127.0.0.1 --port 3000 --no-service --network-magic 1097911063
echo "BCSH"
SNAPSHOT=$(/home/obi/.local/bin//cardano-cli query stake-snapshot --testnet-magic 1097911063 --stake-pool-id 9d20dda05a44eca8ebee4e8fcecd566b47a40b79f3738db6e615b838)
POOL_STAKE=$(echo "$SNAPSHOT" | grep -oP '(?<= "poolStakeSet": )\d+(?=,?)')
ACTIVE_STAKE=$(echo "$SNAPSHOT" | grep -oP '(?<= "activeStakeSet": )\d+(?=,?)')
BCSH=`/usr/local/bin/cncli leaderlog --pool-id 9d20dda05a44eca8ebee4e8fcecd566b47a40b79f3738db6e615b838 --pool-vrf-skey /home/obi/pool-keys/vrf.skey --byron-genesis /home/obi/core/testnet-byron-genesis.json --shelley-genesis /home/obi/core/testnet-shelley-genesis.json --pool-stake $POOL_STAKE --active-stake $ACTIVE_STAKE --ledger-set current`
echo $BCSH | jq .
EPOCH=`echo $BCSH | jq .epoch`
echo "\`Epoch $EPOCH\` 🧙🔮:"
SLOTS=`echo $BCSH | jq .epochSlots`
IDEAL=`echo $BCSH | jq .epochSlotsIdeal`
PERFORMANCE=`echo $BCSH | jq .maxPerformance`
echo "\`BCSH - $SLOTS \`🎰\`, $PERFORMANCE% \`🍀max, \`$IDEAL\` 🧱ideal"
7.4d4
3 February 2022 05:44
3
Here is a script that I wrote for doing leaderlogs using cncli which doesn’t use any CNTOOLS environment files or scripts:
cat /usr/bin/cncli-leaderlog
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
export CARDANO_NODE_SOCKET_PATH='/run/cardano/mainnet-node.socket' #FIXME
CNODE_HOME='/opt/cardano' #FIXME
db="${CNODE_HOME}/db/cncli.db" #FIXME
pool_vrf_skey="${CNODE_HOME}/priv/vrf.skey" #FIXME
byron_genesis="${CNODE_HOME}/etc/mainnet-byron-genesis.json" #FIXME
shelley_genesis="${CNODE_HOME}/etc/mainnet-shelley-genesis.json" #FIXME
tz='Australia/Brisbane' #FIXME
config="${CNODE_HOME}/etc/my-cardano-node-config.json" #FIXME
# Check poolId defined in config
[[ -f "$config" ]] || { echo "Config: $config doesn't exist."; exit 1; }
pool_id="$(jq -r '.poolId' "$config" 2>/dev/null)"
if [[ -z "${pool_id:-}" || "$pool_id" == 'null' ]]; then
echo "Config: $config must contain poolId"
exit 1
fi
function usage() {
echo "Usage: $(basename $0) prev | curr | next" 2>&1
echo 'Generates leaderlog for previous, current or next epoch'
echo
}
optstring=":h"
while getopts ${optstring} arg; do
case ${arg} in
h) usage; exit 0;;
?) echo "Invalid options: -${OPTARG}."; echo; usage; exit 1;;
esac
done
if [[ $(( $# - $OPTIND )) -ne 0 ]]; then usage; exit 1; fi
epoch=${@:$OPTIND:1}; epoch="${epoch:0:4}"
if ! [[ "$epoch" =~ ^(prev|curr|next)$ ]]; then usage; exit 1; fi
declare -A epoch_snapshot # Snapshot name for epoch (Mark|Set|Go)
epoch_snapshot=([prev]='Go' [curr]='Set' [next]='Mark')
snapshot=$(nice -n 15 cardano-cli query stake-snapshot --stake-pool-id "${pool_id}" --mainnet)
pool_stake=$(echo "${snapshot}" | jq ".poolStake${epoch_snapshot[${epoch}]}")
active_stake=$(echo "${snapshot}" | jq ".activeStake${epoch_snapshot[${epoch}]}")
nice -n 15 cncli leaderlog --db "$db" --pool-id "${pool_id}" --pool-vrf-skey "$pool_vrf_skey" --byron-genesis "$byron_genesis" --shelley-genesis "$shelley_genesis" --pool-stake "${pool_stake}" --active-stake "${active_stake}" --ledger-set "${epoch}" --tz "$tz"
exit 0
Check all the variables with #FIXME and change to your values. “my-cardano-node-config.json” file should contain at least:
{
"poolId": "blahblahblah_my_pool_id_hash_value"
}
Or you could just set the variable pool_id directly in the script.
Modify the cardano-cli command for testnet in the script as required.
1 Like