Probe Scripts

Purpose

Probe scripts serve as lightweight health checks for blockchain node daemons and related services running within Kubernetes pods. Their primary role is to provide liveness, readiness, and startup signals that help Kubernetes determine whether a container is functioning correctly, ready to serve requests, or requires restarting. This subtopic addresses the challenge of reliably detecting node synchronization status, network connectivity, and operational health in a heterogeneous blockchain environment where each chain has unique node RPC interfaces and synchronization semantics.

Unlike generic container health checks, these scripts implement blockchain-specific logic by querying node RPC endpoints to assess synchronization progress, peer connectivity, and block advancement. They ensure that only healthy and fully synced nodes receive traffic, maintaining overall system stability and data consistency throughout the multi-blockchain ShapeShift Unchained infrastructure.

Functionality

Probe scripts typically perform the following key workflows:

Each script respects a disabling flag file (e.g., `/data/disable_readiness`) allowing manual override to bypass probe failures during maintenance or debugging.

Example: Bitcoin Readiness Check Snippet

CONNECTION_COUNT=$(curl -sf -H 'content-type: application/json' -u user:password \
  -d '{ "jsonrpc": "2.0", "id": "probe", "method": "getconnectioncount", "params": [] }' http://localhost:8332) || exit 1
BLOCKCHAIN_INFO=$(curl -sf -H 'content-type: application/json' -u user:password \
  -d '{ "jsonrpc": "2.0", "id": "probe", "method": "getblockchaininfo", "params": [] }' http://localhost:8332) || exit 1

PEERS=$(echo $CONNECTION_COUNT | jq -r '.result')
NODE_LATEST_BLOCK_HEIGHT=$(echo $BLOCKCHAIN_INFO | jq -r '.result.blocks')
NETWORK_LATEST_BLOCK_HEIGHT=$(echo $BLOCKCHAIN_INFO | jq -r '.result.headers')

if (( NODE_LATEST_BLOCK_HEIGHT >= NETWORK_LATEST_BLOCK_HEIGHT - 1 )) && (( PEERS > 0 )); then
  exit 0
else
  exit 1
fi

Key Characteristics

Integration

Probe scripts integrate tightly with Kubernetes deployment manifests for blockchain daemon StatefulSets and pods. Kubernetes specifies these scripts as the command for readiness, liveness, and startup probes in pod spec containers, enabling automated health monitoring and lifecycle management.

These scripts complement other subtopics such as:

By providing chain-specific health checks, probe scripts enable the unified API layer and indexers to rely on healthy node data sources, improving overall system robustness and user experience.

Probe Script Health Check Flow

flowchart TD
    Start[Start Probe Script]
    CheckDisable{Disable Flag Present?}
    FetchRPC[Fetch Node RPC Data]
    ParseData[Parse and Extract Status]
    EvaluateStatus{Is Node Synced and Healthy?}
    Success[Exit 0 - Healthy]
    Failure[Exit 1 - Unhealthy]

    Start --> CheckDisable
    CheckDisable -- Yes --> Success
    CheckDisable -- No --> FetchRPC
    FetchRPC --> ParseData
    ParseData --> EvaluateStatus
    EvaluateStatus -- Yes --> Success
    EvaluateStatus -- No --> Failure

This flowchart depicts the typical probe script logic: it first checks for a disable flag to optionally bypass health checks, then queries the node’s RPC interface, parses the response, evaluates synchronization and peer status, and finally exits with a code indicating health to Kubernetes.