diff --git a/scripts/cnode-helper-scripts/archive/balance.sh b/scripts/cnode-helper-scripts/archive/balance.sh deleted file mode 100755 index 4977ac0bf..000000000 --- a/scripts/cnode-helper-scripts/archive/balance.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC1090,SC2086 - -. "$(dirname $0)"/env - -usage() { echo "Usage: $(basename "$0")
" 1>&2; exit 1; } - -if [[ $# -eq 0 ]]; then - usage -elif [[ $# -eq 1 && ! -f "$1" ]]; then - WALLET_ADDR=$1 -elif [[ $# -eq 1 ]]; then - WALLET_ADDR="$(cat "$1")" -else - usage -fi - -function cleanup() { - rm -rf "${TMP_DIR}/fullUtxo.out" - rm -rf "${TMP_DIR}/balance.txt" -} - -# start with a clean slate -cleanup - -${CCLI} query utxo ${NETWORK_IDENTIFIER} --address "${WALLET_ADDR}" > "${TMP_DIR}/fullUtxo.out" -tail -n +3 "${TMP_DIR}/fullUtxo.out" | sort -k3 -nr > "${TMP_DIR}/balance.txt" - -TOTALBALANCE=0 -UTx0_COUNT=0 - -if [ -s "${TMP_DIR}/balance.txt" ]; then - echo "" - head -n 2 "${TMP_DIR}/fullUtxo.out" - head -n 10 "${TMP_DIR}/balance.txt" -fi - -while read -r UTxO; do - INADDR=$(awk '{ print $1 }' <<< "$UTxO") - IDX=$(awk '{ print $2 }' <<< "$UTxO") - BALANCE=$(awk '{ print $3 }' <<< "$UTxO") - - UTx0_COUNT=$(( UTx0_COUNT + 1 )) - TX_IN="${TX_IN} --tx-in ${INADDR}#${IDX}" - TOTALBALANCE=$(( TOTALBALANCE + BALANCE )) -done <"${TMP_DIR}/balance.txt" - -[[ ${UTx0_COUNT} -gt 10 ]] && echo "... (top 10 UTx0 with most lovelace)" - -# ADA pretty print explanation for sed -# remove trailing 0 IF there is a decimal separator -# remove the separator if there are only 0 after separator also (assuming there is at least a digit before like BC does) - -TOTALBALANCE_ADA=$(echo "${TOTALBALANCE}/1000000" | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//') -echo "" -echo "Total balance in ${UTx0_COUNT} UTxO is ${TOTALBALANCE} Lovelace or ${TOTALBALANCE_ADA} ADA" -echo "" diff --git a/scripts/cnode-helper-scripts/archive/createAddr.sh b/scripts/cnode-helper-scripts/archive/createAddr.sh deleted file mode 100755 index ac272283d..000000000 --- a/scripts/cnode-helper-scripts/archive/createAddr.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC2086,SC1090 -. "$(dirname $0)"/env offline - -if [ "$1" = "--help" ] || [ $# -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi - -GREEN="\x1B[1;32m" -NC="\x1B[0m" - -WNAME="$1" -${CCLI} address key-gen --verification-key-file ${WNAME}_payment.vkey --signing-key-file ${WNAME}_payment.skey -${CCLI} stake-address key-gen --verification-key-file ${WNAME}_stake.vkey --signing-key-file ${WNAME}_stake.skey -echo -e "${GREEN}Payment/Enterprise address:${NC}" -${CCLI} address build --payment-verification-key-file ${WNAME}_payment.vkey ${HASH_IDENTIFIER} | tee ${WNAME}_payment.addr -echo -e "${GREEN}Base address:${NC}" -${CCLI} address build --payment-verification-key-file ${WNAME}_payment.vkey --stake-verification-key-file ${WNAME}_stake.vkey ${HASH_IDENTIFIER} | tee ${WNAME}_base.addr -echo -e "${GREEN}Reward address:${NC}" -${CCLI} stake-address build --stake-verification-key-file ${WNAME}_stake.vkey ${HASH_IDENTIFIER} | tee ${WNAME}_reward.addr diff --git a/scripts/cnode-helper-scripts/archive/itnRewards.sh b/scripts/cnode-helper-scripts/archive/itnRewards.sh deleted file mode 100755 index f8a1506f0..000000000 --- a/scripts/cnode-helper-scripts/archive/itnRewards.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC2086,SC1090 - -# source files -. "$(dirname $0)"/env -. "$(dirname $0)"/cntools.config - -function usage() { - echo -e "\nUsage: $(basename "$0") \n" - echo -e "Create a CNTools compatible wallet from ITN keys to be able to withdraw rewards\n" - printf " %-20s\t%s\n" "wallet name" "Wallet name shown in CNTools" \ - "ITN signing key file" "ITN Owner skey (ed25519_sk/ed25519e_sk)" \ - "ITN verification key file" "ITN Owner vkey (ed25519_pk)" - echo "" - exit 1 -} - -if [[ $# -ne 3 ]]; then - usage -fi - -wallet_name="$1" -itn_signing_key_file="$2" -itn_verification_key_file="$3" - -if [[ ! -f "${itn_signing_key_file}" || ! $(cat "${itn_signing_key_file}") =~ ^ed25519e?_sk* ]]; then - echo -e "\n${RED}ERROR${NC}: Invalid ITN Signing Key provided\n" - exit 1 -fi - -if [[ ! -f "${itn_verification_key_file}" || $(cat "${itn_verification_key_file}") != ed25519_pk* ]]; then - echo -e "\n${RED}ERROR${NC}: Invalid ITN Verification Key provided\n" - exit 1 -fi - -if [[ -d "${WALLET_FOLDER}/${wallet_name}" ]]; then - echo -e "\n${RED}ERROR${NC}: Wallet already exist, please use another name" - echo -e "${WALLET_FOLDER}/${wallet_name}\n" - exit 1 -fi -mkdir -p "${WALLET_FOLDER}/${wallet_name}" -if [[ ! -d "${WALLET_FOLDER}/${wallet_name}" ]]; then - echo -e "\n${RED}ERROR${NC}: Failed to create wallet directory?" - echo -e "${WALLET_FOLDER}/${wallet_name}\n" - exit 1 -fi - -if [[ $(cat "${itn_signing_key_file}") == ed25519e_* ]]; then - if ! ${CCLI} key 2>&1 | grep -q "convert-itn-extended-key"; then - echo -e "\n${ORANGE}WARNING${NC}: cardano-cli lacks support for extended ITN key conversion: ${CCLI}\n" - echo -e "If a special version of cardano-cli is built with this support, please specify path below, else follow instructions available at:" - echo -e " https://cardano-community.github.io/guild-operators/Scripts/itnrewards\n" - while true; do - read -r -p "Enter path to cardano-cli with support for extended key conversion or press enter to quit: " CCLI - [[ -z "${CCLI}" ]] && rm -rf "${WALLET_FOLDER:?}/${wallet_name}" && exit 1 - if ! ${CCLI} key 2>&1 | grep -q "convert-itn-extended-key"; then - echo -e "\n${ORANGE}ERROR${NC}: specified file lacks support for extended ITN key conversion, please try again\n" - continue - fi - break - done - fi - ${CCLI} key convert-itn-extended-key --itn-signing-key-file ${itn_signing_key_file} --out-file "${WALLET_FOLDER}/${wallet_name}/${WALLET_STAKE_SK_FILENAME}" -else - ${CCLI} key convert-itn-key --itn-signing-key-file ${itn_signing_key_file} --out-file "${WALLET_FOLDER}/${wallet_name}/${WALLET_STAKE_SK_FILENAME}" -fi -${CCLI} key convert-itn-key --itn-verification-key-file ${itn_verification_key_file} --out-file "${WALLET_FOLDER}/${wallet_name}/${WALLET_STAKE_VK_FILENAME}" - -${CCLI} address key-gen --verification-key-file "${WALLET_FOLDER}/${wallet_name}/${WALLET_PAY_VK_FILENAME}" --signing-key-file "${WALLET_FOLDER}/${wallet_name}/${WALLET_PAY_SK_FILENAME}" -echo -e "\n${BLUE}Payment/Enterprise address:${NC}" -${CCLI} address build --payment-verification-key-file "${WALLET_FOLDER}/${wallet_name}/${WALLET_PAY_VK_FILENAME}" ${HASH_IDENTIFIER} | tee "${WALLET_FOLDER}/${wallet_name}/${WALLET_PAY_ADDR_FILENAME}" -echo -e "${BLUE}Base address:${NC}" -${CCLI} address build --payment-verification-key-file "${WALLET_FOLDER}/${wallet_name}/${WALLET_PAY_VK_FILENAME}" --stake-verification-key-file "${WALLET_FOLDER}/${wallet_name}/${WALLET_STAKE_VK_FILENAME}" ${HASH_IDENTIFIER} | tee "${WALLET_FOLDER}/${wallet_name}/${WALLET_BASE_ADDR_FILENAME}" -echo -e "${BLUE}Reward address:${NC}" -${CCLI} stake-address build --stake-verification-key-file "${WALLET_FOLDER}/${wallet_name}/${WALLET_STAKE_VK_FILENAME}" ${HASH_IDENTIFIER} | tee "${WALLET_FOLDER}/${wallet_name}/${WALLET_STAKE_ADDR_FILENAME}" - -echo -e "\nWallet ${GREEN}${wallet_name}${NC} created\n" -echo -e "1) Start CNTools and verify that correct balance is shown in the wallet reward address" -echo -e "2) Fund base address of wallet with enough funds to pay for withdraw tx fee" -echo -e "3) Use FUNDS >> WITHDRAW to move rewards to base address of wallet from were you can spend/move them as you like\n" diff --git a/scripts/cnode-helper-scripts/archive/rotatePoolKeys.sh b/scripts/cnode-helper-scripts/archive/rotatePoolKeys.sh deleted file mode 100755 index 6621a073d..000000000 --- a/scripts/cnode-helper-scripts/archive/rotatePoolKeys.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC1090,SC2086,SC2154 -function usage() { - printf "\n%s\n\n" "Usage: $(basename "$0") " - printf " %-20s\t%s\n\n" "Pool Name" "Pool name used in CNTools, see cntools.config for pool folder" - exit 1 -} - -if [[ $# -ne 1 ]]; then - usage -fi - -# source files -. "$(dirname $0)"/env -. "$(dirname $0)"/cntools.library -. "$(dirname $0)"/cntools.config - -pool_name="${1}" - -if [[ ! -d "${POOL_FOLDER}/${pool_name}" ]]; then - echo -e "${RED}ERROR${NC}: pool folder not found!" - echo -e "${POOL_FOLDER}/${pool_name}" - exit 1 -fi - -if ! rotatePoolKeys; then - echo && exit 1 -fi - -echo -echo -e "Pool KES Keys Updated: ${GREEN}${pool_name}${NC}" -echo -e "New KES start period: ${start_kes_period}" -echo -e "KES keys will expire on kes period ${kes_expiration_period}, ${expiration_date}" -echo -e "Restart your pool node for changes to take effect" -echo diff --git a/scripts/cnode-helper-scripts/archive/sendADA.sh b/scripts/cnode-helper-scripts/archive/sendADA.sh deleted file mode 100755 index 09e9a938b..000000000 --- a/scripts/cnode-helper-scripts/archive/sendADA.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC1090,SC2086,SC2206,SC2015,SC2154,SC2034 -function usage() { - printf "\n%s\n\n" "Usage: $(basename "$0") [--include-fee]" - printf " %-20s\t%s\n" \ - "Destination Address" "Address or path to Address file." \ - "Amount" "Amount in ADA, number(fraction of ADA valid) or the string 'all'." \ - "Source Address" "Address or path to Address file." \ - "Source Sign Key" "Path to Signature (skey) file. For staking address payment skey is to be used." \ - "--include-fee" "Optional argument to specify that amount to send should be reduced by fee instead of payed by sender." \ - "" "" "Script does NOT support sending of assets other than Ada" "" - printf "\n" - exit 1 -} - -if [[ $# -lt 4 ]]; then - usage -fi - -# source files -. "$(dirname $0)"/env -. "$(dirname $0)"/cntools.config -. "$(dirname $0)"/cntools.library - -CNTOOLS_LOG=/dev/null # disable logging -exec 6>&1 7>&2 8>&1 9>&2 # Link file descriptors to be compatible with CNTools sourced functions - -customExit() { - if { true >&6; } 2<> /dev/null; then - exec 1>&6 2>&7 3>&- 6>&- 7>&- 8>&- 9>&- # Restore stdout/stderr and close tmp file descriptors - fi - exit $1 -} - -# create temporary directory if missing -mkdir -p "${TMP_FOLDER}" # Create if missing -if [[ ! -d "${TMP_FOLDER}" ]]; then - echo - echo -e "${RED}ERROR${NC}: Failed to create directory for temporary files:" - echo -e "${TMP_FOLDER}" - echo && customExit 1 -fi - -# start with a clean slate -rm -f "${TMP_FOLDER}"/* - -# Get protocol parameters and save to ${TMP_FOLDER}/protparams.json -${CCLI} query protocol-parameters ${NETWORK_IDENTIFIER} --out-file ${TMP_FOLDER}/protparams.json || { - echo - echo -e "${RED}ERROR${NC}: failed to query protocol parameters, node running and env parameters correct?" - customExit 1 -} - -# Handle script arguments -if [[ ! -f "$1" ]]; then - d_addr="$1" -else - d_addr="$(cat $1)" -fi - -if [[ ! -f "$3" ]]; then - s_addr="$3" -else - s_addr="$(cat $3)" -fi - -if [[ -f "$4" ]]; then - payment_sk_file="$4" -else - echo -e "${RED}ERROR${NC}: Source Sign file(skey) not found!" - echo -e "$4" - echo && customExit 1 -fi - -if [[ $# -eq 5 ]]; then - [[ $5 = "--include-fee" ]] && include_fee="yes" || usage -else - include_fee="no" -fi - -getBalance ${s_addr} -if [[ ${assets[lovelace]} -gt 0 ]]; then - echo -e "$(printf "\n%s\t${CYAN}%s${NC} ADA" "Funds in source wallet:" "$(formatLovelace ${assets[lovelace]})")" "log" -else - echo -e "${RED}ERROR${NC}: no funds available in source address" - echo && customExit 1 -fi -declare -gA assets_left=() -for asset in "${!assets[@]}"; do - assets_left[${asset}]=${assets[${asset}]} -done - -amountADA="$2" -if [[ ${amountADA} != "all" ]]; then - if ! AdaToLovelace "${amountADA}" >/dev/null; then - echo && customExit 1 - fi - amount_lovelace=$(AdaToLovelace "${amountADA}") - [[ ${amount_lovelace} -gt ${assets[lovelace]} ]] && echo -e "\n${FG_RED}ERROR${NC}: not enough funds on address, ${FG_LBLUE}$(formatLovelace ${assets[lovelace]})${NC} Ada available but trying to send ${FG_LBLUE}$(formatLovelace ${amount_lovelace})${NC} Ada" && echo && customExit 1 -else - amount_lovelace=${assets[lovelace]} - echo -e "\nAda to send set to total supply: ${FG_LBLUE}$(formatLovelace ${amount_lovelace})${NC}" - include_fee="yes" -fi - -if [[ ${amount_lovelace} -eq ${assets[lovelace]} ]]; then - unset assets_left -else - assets_left[lovelace]=$(( assets_left[lovelace] - amount_lovelace )) -fi - -declare -gA assets_to_send=() -assets_to_send[lovelace]=${amount_lovelace} - -s_payment_sk_file="${payment_sk_file}" - -echo -if ! sendAssets >&1; then - echo && customExit 1 -fi - -if ! waitNewBlockCreated >&1; then - echo && customExit 1 -fi - -getBalance ${s_addr} - -while [[ ${assets[lovelace]} -ne ${newBalance} ]]; do - echo - echo -e "${ORANGE}WARN${NC}: Balance mismatch, transaction not included in latest block ($(formatLovelace ${assets[lovelace]}) != $(formatLovelace ${newBalance}))" - if ! waitNewBlockCreated; then - echo "" && customExit 1 - fi - getBalance ${s_addr} -done - -echo -e "$(printf "\n%s\t\t${CYAN}%s${NC} ADA" "Funds in source wallet:" "$(formatLovelace ${assets[lovelace]})")" "log" - -getBalance ${d_addr} -echo -e "$(printf "%s\t${CYAN}%s${NC} ADA" "Funds in destination wallet:" "$(formatLovelace ${assets[lovelace]})")" "log" - -echo -e "\n## Finished! ##\n" - -customExit 0 diff --git a/scripts/cnode-helper-scripts/archive/stack-build.sh b/scripts/cnode-helper-scripts/archive/stack-build.sh deleted file mode 100755 index 79dd5061c..000000000 --- a/scripts/cnode-helper-scripts/archive/stack-build.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -# Install stack if not installed on system -if ! command -v stack >/dev/null; then - curl -sSL https://get.haskellstack.org/ | sh -fi - -# executes stack build and copies binaries to ~/.local/bin folder. -stack build --test --no-run-tests --copy-bins --local-bin-path ~/.local/bin 2>&1 | tee /tmp/build.log diff --git a/scripts/cnode-helper-scripts/archive/system-info.sh b/scripts/cnode-helper-scripts/archive/system-info.sh deleted file mode 100755 index 251dd19e3..000000000 --- a/scripts/cnode-helper-scripts/archive/system-info.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -# pHTN testnet watchdog -# 2020-04-09 v0.1 initial proposal - -echo -e "-------------------------------System Information----------------------------" -echo -e "Hostname:\t\t""$(hostname)" -echo -e "uptime:\t\t\t""$(uptime | awk '{print $3,$4}' | sed 's/,//')" -echo -e "Manufacturer:\t\t""$(cat /sys/class/dmi/id/chassis_vendor)" -echo -e "Product Name:\t\t""$(cat /sys/class/dmi/id/product_name)" -echo -e "Version:\t\t""$(cat /sys/class/dmi/id/product_version)" -#echo -e "Serial Number:\t\t""$(cat /sys/class/dmi/id/product_serial)" -echo -e "Machine Type:\t\t""$(vserver=$(lscpu | grep -c Hypervisor); if [ "$vserver" -gt 0 ]; then echo "VM"; else echo "Physical"; fi)" -echo -e "Operating System:\t""$(hostnamectl | grep "Operating System" | cut -d ' ' -f5-)" -echo -e "Kernel:\t\t\t""$(uname -r)" -echo -e "Architecture:\t\t""$(arch)" -echo -e "Processor Name:\t\t""$(awk -F':' '/^model name/ {print $2}' /proc/cpuinfo | uniq | sed -e 's/^[ \t]*//')" -echo -e "Active User:\t\t""$(w | cut -d ' ' -f1 | grep -v USER | xargs -n1)" -#echo -e "System Main IP:\t\t""$(hostname -I)" -echo "" -echo -e "-------------------------------CPU/Memory Usage------------------------------" -echo -e "Memory Usage:\t""$(free | awk '/Mem/{printf("%.2f%"), $3/$2*100}')" -echo -e "Swap Usage:\t""$(free | awk '/Swap/{if($2=="0")v=0;else v=$3/$2*100;printf(" %.2f\n",$v)}')" -echo -e "CPU Usage:\t""$(awk '/cpu/{printf("%.2f%\n"), ($2+$4)*100/($2+$4+$5)}' < /proc/stat | awk '{print $0}' | head -1)" -echo "" -echo -e "-------------------------------Disk Usage >80%-------------------------------" -df -Ph | sed s/%//g | awk '{ if($5 > 80) print $0;}' -echo "" - -while : -do - echo -e "$(date '+%H:%M:%S') MEM-total\t""$(free | awk '/Mem/{printf("%.2f%"), $3/$2*100}')" - sleep 10 -done diff --git a/scripts/grest-helper-scripts/getmetrics.sh b/scripts/grest-helper-scripts/getmetrics.sh index 811660b7a..62a308dfc 100755 --- a/scripts/grest-helper-scripts/getmetrics.sh +++ b/scripts/grest-helper-scripts/getmetrics.sh @@ -42,17 +42,16 @@ function get-metrics() { tip=$(curl -s http://${RESTAPI_HOST}:${RESTAPI_PORT}/rpc/tip) meminf=$(grep "^Mem" /proc/meminfo) load1m=$(( $(awk '{ print $1*100 }' /proc/loadavg) / $(grep -c ^processor /proc/cpuinfo) )) - memtotal=$(( $(echo "${meminf}" | grep MemTotal | awk '{print $2}') )) - arcused=$(awk -v CONVFMT='%i' '/^size/ { print $3/1024 }' /proc/spl/kstat/zfs/arcstats 2>/dev/null) + memtotal=$(echo "${meminf}" | grep MemTotal | awk '{print $2}') + arcused=$(awk -v OFMT='%i' '/^size/ { print $3/1024 }' /proc/spl/kstat/zfs/arcstats 2>/dev/null) [[ -z "${arcused}" ]] && arcused=0 memused=$(( memtotal - $(echo "${meminf}" | grep MemAvailable | awk '{print $2}') - arcused )) - cpuutil=$(awk -v a="$(awk '/cpu /{print $2+$4,$2+$4+$5}' /proc/stat; sleep 1)" '/cpu /{split(a,b," "); print 100*($2+$4-b[1])/($2+$4+$5-b[2])}' /proc/stat) + cpuutil=$(awk -v a="$(awk -v OFMT='%i' '/cpu /{print $2+$4,$2+$4+$5}' /proc/stat; sleep 1)" '/cpu /{split(a,b," "); print 100*($2+$4-b[1])/($2+$4+$5-b[2])}' /proc/stat) # in Bytes pubschsize=$(psql -t --csv -d ${PGDATABASE} -c "SELECT sum(pg_total_relation_size(quote_ident(schemaname) || '.' || quote_ident(tablename))::bigint) FROM pg_tables WHERE schemaname = 'public'" | grep "^[0-9]") grestschsize=$(psql -t --csv -d ${PGDATABASE} -c "SELECT sum(pg_total_relation_size(quote_ident(schemaname) || '.' || quote_ident(tablename))::bigint) FROM pg_tables WHERE schemaname = 'grest'" | grep "^[0-9]") grestconns=$(psql -t --csv -d ${PGDATABASE} -c "select count(1) from pg_stat_activity where state='active' or state='idle';" | awk '{print $1}') dbsize=$(psql -t --csv -d ${PGDATABASE} -c "SELECT pg_database_size ('${PGDATABASE}');" | grep "^[0-9]") - # Metrics export METRIC_dbsynctipref=$(( currslottip - $( echo "${tip}" | jq .[0].abs_slot) )) export METRIC_nodetipref=$(( currslottip - slotnum )) diff --git a/scripts/grest-helper-scripts/grest-poll.sh b/scripts/grest-helper-scripts/grest-poll.sh index d1455eb41..2be84b855 100755 --- a/scripts/grest-helper-scripts/grest-poll.sh +++ b/scripts/grest-helper-scripts/grest-poll.sh @@ -137,10 +137,12 @@ function chk_rpcs() { } function chk_cache_status() { - last_stakedist_block=$(curl -skL "${GURL}/control_table?key=eq.stake_distribution_lbh" | jq -r .[0].last_value 2>/dev/null) - last_poolhist_update=$(curl -skL "${GURL}/control_table?key=eq.pool_history_cache_last_updated" | jq -r .[0].last_value 2>/dev/null) - last_actvstake_epoch=$(curl -skL "${GURL}/control_table?key=eq.last_active_stake_validated_epoch" | jq -r .[0].last_value 2>/dev/null) - last_snapshot_epoch=$(curl -skL "${GURL}/control_table?key=eq.last_stake_snapshot_epoch" | jq -r .[0].last_value 2>/dev/null) + ctrl_tbl=$(curl -skL "${GURL}/control_table") + last_stakedist_block=$(jq -r 'map(select(.key == "stake_distribution_lbh"))[0].last_value' 2>/dev/null <<< "${ctrl_tbl}") + last_poolhist_update=$(jq -r 'map(select(.key == "pool_history_cache_last_updated"))[0].last_value' 2>/dev/null <<< "${ctrl_tbl}") + last_actvstake_epoch=$(jq -r 'map(select(.key == "last_active_stake_validated_epoch"))[0].last_value' 2>/dev/null <<< "${ctrl_tbl}") + last_snapshot_epoch=$(jq -r 'map(select(.key == "last_stake_snapshot_epoch"))[0].last_value' 2>/dev/null <<< "${ctrl_tbl}") + last_epoch_summary=$(jq -r 'map(select(.key == "last_epoch_summary_data_checked"))[0].last_value' 2>/dev/null <<< "${ctrl_tbl}") if [[ "${last_stakedist_block}" == "" ]] || [[ "${last_stakedist_block}" == "[]" ]] || [[ $(( block_no - last_stakedist_block )) -gt 1000 ]]; then log_err "Stake Distribution cache too far from tip !!" optexit @@ -153,18 +155,22 @@ function chk_cache_status() { log_err "Active Stake cache not populated !!" optexit else - [[ -z "${GENESIS_JSON}" ]] && GENESIS_JSON="${PARENT}"/../files/shelley-genesis.json - epoch_length=$(jq -r .epochLength "${GENESIS_JSON}" 2>/dev/null) - if [[ ${epoch_slot} -ge $(( epoch_length / 8 )) ]]; then - if [[ "${last_actvstake_epoch}" != "${epoch}" ]]; then - log_err "Active Stake cache for epoch ${epoch} still not populated as of ${epoch_slot} slot, maximum tolerance was $(( epoch_length / 10 )) !!" - optexit - fi - else - if [[ $((last_snapshot_epoch + 2)) -lt ${epoch} ]]; then - log_err "Stake snapshot for instance is at '${last_snapshot_epoch}' while current epoch is ${epoch} !!" - optexit - fi + [[ -z "${GENESIS_JSON}" ]] && GENESIS_JSON="${PARENT}"/../files/shelley-genesis.json + epoch_length=$(jq -r .epochLength "${GENESIS_JSON}" 2>/dev/null) + if [[ ${epoch_slot} -ge $(( epoch_length / 6 )) ]]; then + if [[ "${last_actvstake_epoch}" != "${epoch}" ]]; then + log_err "Active Stake cache for epoch ${epoch} still not populated as of ${epoch_slot} slot, maximum tolerance was $(( epoch_length / 10 )) !!" + optexit + fi + if [[ "last_epoch_summary" != "${epoch}" ]]; then + log_err "Epoch Summary Cache for epoch ${epoch} still not populated as of ${epoch_slot} slot, maximum tolerance was $(( epoch_length / 10 )) !!" + optexit + fi + else + if [[ $((last_snapshot_epoch + 2)) -lt ${epoch} ]]; then + log_err "Stake snapshot for instance is at '${last_snapshot_epoch}' while current epoch is ${epoch} !!" + optexit + fi fi fi } @@ -220,7 +226,6 @@ else fi chk_upd - chk_version chk_rpcs chk_tip diff --git a/scripts/grest-helper-scripts/setup-grest.sh b/scripts/grest-helper-scripts/setup-grest.sh index f2a75017e..a4db8c411 100755 --- a/scripts/grest-helper-scripts/setup-grest.sh +++ b/scripts/grest-helper-scripts/setup-grest.sh @@ -16,7 +16,7 @@ # Do NOT modify code below # ###################################### -SGVERSION=v1.1.0 +SGVERSION=v1.1.1 ######## Functions ######## usage() { @@ -139,8 +139,8 @@ SGVERSION=v1.1.0 get_cron_job_executable "stake-distribution-update" set_cron_variables "stake-distribution-update" # Special condition for guild network (NWMAGIC=141) where activity and entries are minimal, and epoch duration is 1 hour - ([[ ${NWMAGIC} -eq 141 ]] && install_cron_job "stake-distribution-update" "*/5 * * * *") || - install_cron_job "stake-distribution-update" "*/30 * * * *" + ([[ ${NWMAGIC} -eq 141 ]] && install_cron_job "stake-distribution-update" "*/10 * * * *") || + install_cron_job "stake-distribution-update" "*/120 * * * *" get_cron_job_executable "stake-distribution-new-accounts-update" set_cron_variables "stake-distribution-new-accounts-update" @@ -303,7 +303,7 @@ SGVERSION=v1.1.0 pgrest_binary=linux-static-x64.tar.xz fi #pgrest_asset_url="$(curl -s https://api.github.com/repos/PostgREST/postgrest/releases/latest | jq -r '.assets[].browser_download_url' | grep ${pgrest_binary})" - pgrest_asset_url="https://github.com/PostgREST/postgrest/releases/download/v11.2.2/postgrest-v11.2.2-${pgrest_binary}" # Fix PostgREST to v11.2.2 until v12 headers are updated + pgrest_asset_url="https://github.com/PostgREST/postgrest/releases/download/v12.0.2/postgrest-v12.0.2-${pgrest_binary}" # Fix PostgREST to v11.2.2 until v12 headers are updated if curl -sL -f -m ${CURL_TIMEOUT} -o postgrest.tar.xz "${pgrest_asset_url}"; then tar xf postgrest.tar.xz &>/dev/null && rm -f postgrest.tar.xz [[ -f postgrest ]] || err_exit "PostgREST archive downloaded but binary not found after attempting to extract package!" @@ -319,7 +319,9 @@ SGVERSION=v1.1.0 deploy_haproxy() { printf "\n[Re]Installing HAProxy.." pushd ~/tmp >/dev/null || err_exit - haproxy_url="http://www.haproxy.org/download/2.8/src/haproxy-2.8.3.tar.gz" + major_v="2.9" + minor_v="1" + haproxy_url="http://www.haproxy.org/download/${major_v}/src/haproxy-${major_v}.${minor_v}.tar.gz" if curl -sL -f -m ${CURL_TIMEOUT} -o haproxy.tar.gz "${haproxy_url}"; then tar xf haproxy.tar.gz &>/dev/null && rm -f haproxy.tar.gz if command -v apt-get >/dev/null; then @@ -328,7 +330,7 @@ SGVERSION=v1.1.0 if command -v yum >/dev/null; then sudo yum -y install pcre-devel >/dev/null || err_exit "'sudo yum -y install prce-devel' failed!" fi - cd haproxy-2.8.3 || return + cd haproxy-${major_v}.${minor_v} || return make clean >/dev/null make -j $(nproc) TARGET=linux-glibc USE_ZLIB=1 USE_LIBCRYPT=1 USE_OPENSSL=1 USE_PCRE=1 USE_SYSTEMD=1 USE_PROMEX=1 >/dev/null sudo make install-bin >/dev/null @@ -375,6 +377,9 @@ SGVERSION=v1.1.0 db-anon-role = "web_anon" server-host = "127.0.0.1" server-port = 8050 + db-aggregates-enabled = true + #db-plan-enabled = false + #server-timing-enabled = true #jwt-secret = "secret-token" #db-pool = 10 #db-extra-search-path = "public" @@ -392,8 +397,8 @@ SGVERSION=v1.1.0 maxconn 256 ulimit-n 65536 stats socket \"\\\$GRESTTOP\"/sockets/haproxy.socket mode 0600 level admin user \"\\\$HAPROXY_SOCKET_USER\" - cpu-map 1/all 1-2 log 127.0.0.1 local0 notice + tune.disable-zero-copy-forwarding insecure-fork-wanted external-check