diff --git a/.github/workflows/docker_bin.yml b/.github/workflows/docker_bin.yml index 3b13315cc..a56fe0bf6 100644 --- a/.github/workflows/docker_bin.yml +++ b/.github/workflows/docker_bin.yml @@ -2,6 +2,16 @@ name: Docker Image on: workflow_dispatch: + inputs: + guild_deploy_branch: + description: Branch to deploy + required: false + default: master + testing: + description: Testing workflow + required: false + type: boolean + default: false push: paths: - 'files/docker/node/release-versions/cardano-node-latest.txt' @@ -26,6 +36,7 @@ jobs: --file files/docker/node/dockerfile_bin \ --compress \ --build-arg G_ACCOUNT=${{ env.G_ACCOUNT }} \ + --build-arg GUILD_DEPLOY_BRANCH=${{ env.guild_deploy_branch }} \ --tag ${{ env.REGISTRY }}/${{ secrets.DOCKER_USER }}/cardano-node:latest # Workaround to provide additional free space for builds. # https://github.com/actions/virtual-environments/issues/2840 @@ -42,6 +53,7 @@ jobs: sudo rm -rf "/usr/local/share/boost" sudo rm -rf "$AGENT_TOOLSDIRECTORY" - name: docker push latest + if: env.testing == 'false' && env.guild_deploy_branch == 'master' run: | CNVERSION=`cat files/docker/node/release-versions/cardano-node-latest.txt` docker push ${{ env.REGISTRY }}/${{ secrets.DOCKER_USER }}/cardano-node:latest diff --git a/docs/docker/docker.md b/docs/docker/docker.md index 6b5d7cd34..a9a1df980 100644 --- a/docs/docker/docker.md +++ b/docs/docker/docker.md @@ -16,12 +16,19 @@ Running your own Cardano node has never been so fast and easy. - cardano-hw-cli - cardano-node - cardano-submit-api +- mithril-client +- mithril-signer + +#### Mithril ### 🔔 Built-in tools - CNTools - gLiveView - CNCLI +- Ogmios +- Cardano Hardware CLI +- Cardano Signer - Monitoring ready (with EKG and Prometheus) #### Docker Splash screen @@ -48,11 +55,13 @@ Running your own Cardano node has never been so fast and easy. Modular docker images based on Debian. -Based on the Guild's work we decided to build the Cardano Node images in 3 stages: +Based on the Guild's work the Cardano Node image is built in a single stage: -> [dockerfile_bin](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_bin) + +- Uses `guild-deploy.sh` to: + - Install the os prerequisites + - Add the cardano software from release binaries + - Add the guild's SPO tools and the node's configuration files. -- 1st stage: it uses `prereq.sh` to prepare the development environment before compiling the node source code. -> [Stage1](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_stage1) -- 2nd stage: based on stage1, this stage intent is to compile and produce the binaries of the node. -> [Stage2](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_stage2) -- 3rd stage: based upon a minimal debian image it incorporates the node's binaries as well as all the Koios' SPO tools. -> [Stage3](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_stage3) ### Additional docs diff --git a/docs/docker/run.md b/docs/docker/run.md index 4f37f925d..bc3d9abe8 100644 --- a/docs/docker/run.md +++ b/docs/docker/run.md @@ -56,4 +56,5 @@ !!! info "Note" 1) `--entrypoint=bash` # This option won't start the node's container but only the OS running (the node software wont actually start, you'll need to manually execute entrypoint.sh ), ready to get in (trough the command ``` docker exec -it < container name or hash > /bin/bash ```) and play/explore around with it in command line mode. 2) all guild tools env variable can be used to start a new container using custom values by using the "-e" option. - 3) CPU and RAM and SHared Memory allocation option for the container can be used when you start the container (i.e. --shm-size or --memory or --cpus [official docker resource docs](https://docs.docker.com/config/containers/resource_constraints/)) + 3) CPU and RAM and Shared Memory allocation option for the container can be used when you start the container (i.e. --shm-size or --memory or --cpus [official docker resource docs](https://docs.docker.com/config/containers/resource_constraints/)) + 4) `--env MITHRIL_DOWNLOAD=Y` # This option will allow Mithril client to download the latest Mithril snapshot of the blockchain when the container starts and does not have a copy of the blockchain yet. This is useful when you want to start a new node from scratch and don't want to wait for the node to sync from the network. This option is only available for the mainnet, preprod, and preview networks. diff --git a/files/docker/node/dockerfile_bin b/files/docker/node/dockerfile_bin index b6aa4104e..c1df464b7 100644 --- a/files/docker/node/dockerfile_bin +++ b/files/docker/node/dockerfile_bin @@ -6,6 +6,7 @@ STOPSIGNAL SIGINT LABEL desc="Cardano Node by Guild's Operators" ARG DEBIAN_FRONTEND=noninteractive ARG G_ACCOUNT +ARG GUILD_DEPLOY_BRANCH USER root WORKDIR / @@ -45,7 +46,7 @@ RUN set -x && apt update \ && export SUDO='N' \ && export UPDATE_CHECK='N' \ && export SKIP_DBSYNC_DOWNLOAD='Y' \ - && chmod +x ./guild-deploy.sh && ./guild-deploy.sh -b master -s p \ + && chmod +x ./guild-deploy.sh && ./guild-deploy.sh -b ${GUILD_DEPLOY_BRANCH} -s p \ && ls /opt/ \ && mkdir -p $CNODE_HOME/priv/files \ && apt-get -y remove libpq-dev build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ \ @@ -58,14 +59,13 @@ RUN set -x && apt update \ RUN set -x && export SUDO='N' \ && export UPDATE_CHECK='N' \ && export SKIP_DBSYNC_DOWNLOAD='Y' \ - && ./guild-deploy.sh -b master -s dcowx \ + && ./guild-deploy.sh -b ${GUILD_DEPLOY_BRANCH} -s dcmowx \ && cd /usr/bin \ && wget http://www.vdberg.org/~richard/tcpping \ && chmod 755 tcpping \ - && chown -R guild:guild $CNODE_HOME/* \ + && chown -R guild:guild $CNODE_HOME \ && mv /root/.local/bin /home/guild/.local/ \ - && chown -R guild:guild /home/guild/.* \ - && chmod a+x /home/guild/.scripts/*.sh /opt/cardano/cnode/scripts/*.sh + && chown -R guild:guild /home/guild/.* # Add final tools in a separate layer to shrink the largest layer RUN apt-get update \ @@ -89,15 +89,18 @@ RUN curl -sL -H "Accept: application/vnd.github.everest-preview+json" -H "Conte # ENTRY SCRIPT -ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/banner.txt /home/guild/.scripts/ -ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/guild-topology.sh /home/guild/.scripts/ -ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/block_watcher.sh /home/guild/.scripts/ -ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/healthcheck.sh /home/guild/.scripts/ -ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/guild-deploy.sh /opt/cardano/cnode/scripts/ +ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/banner.txt \ + https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/guild-topology.sh \ + https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/block_watcher.sh \ + https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/healthcheck.sh /home/guild/.scripts/ +ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/guild-deploy.sh \ + https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/mithril-client.sh \ + https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/mithril-signer.sh \ + https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/mithril-relay.sh /opt/cardano/cnode/scripts/ ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/entrypoint.sh ./ RUN sudo chmod a+rx /home/guild/.scripts/*.sh /opt/cardano/cnode/scripts/*.sh /home/guild/entrypoint.sh \ - && sudo chown -R guild:guild /home/guild/.* $CNODE_HOME/* + && sudo chown -R guild:guild /home/guild/.* $CNODE_HOME HEALTHCHECK --start-period=5m --interval=5m --timeout=100s CMD /home/guild/.scripts/healthcheck.sh diff --git a/scripts/cnode-helper-scripts/cntools.library b/scripts/cnode-helper-scripts/cntools.library index a75e98c28..32d638aad 100644 --- a/scripts/cnode-helper-scripts/cntools.library +++ b/scripts/cnode-helper-scripts/cntools.library @@ -15,7 +15,7 @@ CNTOOLS_MAJOR_VERSION=11 # Minor: Changes and features of minor character that can be applied without breaking existing functionality or workflow CNTOOLS_MINOR_VERSION=0 # Patch: Backwards compatible bug fixes. No additional functionality or major changes -CNTOOLS_PATCH_VERSION=2 +CNTOOLS_PATCH_VERSION=3 CNTOOLS_VERSION="${CNTOOLS_MAJOR_VERSION}.${CNTOOLS_MINOR_VERSION}.${CNTOOLS_PATCH_VERSION}" @@ -841,31 +841,6 @@ verifyTx() { return 0 } -# Command : getPoolID [pool name] -# Description : create and save pool id in hex & bech32 encoded format -# Parameters : pool name > the name of the pool -# Return : populates ${pool_id} & ${pool_id_bech32} -getPoolID() { - pool_id_file="${POOL_FOLDER}/${1}/${POOL_ID_FILENAME}" - pool_id_bech32_file="${POOL_FOLDER}/${1}/${POOL_ID_FILENAME}-bech32" - [[ -f ${pool_id_file} && -f ${pool_id_bech32_file} ]] && pool_id=$(cat ${pool_id_file}) && pool_id_bech32=$(cat ${pool_id_bech32_file}) && return 0 - pool_id="" - pool_id_bech32="" - pool_coldkey_vk_file="${POOL_FOLDER}/${1}/${POOL_COLDKEY_VK_FILENAME}" - if [[ -f ${pool_coldkey_vk_file} ]]; then - println ACTION "${CCLI} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file} --output-format hex" - println ACTION "${CCLI} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file}" - if ! pool_id=$(${CCLI} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" --output-format hex 2>/dev/null) || \ - ! pool_id_bech32=$(${CCLI} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" 2>/dev/null); then - return 1 - fi - echo ${pool_id} > "${pool_id_file}" - echo ${pool_id_bech32} > "${pool_id_bech32_file}" - return 0 - fi - return 1 -} - # Command : getPayAddress [wallet name] # Description : create and save payment address # Parameters : wallet name > the name of the wallet @@ -2081,7 +2056,7 @@ deRegisterPool() { rotatePoolKeys() { # cold keys - if getPoolType ${pool_name} ; then needHWCLI="true" ;fi + if getPoolType ${pool_name}; then needHWCLI="true"; else needHWCLI="false" ;fi # generated files pool_hotkey_vk_file="${POOL_FOLDER}/${pool_name}/${POOL_HOTKEY_VK_FILENAME}" diff --git a/scripts/cnode-helper-scripts/env b/scripts/cnode-helper-scripts/env index 53c6ee5a5..9c5b9d93a 100644 --- a/scripts/cnode-helper-scripts/env +++ b/scripts/cnode-helper-scripts/env @@ -662,6 +662,20 @@ timeLeft() { printf '%02d:%02d:%02d' $H $M $S } +# Description : Format number in compact format, ie thousand = k, millon = m etc, with variable precision +# Return : populates ${cn_value} & ${cn_suffix} +compactNumber() { + unset cn_value cn_suffix + if [[ $# -ne 1 ]] || ! isNumber $1; then return 1; fi + if [[ $1 -gt 100000000 ]]; then LC_NUMERIC=C printf -v cn_value "%.0f" "$(echo "$1/1000000" | bc -l)"; cn_suffix=M; return; fi + if [[ $1 -gt 10000000 ]]; then LC_NUMERIC=C printf -v cn_value "%.1f" "$(echo "$1/1000000" | bc -l)"; cn_suffix=M; return; fi + if [[ $1 -gt 1000000 ]]; then LC_NUMERIC=C printf -v cn_value "%.2f" "$(echo "$1/1000000" | bc -l)"; cn_suffix=M; return; fi + if [[ $1 -gt 100000 ]]; then LC_NUMERIC=C printf -v cn_value "%.0f" "$(echo "$1/1000" | bc -l)"; cn_suffix=k; return; fi + if [[ $1 -gt 10000 ]]; then LC_NUMERIC=C printf -v cn_value "%.1f" "$(echo "$1/1000" | bc -l)"; cn_suffix=k; return; fi + if [[ $1 -gt 1000 ]]; then LC_NUMERIC=C printf -v cn_value "%.2f" "$(echo "$1/1000" | bc -l)"; cn_suffix=k; return; fi + cn_value=$1 +} + # Description : Get calculated slot number tip getSlotTipRef() { current_time_sec=$(printf '%(%s)T\n' -1) @@ -699,6 +713,32 @@ kesExpiration() { printf -v kes_expiration '%(%F %T %Z)T' ${expiration_time_sec} } +# Description : create and save pool id in hex & bech32 encoded format +# Parameters : pool name > the name of the pool +# Return : populates ${pool_id} & ${pool_id_bech32} +getPoolID() { + local pool_dir + [[ -z "${1}" ]] && pool_dir="${POOL_DIR}" || pool_dir="${POOL_FOLDER}/${1}" + pool_id_file="${pool_dir}/${POOL_ID_FILENAME}" + pool_id_bech32_file="${pool_dir}/${POOL_ID_FILENAME}-bech32" + [[ -f ${pool_id_file} && -f ${pool_id_bech32_file} ]] && pool_id=$(cat ${pool_id_file}) && pool_id_bech32=$(cat ${pool_id_bech32_file}) && return 0 + pool_id="" + pool_id_bech32="" + pool_coldkey_vk_file="${pool_dir}/${POOL_COLDKEY_VK_FILENAME}" + if [[ -f ${pool_coldkey_vk_file} ]]; then + println ACTION "${CCLI} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file} --output-format hex" + println ACTION "${CCLI} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file}" + if ! pool_id=$(${CCLI} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" --output-format hex 2>/dev/null) || \ + ! pool_id_bech32=$(${CCLI} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" 2>/dev/null); then + return 1 + fi + echo ${pool_id} > "${pool_id_file}" + echo ${pool_id_bech32} > "${pool_id_bech32_file}" + return 0 + fi + return 1 +} + # Description : Calculate expected interval between blocks slotInterval() { if [[ -z ${DECENTRALISATION} || $(echo "${DECENTRALISATION} < 0.5" | bc) -eq 1 ]]; then d=0.5; else d=${DECENTRALISATION}; fi diff --git a/scripts/cnode-helper-scripts/gLiveView.sh b/scripts/cnode-helper-scripts/gLiveView.sh index 61ac1b027..9a9f03665 100755 --- a/scripts/cnode-helper-scripts/gLiveView.sh +++ b/scripts/cnode-helper-scripts/gLiveView.sh @@ -7,24 +7,26 @@ # Common variables set in env file # ###################################### -NODE_NAME="Cardano Node" # Change your node's name prefix here, keep at or below 19 characters! -REFRESH_RATE=2 # How often (in seconds) to refresh the view (additional time for processing and output may slow it down) -LEGACY_MODE=false # (true|false) If enabled unicode box-drawing characters will be replaced by standard ASCII characters -RETRIES=3 # How many attempts to connect to running Cardano node before erroring out and quitting (0 for continuous retries) -PEER_LIST_CNT=10 # Number of peers to show on each in/out page in peer analysis view -THEME="dark" # dark = suited for terminals with a dark background +#NODE_NAME="Cardano Node" # Change your node's name prefix here, keep at or below 19 characters! +#REFRESH_RATE=2 # How often (in seconds) to refresh the view (additional time for processing and output may slow it down) +#REPAINT_RATE=10 # Re-paint entire screen every nth REFRESH_RATE. Complete re-paint can make screen flicker, hence not done for every update +#LEGACY_MODE=false # (true|false) If enabled unicode box-drawing characters will be replaced by standard ASCII characters +#RETRIES=3 # How many attempts to connect to running Cardano node before erroring out and quitting (0 for continuous retries) +#PEER_LIST_CNT=10 # Number of peers to show on each in/out page in peer analysis view +#THEME="dark" # dark = suited for terminals with a dark background # light = suited for terminals with a bright background -#ENABLE_IP_GEOLOCATION="Y" # Enable IP geolocation on outgoing and incoming connections using ip-api.com (default: Y) +#ENABLE_IP_GEOLOCATION=Y # Enable IP geolocation on outgoing and incoming connections using ip-api.com (default: Y) #LATENCY_TOOLS="cncli|ss|tcptraceroute|ping" # Preferred latency check tool order, valid entries: cncli|ss|tcptraceroute|ping (must be separated by |) #CNCLI_CONNECT_ONLY=false # By default cncli measure full connect handshake duration. If set to false, only connect is measured similar to other tools -#HIDE_DUPLICATE_IPS="N" # If set to 'Y', duplicate and local IP's will be filtered out in peer analysis, else all connected peers are shown (default: N) +#HIDE_DUPLICATE_IPS=N # If set to 'Y', duplicate and local IP's will be filtered out in peer analysis, else all connected peers are shown (default: N) +#VERBOSE=N # Start in verbose mode showing additional metrics (default: N) ##################################### # Themes # ##################################### setTheme() { - if [[ ${THEME} = "dark" ]]; then + if [[ -z ${THEME} || ${THEME} = "dark" ]]; then style_title=${FG_MAGENTA}${BOLD} # style of title style_base=${FG_WHITE} # default color for text and lines style_values_1=${FG_LBLUE} # color of most live values @@ -57,13 +59,10 @@ setTheme() { # Do NOT modify code below # ###################################### -GLV_VERSION=v1.27.6 +GLV_VERSION=v1.28.1 PARENT="$(dirname $0)" -# Set default for user variables added in recent versions (for those who may not necessarily have it due to upgrade) -[[ -z "${RETRIES}" ]] && RETRIES=3 - usage() { cat <<-EOF Usage: $(basename "$0") [-l] [-p] [-b ] [-v] @@ -172,10 +171,19 @@ fi # Can be overridden in 'User Variables' section above # ####################################################### +[[ -z ${NODE_NAME} ]] && NODE_NAME="Cardano Node" [[ ${#NODE_NAME} -gt 19 ]] && myExit 1 "Please keep node name at or below 19 characters in length!" +[[ -z ${REFRESH_RATE} ]] && REFRESH_RATE=2 [[ ! ${REFRESH_RATE} =~ ^[0-9]+$ ]] && myExit 1 "Please set a valid refresh rate number!" +[[ -z ${REPAINT_RATE} ]] && REPAINT_RATE=10 +[[ ! ${REPAINT_RATE} =~ ^[0-9]+$ ]] && myExit 1 "Please set a valid repaint rate number!" + +[[ -z ${LEGACY_MODE} ]] && LEGACY_MODE=false + +[[ -z "${RETRIES}" ]] && RETRIES=3 + [[ -z ${ENABLE_IP_GEOLOCATION} ]] && ENABLE_IP_GEOLOCATION=Y declare -gA geoIP=() [[ -f "$0.geodb" ]] && . -- "$0.geodb" @@ -188,6 +196,8 @@ declare -gA geoIP=() [[ -z ${HIDE_DUPLICATE_IPS} ]] && HIDE_DUPLICATE_IPS=N +[[ -z ${VERBOSE} ]] && VERBOSE=N + ####################################################### # Style / UI # ####################################################### @@ -289,6 +299,7 @@ waitForInput() { if [[ $# -eq 0 ]]; then [[ ${key1} = "p" ]] && check_peers="true" && clrScreen && return [[ ${key1} = "i" ]] && show_home_info="true" && clrScreen && return + if [[ ${key1} = "v" ]]; then [[ ${VERBOSE} = "N" ]] && VERBOSE="Y" || VERBOSE="N"; fi; clrScreen && return elif [[ $1 = "homeInfo" ]]; then [[ ${key1} = "h" ]] && show_home_info="false" && line=0 && clrScreen && return elif [[ $1 = "peersInfo" ]]; then @@ -385,9 +396,10 @@ clrLine () { printf "\033[K" } # Command : clrScreen -# Description: clear the screen, move to (0,0) +# Description: clear the screen, move to (0,0), and reset screen update counter clrScreen () { printf "\033[2J" + screen_upd_cnt=0 } # Description: latency helper functions @@ -437,6 +449,83 @@ getArrayIndex () { echo -1 } +getPoolInfo () { + # runs in background to not stall rest of gLiveView while fetching data + if ! pool_info=$(curl -sSL -f -X POST -H "Content-Type: application/json" -d '{"_pool_bech32_ids":["'${pool_id_bech32}'"]}' "${KOIOS_API}/pool_info" 2>&1); then + echo ${pool_info} > ${pool_info_error_file} + return + fi + [[ ${pool_info} = '[]' ]] && return + echo ${pool_info} > ${pool_info_file} +} + +parsePoolInfo () { + pool_info_tsv=$(jq -r '[ + .[0].active_epoch_no //0, + .[0].vrf_key_hash //"-", + .[0].margin //0, + .[0].fixed_cost //0, + .[0].pledge //0, + .[0].reward_addr //"-", + (.[0].owners|@json), + (.[0].relays|@json), + .[0].meta_url //"-", + .[0].meta_hash //"-", + (.[0].meta_json|@base64), + .[0].pool_status //"-", + .[0].retiring_epoch //"-", + .[0].op_cert //"-", + .[0].op_cert_counter //"null", + .[0].active_stake //0, + .[0].block_count //0, + .[0].live_pledge //0, + .[0].live_stake //0, + .[0].live_delegators //0, + .[0].live_saturation //0 + ] | @tsv' "${pool_info_file}") + + read -ra pool_info_arr <<< ${pool_info_tsv} + + p_active_epoch_no=${pool_info_arr[0]} + p_vrf_key_hash=${pool_info_arr[1]} + p_margin=${pool_info_arr[2]} + p_fixed_cost=${pool_info_arr[3]} + p_pledge=${pool_info_arr[4]} + p_reward_addr=${pool_info_arr[5]} + p_owners=${pool_info_arr[6]} + p_relays=${pool_info_arr[7]} + p_meta_url=${pool_info_arr[8]} + p_meta_hash=${pool_info_arr[9]} + p_meta_json=$(base64 -d <<< ${pool_info_arr[10]}) + p_pool_status=${pool_info_arr[11]} + p_retiring_epoch=${pool_info_arr[12]} + p_op_cert=${pool_info_arr[13]} + p_op_cert_counter=${pool_info_arr[14]} + p_active_stake=${pool_info_arr[15]} + p_block_count=${pool_info_arr[16]} + p_live_pledge=${pool_info_arr[17]} + p_live_stake=${pool_info_arr[18]} + p_live_delegators=${pool_info_arr[19]} + p_live_saturation=${pool_info_arr[20]} + + rm ${pool_info_file} +} + +getOpCert () { + op_cert_disk="?" + op_cert_node="?" + opcert_file="${POOL_DIR}/${POOL_OPCERT_FILENAME}" + if [[ -f ${opcert_file} ]]; then + op_cert_tsv=$(jq -r '[ + .qKesNodeStateOperationalCertificateNumber //"?", + .qKesOnDiskOperationalCertificateNumber //"?" + ] | @tsv' <<<"$(${CCLI} query kes-period-info ${NETWORK_IDENTIFIER} --op-cert-file "${opcert_file}" | tail -n +3)") + read -ra op_cert_arr <<< ${op_cert_tsv} + isNumber ${op_cert_arr[0]} && op_cert_node=${op_cert_arr[0]} + isNumber ${op_cert_arr[1]} && op_cert_disk=${op_cert_arr[1]} + fi +} + # Command : checkPeers # Description: Check peer connections # Inspired by ping script from Martin @ ATADA pool @@ -627,6 +716,14 @@ node_version=$(grep "cardano-node" <<< "${version}" | cut -d ' ' -f2) node_rev=$(grep "git rev" <<< "${version}" | cut -d ' ' -f3 | cut -c1-8) fail_count=0 epoch_items_last=0 +screen_upd_cnt=0 + +test_koios # KOIOS_API variable unset if check fails. Only tested once on startup. +pool_info_file=/dev/shm/pool_info +pool_info_error_file=/dev/shm/pool_info_error +[[ -n ${KOIOS_API} ]] && getPoolID + +getOpCert tput civis # Disable cursor stty -echo # Disable user input @@ -686,6 +783,7 @@ while true; do node_version=$(grep "cardano-node" <<< "${version}" | cut -d ' ' -f2) node_rev=$(grep "git rev" <<< "${version}" | cut -d ' ' -f3 | cut -c1-8) fail_count=0 + getOpCert fi if [[ -z "${PROT_PARAMS}" ]]; then @@ -706,16 +804,16 @@ while true; do fi mem_rss="$(ps -q ${CNODE_PID} -o rss=)" - read -ra cpu_now <<< "$(awk '/cpu /{printf "%.f %.f", $2+$4,$2+$4+$5}' /proc/stat)" + read -ra cpu_now <<< "$(LC_NUMERIC=C awk '/cpu /{printf "%.f %.f", $2+$4,$2+$4+$5}' /proc/stat)" if [[ ${#cpu_now[@]} -eq 2 ]]; then if [[ ${#cpu_last[@]} -eq 2 ]]; then cpu_util=$(bc -l <<< "100*((${cpu_now[0]}-${cpu_last[0]})/(${cpu_now[1]}-${cpu_last[1]}))") if [[ ${cpu_util%.*} -gt 99 ]]; then - cpu_util=$(printf "%.0f" "${cpu_util}") + cpu_util=$(LC_NUMERIC=C printf "%.0f" "${cpu_util}") elif [[ ${cpu_util%.*} -gt 9 ]]; then - cpu_util=$(printf "%.1f" "${cpu_util}") + cpu_util=$(LC_NUMERIC=C printf "%.1f" "${cpu_util}") else - cpu_util=$(printf "%.2f" "${cpu_util}") + cpu_util=$(LC_NUMERIC=C printf "%.2f" "${cpu_util}") fi else cpu_util="0.0" @@ -739,6 +837,25 @@ while true; do curr_epoch=${epochnum} PROT_PARAMS="$(${CCLI} query protocol-parameters ${NETWORK_IDENTIFIER} 2>/dev/null)" if [[ -n "${PROT_PARAMS}" ]] && ! DECENTRALISATION=$(jq -re .decentralization <<< ${PROT_PARAMS} 2>/dev/null); then DECENTRALISATION=0.5; fi + unset pool_info_last_upd + fi + if [[ ${nodemode} = "Core" ]]; then + if [[ -n ${KOIOS_API} && -n ${pool_id_bech32} ]]; then + if [[ -n ${pool_info_last_upd} && $(($(date -u +%s) - pool_info_last_upd)) -lt 3600 ]]; then + : # nothing to do, pool info already fetched, processed and under 1h old + elif [[ -f ${pool_info_error_file} ]]; then + clrScreen && mvPos 2 2 + printf "${style_status_3}%s${NC}" "$(cat ${pool_info_error_file})" + rm ${pool_info_error_file} + waitToProceed && continue + elif [[ -f ${pool_info_file} ]]; then + parsePoolInfo + pool_info_last_upd=$(date -u +%s) + clrScreen + else + getPoolInfo & # background process to not stall UI + fi + fi fi fi @@ -932,7 +1049,7 @@ while true; do else epoch_progress=$(echo "(${slot_in_epoch}/${BYRON_EPOCH_LENGTH})*100" | bc -l) # in Byron era fi - epoch_progress_1dec=$(printf "%2.1f" "${epoch_progress}") + epoch_progress_1dec=$(LC_NUMERIC=C printf "%2.1f" "${epoch_progress}") epoch_time_left=$(timeLeft "$(timeUntilNextEpoch)") printf "${VL} Epoch ${style_values_1}%s${NC} [${style_values_1}%s%%${NC}], ${style_values_1}%s${NC} %-12s" "${epochnum}" "${epoch_progress_1dec}" "${epoch_time_left}" "remaining" closeRow @@ -972,7 +1089,7 @@ while true; do printf "Tip (diff) : ${style_status_2}%-${three_col_2_value_width}s${NC}" "${tip_diff} :|" else sync_progress=$(echo "(${slotnum}/${tip_ref})*100" | bc -l) - printf "Syncing : ${style_info}%-${three_col_2_value_width}s${NC}" "$(printf "%2.1f" "${sync_progress}")%" + printf "Syncing : ${style_info}%-${three_col_2_value_width}s${NC}" "$(LC_NUMERIC=C printf "%2.1f" "${sync_progress}")%" fi mvThreeThird printf "Total Tx : ${style_values_1}%-${three_col_1_value_width}s${NC}" "${tx_processed}" @@ -1029,54 +1146,91 @@ while true; do echo "${propdivider}" && ((line++)) - # row 1 - printf -v block_delay_rounded "%.2f" ${block_delay} - printf "${VL} Last Delay : ${style_values_1}%s${NC}%-$((three_col_1_value_width - ${#block_delay_rounded}))s" "${block_delay_rounded}" "s" - mvThreeSecond - printf "Served : ${style_values_1}%-${three_col_2_value_width}s${NC}" "${blocks_served}" - mvThreeThird - printf "Late (>5s) : ${style_values_1}%-${three_col_3_value_width}s${NC}" "${blocks_late}" - closeRow + LC_NUMERIC=C printf -v block_delay_rounded "%.2f" ${block_delay} + [[ ${blocks_w1s} = 1.* ]] && blocks_w1s_pct=100 || LC_NUMERIC=C printf -v blocks_w1s_pct "%.2f" "$(bc -l <<<"(${blocks_w1s}*100)")" + [[ ${blocks_w3s} = 1.* ]] && blocks_w3s_pct=100 || LC_NUMERIC=C printf -v blocks_w3s_pct "%.2f" "$(bc -l <<<"(${blocks_w3s}*100)")" + [[ ${blocks_w5s} = 1.* ]] && blocks_w5s_pct=100 || LC_NUMERIC=C printf -v blocks_w5s_pct "%.2f" "$(bc -l <<<"(${blocks_w5s}*100)")" - # row 2 - printf -v blocks_w1s_pct "%.2f" "$(bc -l <<<"(${blocks_w1s}*100)")" - printf "${VL} Within 1s : ${style_values_1}%s${NC}%-$((three_col_1_value_width - ${#blocks_w1s_pct}))s" "${blocks_w1s_pct}" "%" - mvThreeSecond - printf -v blocks_w3s_pct "%.2f" "$(bc -l <<<"(${blocks_w3s}*100)")" - printf "Within 3s : ${style_values_1}%s${NC}%-$((three_col_2_value_width - ${#blocks_w3s_pct}))s" "${blocks_w3s_pct}" "%" - mvThreeThird - printf -v blocks_w5s_pct "%.2f" "$(bc -l <<<"(${blocks_w5s}*100)")" - printf "Within 5s : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#blocks_w5s_pct}))s" "${blocks_w5s_pct}" "%" - closeRow + if [[ ${VERBOSE} = "Y" ]]; then + + # row 1 + printf "${VL} Last Block : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#block_delay_rounded}))s" "${block_delay_rounded}" "s" + mvThreeSecond + printf "Served : ${style_values_1}%s${NC}" "${blocks_served}" + mvThreeThird + printf "Late (>5s) : ${style_values_1}%s${NC}" "${blocks_late}" + closeRow + + # row 2 + printf "${VL} Within 1s : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#blocks_w1s_pct}))s" "${blocks_w1s_pct}" "%" + mvThreeSecond + printf "Within 3s : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#blocks_w3s_pct}))s" "${blocks_w3s_pct}" "%" + mvThreeThird + printf "Within 5s : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#blocks_w5s_pct}))s" "${blocks_w5s_pct}" "%" + closeRow + + else + + # row 1 + printf "${VL} Last Block : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#block_delay_rounded}))s" "${block_delay_rounded}" "s" + mvThreeSecond + blocks_w5s_value_width=$(( (three_col_width*2) - 23 - 6 - ${#blocks_w1s_pct} - ${#blocks_w3s_pct} )) + printf "Less than 1|3|5s [%%] : ${style_values_1}%s${NC} | ${style_values_1}%s${NC} | ${style_values_1}%-${blocks_w5s_value_width}s${NC}" "${blocks_w1s_pct}" "${blocks_w3s_pct}" "${blocks_w5s_pct}" + closeRow + + fi echo "${resourcesdivider}" && ((line++)) - # row 1 - printf "${VL} CPU (sys) : ${style_values_1}%s${NC}%-$((three_col_1_value_width - ${#cpu_util}))s" "${cpu_util}" "%" - mvThreeSecond - printf -v mem_live_gb "%.1f" "$(bc -l <<<"(${mem_live}/1073741824)")" - printf "Mem (Live) : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#mem_live_gb}))s" "${mem_live_gb}" "G" - mvThreeThird - printf "GC Minor : ${style_values_1}%-${three_col_3_value_width}s${NC}" "${gc_minor}" - closeRow + LC_NUMERIC=C printf -v mem_rss_gb "%.1f" "$(bc -l <<<"(${mem_rss}/1048576)")" + [[ $(df -h ${CNODE_HOME}) =~ ([0-9.]+)% ]] && disk_usage=${BASH_REMATCH[1]} || disk_usage="?" - # row 2 - printf -v mem_rss_gb "%.1f" "$(bc -l <<<"(${mem_rss}/1048576)")" - printf "${VL} Mem (RSS) : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#mem_rss_gb}))s" "${mem_rss_gb}" "G" - mvThreeSecond - printf -v mem_heap_gb "%.1f" "$(bc -l <<<"(${mem_heap}/1073741824)")" - printf "Mem (Heap) : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#mem_heap_gb}))s" "${mem_heap_gb}" "G" - mvThreeThird - printf "GC Major : ${style_values_1}%-${three_col_3_value_width}s${NC}" "${gc_major}" - closeRow + if [[ ${VERBOSE} = "Y" ]]; then + + LC_NUMERIC=C printf -v mem_live_gb "%.1f" "$(bc -l <<<"(${mem_live}/1073741824)")" + LC_NUMERIC=C printf -v mem_heap_gb "%.1f" "$(bc -l <<<"(${mem_heap}/1073741824)")" + + # row 1 + printf "${VL} CPU (sys) : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#cpu_util}))s" "${cpu_util}" "%" + mvThreeSecond + printf "Mem (RSS) : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#mem_rss_gb}))s" "${mem_rss_gb}" "G" + mvThreeThird + printf "GC Minor : ${style_values_1}%s${NC}" "${gc_minor}" + closeRow + + # row 2 + printf "${VL} Disk util : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#disk_usage}))s" "${disk_usage}" "%" + mvThreeSecond + printf "Mem (Live) : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#mem_live_gb}))s" "${mem_live_gb}" "G" + mvThreeThird + printf "GC Major : ${style_values_1}%s${NC}" "${gc_major}" + closeRow + + # row 3 + printf "${VL}" + mvThreeSecond + printf "Mem (Heap) : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#mem_heap_gb}))s" "${mem_heap_gb}" "G" + closeRow + + else + + # row 1 + printf "${VL} CPU (sys) : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#cpu_util}))s" "${cpu_util}" "%" + mvThreeSecond + printf "Mem (RSS) : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#mem_rss_gb}))s" "${mem_rss_gb}" "G" + mvThreeThird + printf "Disk util : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#disk_usage}))s" "${disk_usage}" "%" + closeRow + + fi ## Core section ## if [[ ${nodemode} = "Core" ]]; then echo "${coredivider}" && ((line++)) - printf "${VL} KES current/remaining" + printf "${VL} KES current|remaining|exp" mvTwoSecond - printf ": ${style_values_1}%s${NC} / " "${kesperiod}" + printf ": ${style_values_1}%s${NC} | " "${kesperiod}" if [[ ${remaining_kes_periods} -le 0 ]]; then printf "${style_status_4}%s${NC}" "${remaining_kes_periods}" elif [[ ${remaining_kes_periods} -le 8 ]]; then @@ -1084,16 +1238,67 @@ while true; do else printf "${style_values_1}%s${NC}" "${remaining_kes_periods}" fi + [[ ${kes_expiration} =~ (.+[0-9]+:[0-9]+):[0-9]+(.*) ]] && kes_expiration_nosec="${BASH_REMATCH[1]}${BASH_REMATCH[2]}" || kes_expiration_nosec="?" + printf " | ${style_values_1}%s${NC}" "${kes_expiration_nosec}" closeRow - printf "${VL} KES expiration date" + # OP Cert + if isNumber ${p_op_cert_counter}; then + op_cert_chain=${p_op_cert_counter} + if isNumber ${op_cert_disk} && [[ ${op_cert_disk} -ge ${op_cert_chain} && ${op_cert_disk} -le $((op_cert_chain+1)) ]]; then op_cert_disk_fmt="${style_values_1}"; else op_cert_disk_fmt="${style_status_3}"; fi + if isNumber ${op_cert_node} && [[ ${op_cert_node} -ge ${op_cert_chain} && ${op_cert_node} -le $((op_cert_chain+1)) ]]; then op_cert_node_fmt="${style_values_1}"; else op_cert_node_fmt="${style_status_3}"; fi + else + op_cert_chain="?" + if isNumber ${op_cert_disk}; then op_cert_disk_fmt="${style_values_1}"; else op_cert_disk_fmt="${style_values_3}"; fi + if isNumber ${op_cert_node}; then op_cert_node_fmt="${style_values_1}"; else op_cert_node_fmt="${style_values_3}"; fi + fi + printf "${VL} OP Cert disk|node|chain" mvTwoSecond - printf ": ${style_values_1}%-${two_col_width}s${NC}" "${kes_expiration}" && closeRow + printf ": ${op_cert_disk_fmt}%s${NC} | ${op_cert_node_fmt}%s${NC} | ${style_values_1}%s${NC}" "${op_cert_disk}" "${op_cert_node}" "${op_cert_chain}" + closeRow - printf "${VL} Missed slot leader checks" - mvTwoSecond - printf -v missed_slots_pct "%.4f" "$(bc -l <<<"(${missed_slots}/(${about_to_lead}+${missed_slots}))*100")" - printf ": ${style_values_1}%s${NC} (${style_values_1}%s${NC} %%)" "${missed_slots}" "${missed_slots_pct}" && closeRow + if [[ ${VERBOSE} = "Y" ]]; then + printf "${VL} Missed slot leader checks" + mvTwoSecond + LC_NUMERIC=C printf -v missed_slots_pct "%.4f" "$(bc -l <<<"(${missed_slots}/(${about_to_lead}+${missed_slots}))*100")" + printf ": ${style_values_1}%s${NC} (${style_values_1}%s${NC} %%)" "${missed_slots}" "${missed_slots_pct}" + closeRow + fi + + if [[ -n ${p_active_stake} ]]; then + + # row 1 + printf "${VL} Blocks : ${style_values_1}%s${NC}" "${p_block_count}" + mvThreeSecond + compactNumber $((p_active_stake/1000000)) + printf "Act Stake : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#cn_value}))s" "${cn_value}" "${cn_suffix}" + mvThreeThird + compactNumber $((p_pledge/1000000)) + printf "Pledge : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#cn_value}))s" "${cn_value}" "${cn_suffix}" + closeRow + + # row 2 + compactNumber $((p_fixed_cost/1000000)) + printf "${VL} Fixed Fee : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#cn_value}))s" "${cn_value}" "${cn_suffix}" + mvThreeSecond + compactNumber $((p_live_stake/1000000)) + printf "Live Stake : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#cn_value}))s" "${cn_value}" "${cn_suffix}" + mvThreeThird + [[ ${p_live_pledge} -ge ${p_pledge} ]] && p_live_pledge_fmt="${style_values_1}" || p_live_pledge_fmt="${style_status_3}" + compactNumber $((p_live_pledge/1000000)) + printf "Live Pledge: ${p_live_pledge_fmt}%s${NC}%-$((three_col_3_value_width - ${#cn_value}))s" "${cn_value}" "${cn_suffix}" + closeRow + + # row 3 + margin_fee=$(fractionToPCT ${p_margin}) + ! validateDecimalNbr ${margin_fee} && margin_fee="?" + printf "${VL} Margin Fee : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#margin_fee}))s" "${margin_fee}" "%" + mvThreeSecond + printf "Delegators : ${style_values_1}%-${three_col_3_value_width}s${NC}" "${p_live_delegators}" + mvThreeThird + printf "Saturation : ${style_values_1}%s${NC}%-$((three_col_3_value_width - ${#p_live_saturation}))s" "${p_live_saturation}" "%" + closeRow + fi printf "${blockdivider}\n" && ((line++)) @@ -1112,40 +1317,66 @@ while true; do esac done adopted_cnt=$(( adopted_cnt + confirmed_cnt )) - leader_cnt=$(( leader_cnt + adopted_cnt + invalid_cnt + missed_cnt + ghosted_cnt + stolen_cnt )) + lost_cnt=$(( invalid_cnt + missed_cnt + ghosted_cnt + stolen_cnt )) + leader_cnt=$(( leader_cnt + adopted_cnt + lost_cnt )) leader_next=$(sqlite3 "${BLOCKLOG_DB}" "SELECT at FROM blocklog WHERE datetime(at) > datetime('now') ORDER BY slot ASC LIMIT 1;" 2>/dev/null) IFS='|' read -ra epoch_stats <<< "$(sqlite3 "${BLOCKLOG_DB}" "SELECT epoch_slots_ideal, max_performance FROM epochdata WHERE epoch=${epochnum};" 2>/dev/null)"; unset IFS if [[ ${#epoch_stats[@]} -eq 0 ]]; then epoch_stats=("-" "-"); else epoch_stats[1]="${epoch_stats[1]}%"; fi - [[ ${invalid_cnt} -eq 0 ]] && invalid_fmt="${style_values_1}" || invalid_fmt="${style_status_3}" - [[ ${missed_cnt} -eq 0 ]] && missed_fmt="${style_values_1}" || missed_fmt="${style_status_3}" - [[ ${ghosted_cnt} -eq 0 ]] && ghosted_fmt="${style_values_1}" || ghosted_fmt="${style_status_3}" - [[ ${stolen_cnt} -eq 0 ]] && stolen_fmt="${style_values_1}" || stolen_fmt="${style_status_3}" [[ ${confirmed_cnt} -ne ${adopted_cnt} ]] && confirmed_fmt="${style_status_2}" || confirmed_fmt="${style_values_2}" - # row 1 - printf "${VL} Leader : ${style_values_1}%-${three_col_1_value_width}s${NC}" "${leader_cnt}" - mvThreeSecond - printf "Adopted : ${style_values_1}%-${three_col_2_value_width}s${NC}" "${adopted_cnt}" - mvThreeThird - printf "Missed : ${missed_fmt}%-${three_col_3_value_width}s${NC}" "${missed_cnt}" - closeRow + if [[ ${VERBOSE} = "Y" ]]; then + + [[ ${invalid_cnt} -eq 0 ]] && invalid_fmt="${style_values_1}" || invalid_fmt="${style_status_3}" + [[ ${missed_cnt} -eq 0 ]] && missed_fmt="${style_values_1}" || missed_fmt="${style_status_3}" + [[ ${ghosted_cnt} -eq 0 ]] && ghosted_fmt="${style_values_1}" || ghosted_fmt="${style_status_3}" + [[ ${stolen_cnt} -eq 0 ]] && stolen_fmt="${style_values_1}" || stolen_fmt="${style_status_3}" + + # row 1 + printf "${VL} Leader : ${style_values_1}%-${three_col_1_value_width}s${NC}" "${leader_cnt}" + mvThreeSecond + printf "Adopted : ${style_values_1}%-${three_col_2_value_width}s${NC}" "${adopted_cnt}" + mvThreeThird + printf "Missed : ${missed_fmt}%-${three_col_3_value_width}s${NC}" "${missed_cnt}" + closeRow + + # row 2 + printf "${VL} Ideal : ${style_values_1}%-${three_col_1_value_width}s${NC}" "${epoch_stats[0]}" + mvThreeSecond + printf "Confirmed : ${confirmed_fmt}%-${three_col_2_value_width}s${NC}" "${confirmed_cnt}" + mvThreeThird + printf "Ghosted : ${ghosted_fmt}%-${three_col_3_value_width}s${NC}" "${ghosted_cnt}" + closeRow + + # row 3 + printf "${VL} Luck : ${style_values_1}%-${three_col_1_value_width}s${NC}" "${epoch_stats[1]}" + mvThreeSecond + printf "Invalid : ${invalid_fmt}%-${three_col_2_value_width}s${NC}" "${invalid_cnt}" + mvThreeThird + printf "Stolen : ${stolen_fmt}%-${three_col_3_value_width}s${NC}" "${stolen_cnt}" + closeRow - # row 2 - printf "${VL} Ideal : ${style_values_1}%-${three_col_1_value_width}s${NC}" "${epoch_stats[0]}" - mvThreeSecond - printf "Confirmed : ${confirmed_fmt}%-${three_col_2_value_width}s${NC}" "${confirmed_cnt}" - mvThreeThird - printf "Ghosted : ${ghosted_fmt}%-${three_col_3_value_width}s${NC}" "${ghosted_cnt}" - closeRow + else - # row 3 - printf "${VL} Luck : ${style_values_1}%-${three_col_1_value_width}s${NC}" "${epoch_stats[1]}" - mvThreeSecond - printf "Invalid : ${invalid_fmt}%-${three_col_2_value_width}s${NC}" "${invalid_cnt}" - mvThreeThird - printf "Stolen : ${stolen_fmt}%-${three_col_3_value_width}s${NC}" "${stolen_cnt}" - closeRow + [[ ${lost_cnt} -eq 0 ]] && lost_fmt="${style_values_1}" || lost_fmt="${style_status_3}" + + # row 1 + printf "${VL} Leader : ${style_values_1}%-${three_col_1_value_width}s${NC}" "${leader_cnt}" + mvThreeSecond + printf "Luck : ${style_values_1}%-${three_col_1_value_width}s${NC}" "${epoch_stats[1]}" + mvThreeThird + printf "Confirmed : ${confirmed_fmt}%-${three_col_2_value_width}s${NC}" "${confirmed_cnt}" + closeRow + + # row 2 + printf "${VL} Ideal : ${style_values_1}%-${three_col_1_value_width}s${NC}" "${epoch_stats[0]}" + mvThreeSecond + printf "Adopted : ${style_values_1}%-${three_col_2_value_width}s${NC}" "${adopted_cnt}" + mvThreeThird + printf "Lost : ${lost_fmt}%-${three_col_2_value_width}s${NC}" "${lost_cnt}" + closeRow + + fi if [[ -n ${leader_next} ]]; then leader_time_left=$(( $(date -u -d ${leader_next} +%s) - $(printf '%(%s)T\n' -1) )) @@ -1153,16 +1384,16 @@ while true; do setSizeAndStyleOfProgressBar ${leader_time_left} leader_time_left_fmt="$(timeLeft ${leader_time_left})" leader_progress=$(echo "(1-(${leader_time_left}/${leader_bar_span}))*100" | bc -l) - leader_items=$(( ($(printf %.0f "${leader_progress}") * granularity) / 100 )) - printf "${m3divider}\n" && ((line++)) - printf "${VL} ${style_values_1}%s${NC} until leader " "${leader_time_left_fmt}" && closeRow + leader_items=$(( ($(printf %.0f "${leader_progress}") * granularity_small) / 100 )) + printf "${VL} Next block : ${style_values_1}%-$((two_col_width-14))s${NC}" "${leader_time_left_fmt}" + mvPos ${line} ${bar_col_small} if [[ -z ${leader_bar} || ${leader_items} -ne ${leader_items_last} ]]; then leader_bar=""; leader_items_last=${leader_items} - for i in $(seq 0 $((granularity-1))); do + for i in $(seq 0 $((granularity_small-1))); do [[ $i -lt ${leader_items} ]] && leader_bar+=$(printf "${leader_bar_style}${char_marked}") || leader_bar+=$(printf "${NC}${char_unmarked}") done fi - printf "${VL} ${leader_bar}" && closeRow + printf "${leader_bar}" && closeRow fi fi else @@ -1199,8 +1430,11 @@ while true; do clrLine waitForInput "homeInfo" else - printf " ${style_info}[esc/q] Quit${NC} | ${style_info}[i] Info${NC} | ${style_info}[p] Peer Analysis${NC}" + [[ ${VERBOSE} = "Y" ]] && verbose_label="Compact" || verbose_label="Verbose" + printf " ${style_info}[esc/q] Quit${NC} | ${style_info}[i] Info${NC} | ${style_info}[p] Peer Analysis${NC} | ${style_info}[v] ${verbose_label}${NC}" clrLine waitForInput fi + + [[ $((++screen_upd_cnt)) -gt ${REPAINT_RATE} ]] && clrScreen done diff --git a/scripts/cnode-helper-scripts/guild-deploy.sh b/scripts/cnode-helper-scripts/guild-deploy.sh index 3aaf4b005..889b50cf6 100755 --- a/scripts/cnode-helper-scripts/guild-deploy.sh +++ b/scripts/cnode-helper-scripts/guild-deploy.sh @@ -216,10 +216,8 @@ os_dependencies() { if [[ "${DISTRO}" =~ Rocky ]]; then #RockyLinux 8/9 pkg_list="${pkg_list} --enablerepo=devel,crb libusbx ncurses-compat-libs pkgconf-pkg-config" - elif [[ "${DISTRO}" =~ "Red Hat" ]] || [[ "${VERSION_ID}" =~ "8" ]]; then - pkg_list="${pkg_list} --enablerepo=codeready-builder-for-rhel-8-x86_64-rpms libusbx ncurses-compat-libs pkgconf-pkg-config" - elif [[ "${DISTRO}" =~ "Red Hat" ]] || [[ "${VERSION_ID}" =~ "9" ]]; then - pkg_list="${pkg_list} --enablerepo=codeready-builder-for-rhel-9-x86_64-rpms libusbx ncurses-compat-libs pkgconf-pkg-config" + elif [[ "${DISTRO}" =~ "Red Hat" ]]; then + pkg_list="${pkg_list} --enablerepo=codeready-builder-for-rhel-${VERSION_ID/.*/}-x86_64-rpms libusbx ncurses-compat-libs pkgconf-pkg-config" fi elif [[ "${DISTRO}" =~ Fedora ]]; then #Fedora @@ -431,7 +429,7 @@ download_ogmios() { if command -v ogmios >/dev/null; then ogmios_version="$(ogmios --version)"; else ogmios_version="v0.0.0"; fi rm -rf /tmp/ogmios && mkdir /tmp/ogmios pushd /tmp/ogmios >/dev/null || err_exit - ogmios_asset_url="$(curl -s https://api.github.com/repos/CardanoSolutions/ogmios/releases | jq -r '.[0].assets[].browser_download_url')" + ogmios_asset_url="$(curl -s https://api.github.com/repos/CardanoSolutions/ogmios/releases | jq -r '.[].assets[].browser_download_url' | grep linux.zip | head -1)" if curl -sL -f -m ${CURL_TIMEOUT} -o ogmios.zip ${ogmios_asset_url}; then unzip ogmios.zip &>/dev/null rm -f ogmios.zip diff --git a/scripts/cnode-helper-scripts/mithril-client.sh b/scripts/cnode-helper-scripts/mithril-client.sh index 728261746..49c3bc124 100755 --- a/scripts/cnode-helper-scripts/mithril-client.sh +++ b/scripts/cnode-helper-scripts/mithril-client.sh @@ -15,6 +15,9 @@ # Do NOT modify code below # ###################################### +U_ID=$(id -u) +G_ID=$(id -g) + ##################### # Functions # ##################### @@ -34,6 +37,10 @@ usage() { generate_environment_file() { + if [[ ! -d "${CNODE_HOME}/mithril/data-stores" ]]; then + sudo mkdir -p "${CNODE_HOME}"/mithril/data-stores + sudo chown -R "$U_ID":"$G_ID" "${CNODE_HOME}"/mithril 2>/dev/null + fi if [[ -n "${POOL_NAME}" ]] && [[ "${POOL_NAME}" != "CHANGE_ME" ]]; then export ERA_READER_ADDRESS=https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/${RELEASE}-${NETWORK_NAME,,}/era.addr export ERA_READER_VKEY=https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/${RELEASE}-${NETWORK_NAME,,}/era.vkey @@ -169,6 +176,10 @@ while getopts :duh opt; do usage exit 1 ;; + *) + usage + exit 1 + ;; esac done diff --git a/scripts/cnode-helper-scripts/mithril-relay.sh b/scripts/cnode-helper-scripts/mithril-relay.sh index c395c232d..6c104fddf 100755 --- a/scripts/cnode-helper-scripts/mithril-relay.sh +++ b/scripts/cnode-helper-scripts/mithril-relay.sh @@ -208,6 +208,10 @@ while getopts :dlh opt; do usage exit 1 ;; + *) + usage + exit 1 + ;; esac done diff --git a/scripts/cnode-helper-scripts/mithril-signer.sh b/scripts/cnode-helper-scripts/mithril-signer.sh index cd5090743..dd93187de 100755 --- a/scripts/cnode-helper-scripts/mithril-signer.sh +++ b/scripts/cnode-helper-scripts/mithril-signer.sh @@ -16,6 +16,9 @@ # Do NOT modify code below # ###################################### +U_ID=$(id -u) +G_ID=$(id -g) + ##################### # Functions # ##################### @@ -71,6 +74,10 @@ get_relay_endpoint() { } generate_environment_file() { + if [[ ! -d "${CNODE_HOME}/mithril/data-stores" ]]; then + sudo mkdir -p "${CNODE_HOME}"/mithril/data-stores + sudo chown -R "$U_ID":"$G_ID" "${CNODE_HOME}"/mithril 2>/dev/null + fi # Inquire about the relay endpoint read -r -p "Are you using a relay endpoint? (y/n, press Enter to use default y): " ENABLE_RELAY_ENDPOINT ENABLE_RELAY_ENDPOINT=${ENABLE_RELAY_ENDPOINT:-y} diff --git a/scripts/grest-helper-scripts/setup-grest.sh b/scripts/grest-helper-scripts/setup-grest.sh index d1625a9d1..4261e4d03 100755 --- a/scripts/grest-helper-scripts/setup-grest.sh +++ b/scripts/grest-helper-scripts/setup-grest.sh @@ -58,7 +58,7 @@ SGVERSION=v1.1.0rc fi checkUpdate env N N N - [[ $? -eq 2 ]] && print"\nERROR: Failed to check updates from github against specified branch\n" && exit 1 + [[ $? -eq 2 ]] && printf "\nERROR: Failed to check updates from github against specified branch\n" && exit 1 checkUpdate setup-grest.sh Y N N grest-helper-scripts case $? in