From 38c92dfb92c06de4b789f818404a5fd7ef9998e0 Mon Sep 17 00:00:00 2001 From: rdlrt <3169068+rdlrt@users.noreply.github.com> Date: Sat, 20 Jan 2024 11:48:24 +1100 Subject: [PATCH] - Move node version check to be earlier ( to avoid CLI reporting invalid 'latest' argument in previous version) - Move function definitions to be earlier than statements --- scripts/cnode-helper-scripts/env | 59 +++++++++++---------- scripts/grest-helper-scripts/setup-grest.sh | 2 +- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/scripts/cnode-helper-scripts/env b/scripts/cnode-helper-scripts/env index 6769b8fce..d19380011 100644 --- a/scripts/cnode-helper-scripts/env +++ b/scripts/cnode-helper-scripts/env @@ -105,7 +105,7 @@ is_dir() { # Description : Check higher of two versions # : $1=minimal_needed_version -# : $2=current_node_version +# : $2=current_version versionCheck() { [[ ${STRICT_VERSION_CHECK} = N ]] && return 0 w_ver=${1//v/}; w_ver_dots=${w_ver//[^.]}; [[ ${#w_ver_dots} -gt 1 && ${w_ver} =~ ^([0-9]+.[0-9]) ]] && w_ver=${BASH_REMATCH[1]} @@ -448,6 +448,7 @@ getPassword() { fi done } + readPassword() { read_password="" prompt="$1: " @@ -853,6 +854,27 @@ set_default_vars() { NC='\e[0m' } +read_genesis() { + read -ra SHGENESIS <<< "$(jq -r '[ .networkMagic, .systemStart, .epochLength, .slotLength, .activeSlotsCoeff, .slotsPerKESPeriod, .maxKESEvolutions ] |@tsv' < ${GENESIS_JSON})" + read -ra BYGENESIS <<< "$(jq -r '[ .startTime, .protocolConsts.k, .blockVersionData.slotDuration ] |@tsv' < ${BYRON_GENESIS_JSON})" + NWMAGIC=${SHGENESIS[0]} + SHELLEY_GENESIS_START_SEC=$(date --date="${SHGENESIS[1]}" +%s) + EPOCH_LENGTH=${SHGENESIS[2]} + SLOT_LENGTH=${SHGENESIS[3]} + ACTIVE_SLOTS_COEFF=${SHGENESIS[4]} + SLOTS_PER_KES_PERIOD=${SHGENESIS[5]} + MAX_KES_EVOLUTIONS=${SHGENESIS[6]} + BYRON_GENESIS_START_SEC=${BYGENESIS[0]} + BYRON_K=${BYGENESIS[1]} + BYRON_SLOT_LENGTH=${BYGENESIS[2]} + BYRON_EPOCH_LENGTH=$(( 10 * BYRON_K )) +} + +test_koios() { + # make sure KOIOS_API is reachable, else fall back to cli + [[ ${ENABLE_KOIOS} = 'Y' && -n ${KOIOS_API} && $(curl -sfk -o /dev/null -w "%{http_code}" -m 5 ${KOIOS_API}/tip | awk '{print $1}') = "200" ]] || unset KOIOS_API +} + [[ ${0} != '-bash' ]] && PARENT=$(dirname $0) || PARENT="$(pwd)" # If sourcing at terminal, $0 would be "-bash" , which is invalid. Thus, fallback to present working directory # Initialise/Set offline mode prior to calling functions OFFLINE_MODE='N' @@ -889,6 +911,13 @@ if [[ -z "${CNCLI}" ]]; then CNCLI=$(command -v cncli) || CNCLI="${HOME}/.local/bin/cncli" fi +node_version="$(${CNODEBIN} version | head -1 | cut -d' ' -f2)" +cli_version="$(${CCLI} version | head -1 | cut -d' ' -f2)" +if ! versionCheck "8.7.3" "${node_version}" || ! versionCheck "8.17.0.0" "${cli_version}"; then + echo -e "\nKoios scripts have now been upgraded to support cardano-node 8.7.x ('${node_version}' found) / cardano-cli 8.17.x.x ('${cli_version}' found).\nPlease update cardano-node binaries (ensure to read release notes and update various configs using guild-deploy (use appropriate options to download/install/overwrite parts you need) or use tagged branches for older node version (eg: ./