Skip to content

Commit

Permalink
gLiveView 1.28.0 - Tighter integration with Koios (#1705)
Browse files Browse the repository at this point in the history
## Description
<!--- Describe your changes -->

### cntools.library
- getPoolID moved to env
- Fix for CNTools Rotate Keys when using HW CLI

### env
- New compactNumber function
- getPoolID from `cntools.library`

### gLiveView.sh
- New user param `REPAINT_RATE` that will refresh entire screen every
nth `REFRESH_RATE`.
- New user param `VERBOSE` to set a default value for verbose flag. Used
to show/hide additional metrics not normally of interest. Can also be
toggled live with `v`.
- Block propagation now a single line in compact mode with some metrics
reserved for verbose mode.
  - GC and some memory metrics now only visible in verbose mode.
  - Missed slot leader checks moved to verbose mode.
  - Various pool metrics made more compact.
- Added disk utilization metric for CNODE_HOME path
- Koios:
- Pool info metrics fetched and shown. Fetched in background to not
stall UI loading on startup. Takes a couple of seconds before shown.
Updated on epoch change or every 1h if left open.
  - OP cert disk | node | chain metrics added.

---------

Co-authored-by: Scitz0 <[email protected]>
  • Loading branch information
rdlrt and Scitz0 authored Nov 20, 2023
1 parent 7f8ca9b commit 886d1a0
Show file tree
Hide file tree
Showing 4 changed files with 370 additions and 123 deletions.
29 changes: 2 additions & 27 deletions scripts/cnode-helper-scripts/cntools.library
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down
38 changes: 38 additions & 0 deletions scripts/cnode-helper-scripts/env
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -699,6 +713,30 @@ 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() {
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
}
# 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
Expand Down
Loading

0 comments on commit 886d1a0

Please sign in to comment.