From 0ff6b275a2f69b149aaf0f681725ea0442945c0a Mon Sep 17 00:00:00 2001 From: lklimek <842586+lklimek@users.noreply.github.com> Date: Mon, 16 Dec 2024 10:37:35 +0100 Subject: [PATCH] chore: remove deprecated check_network_version.sh (#2084) --- scripts/check_network_version.sh | 207 ------------------------------- 1 file changed, 207 deletions(-) delete mode 100755 scripts/check_network_version.sh diff --git a/scripts/check_network_version.sh b/scripts/check_network_version.sh deleted file mode 100755 index 400501329c8..00000000000 --- a/scripts/check_network_version.sh +++ /dev/null @@ -1,207 +0,0 @@ -#! /bin/bash - -# Some defaults -PORT=${PORT:-443} -CSV=/tmp/masternodes.csv -MASTERNODES="" -ALL="" - -function help() { - if [[ -z "$1" ]]; then - - echo This script connects to all masternodes and tries to detect their version. - echo "" - echo "Usage: $0 [-p | --port ] [-h | --help] [-m | --masternodes ] [-j | --json ] [-w | --mnowatch] [-c | --csv ]" - echo "Options:" - echo " -p, --port Port to connect to (default: $PORT)" - echo " -h, --help Show this help" - echo " -m, --masternodes File with IP addresses of masternodes to check" - echo " -j, --json File with masternodes.json in format generated by mnowatch" - echo " -w, --mnowatch Use mnowatch.org to get masternodes" - echo " -c, --csv Save results to CSV file; default: $CSV" - echo "" - echo "Note: --masternodes, --json, and --mnowatch are mutually exclusive and the latest one takes precedence." - exit 1 - fi -} - -REPO="$(realpath "$(dirname "$0")/..")" - -function load_masternodes_json() { - # curl https://mnowatch.org/json/?method=emn_details - # TODO: use curl above - jq 'map(select(.platformHTTPPortStatus != "CLOSED"))|map(select(.active_YNU!="N"))|map(select(.status!="P"))' "$1" | - jq -r .[].ip | - sort | - uniq -} - -function grpc_core { - docker run \ - -v "${REPO}:/repo" \ - fullstorydev/grpcurl:latest \ - -import-path "/repo/packages/dapi-grpc/protos/core/v0" \ - -proto core.proto \ - -max-time 30 \ - -keepalive-time 1 \ - "$@" -} - -function grpc_platform { - docker run \ - -v "${REPO}:/repo" \ - fullstorydev/grpcurl:latest \ - -import-path "/repo/packages/dapi-grpc/protos/platform/v0" \ - -proto platform.proto \ - -max-time 30 \ - -keepalive-time 1 \ - "$@" -} - -# Go to specified IP and fetch SML (subscribeToMasternodeList) - -# MASTERNODES=$( -# grpc_core "$FULLNODE:$PORT" org.dash.platform.dapi.v0.Core/subscribeToMasternodeList | -# jq -r .masternodeListDiff | -# base64 -d | -# grep -aEo '([0-9]{1,3}\.){3}[0-9]{1,3}' | sort | uniq -# ) - -# Try to determine version of the platform -function detect_platform() { - NODE="$1" - - err="$(grpc_platform -insecure "$NODE:${PORT}" org.dash.platform.dapi.v0.Platform/getTotalCreditsInPlatform 2>&1)" - - echo "============ $NODE ============" >>/tmp/detect_platform.log - echo "$err" >>/tmp/detect_platform.log - - case "$err" in - *"decoding error: could not decode"*) - echo 1.1 - ;; - *"upstream connect error or disconnect/reset before headers"*) - echo "upstream connect error" - ;; - *"connect: connection refused"*) - echo "connection refused" - ;; - *"Code: Unimplemented"*) - echo "unimplemented" - ;; - *) - echo "ERROR" - ;; - esac -} - -# Check if core is available by calling getBlockchainStatus -# UNUSED -function detect_core() { - NODE="$1" - - err="$(grpc_core -insecure -d '{}' "$NODE:${PORT}" org.dash.platform.dapi.v0.Core/getBlockchainStatus 2>&1)" - - echo "============ $NODE ============" >>/tmp/detect_core.log - echo "$err" >>/tmp/detect_core.log - - version="$(echo "$err" | jq -r .version.agent 2>/dev/null)" - if [[ -z "$version" ]]; then - case "$err" in - *"upstream connect error"*) - echo down - ;; - *"connect: connection refused"*) - echo "connection refused" - ;; - *) - echo "UNKNOWN" - ;; - esac - else - echo "$version" - fi -} - -# Parse arguments -while [[ "$1" == -* ]]; do - case "$1" in - -p | --port) - PORT="$2" - shift 2 - ;; - -m | --masternodes) - MASTERNODES=$(cat "$2") - shift 2 - ;; - -j | --json) - MASTERNODES=$(load_masternodes_json "$2") - ALL=$(jq '.|length' "$2") - shift 2 - ;; - -w | --mnowatch) - MN_FILE=$(mktemp /tmp/masternodes.json.XXXXXX) - echo -n Fetching masternodes from mnowatch.org... - curl -s https://mnowatch.org/json/?method=emn_details >"$MN_FILE" - ALL=$(jq '.|length' "$MN_FILE") - MASTERNODES=$(load_masternodes_json "$MN_FILE") - echo " done." - shift - ;; - -c | --csv) - CSV="$2" - shift 2 - ;; - *) - echo "Unknown option: $1" - exit 1 - ;; - esac -done - -COUNT=$(echo "$MASTERNODES" | wc -l) -if [[ -z "$ALL" ]]; then - ALL=$COUNT -fi - -# Fetch getTotalCreditsInPlatform : -# * can’t connect - no platform, not found - means platform version -# * less than 1.1.0, internal - right version but init chain is not called yet. -# Fetch getBlockchainStatus to get information about Core: -# * can’t connect - no platform or no core -# grpc_core -help -set +e - -# Reset logs -truncate -s 0 /tmp/detect_platform.log -truncate -s 0 /tmp/detect_core.log - -if [[ -z "$MASTERNODES" ]]; then - echo "No masternodes found" - exit 1 -fi - -# CSV header -echo "'no','masternode','platform','core'" >"$CSV" - -i=1 -for MN in $MASTERNODES; do - echo "Checking status of evo node $MN ($i/$COUNT)" - - PLATFORM="$(detect_platform "$MN")" - # CORE="$(detect_core "$MN")" - # Format result as CSV - echo "$i,'$MN','$PLATFORM','$CORE'" >>"$CSV" - i=$((i + 1)) -done - -echo "Done." - -echo "" -echo "Results saved to $CSV" -echo "" -echo "Some statistics:" -echo "Total evonodes: $ALL" -echo "Potentially correct evo nodes: $COUNT" -echo "Platform versions:" -tail -n +2 "$CSV" | cut -d, -f3 | sort | uniq -c | sort -n