Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ An installer for the APS miner (APScheduler-based miner) is also available:
curl -s https://raw.githubusercontent.com/backend-developers-ltd/InfiniteHash/refs/heads/deploy-config-prod/installer/miner_install.sh | bash
```

This script prompts for `WORKING_DIRECTORY` (default: `~/InfiniteHash-miner/`), then prompts for TOML configuration values and proxy mode. Worker configuration uses v2 grouped input (`hashratePHxcount`, e.g. `0.45x10,0.25x4`) and is written to `[workers.worker_sizes]` in `config.toml`. The installer then deploys the miner stack with Docker Compose and installs a cron job that keeps the compose file up to date by calling `installer/update_miner_compose.sh`.
This script prompts for `WORKING_DIRECTORY` (default: `~/InfiniteHash-miner/`), then prompts for TOML configuration values and proxy mode. Wallet directory prompt is host-side (used for local hotkey lookup), while `config.toml` wallet directory is normalized for container runtime (`/root/.bittensor/wallets`). Worker configuration uses v2 grouped input (`hashratePHxcount`, e.g. `0.45x10,0.25x4`) and is written to `[workers.worker_sizes]` in `config.toml`. The installer then deploys the miner stack with Docker Compose and installs a cron job that keeps the compose file up to date by calling `installer/update_miner_compose.sh`.

For `ihp` mode, default proxy template files (`proxy/.env` and `proxy/pools.toml`) are generated directly by the installer script (inline templates), not downloaded from external template files.

Expand All @@ -82,7 +82,7 @@ In `braiins` mode, the installer provisions Braiins Farm Proxy (`farm-proxy` and
- APS miner updates subnet allocation by pool `name` in `proxy/pools.toml` (`[[pools.main]]` entry), not by host/port.
- The miner container uses `APS_MINER_SUBNET_POOL_NAME` (default: `central-proxy`) to select which pool gets absolute `target_hashrate`.
- The selected pool name must exist in `proxy/pools.toml`; otherwise no subnet target update is applied.
- During installation, if `proxy/pools.toml` does not exist yet, the script asks for backup/private pool host/port and writes those values to `pools.backup`.
- During installation, if `proxy/pools.toml` does not exist yet, the script asks for backup/private pool host/port, optional backup `worker_id` override, and for `central-proxy` asks whether to use suggested identity format or set `worker_id` manually (manual input may be empty for no override), then writes provided values to `pools.backup`/`[[pools.main]]`.
- Installer default sets `[extranonce].extranonce2_size = 2`.
- After updating `proxy/pools.toml`, APS miner touches reload sentinel `APS_MINER_IHP_RELOAD_SENTINEL` (default: `/root/src/proxy/.reload-ihp`); sidecar `ihp-proxy-reloader` then runs `kill -HUP 1` in `ihp-proxy` PID namespace.

Expand Down
86 changes: 82 additions & 4 deletions installer/miner_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fi
GITHUB_URL="https://raw.githubusercontent.com/backend-developers-ltd/InfiniteHash/refs/heads"
MAX_V2_WORKER_SIZE_PH="0.45"
MAX_V2_TOTAL_WORKERS=1000
DEFAULT_HOST_WALLET_DIRECTORY="${HOME}/.bittensor/wallets"
CONTAINER_WALLET_DIRECTORY="/root/.bittensor/wallets"

mkdir -p "${WORKING_DIRECTORY}"
WORKING_DIRECTORY=$(realpath "${WORKING_DIRECTORY}")
Expand Down Expand Up @@ -49,6 +51,8 @@ write_default_ihp_pools() {
local destination="$1"
local backup_pool_host="$2"
local backup_pool_port="$3"
local backup_pool_worker_id="${4:-}"
local main_pool_worker_id="${5:-}"

cat > "${destination}" <<EOL
[pools]
Expand All @@ -57,12 +61,29 @@ write_default_ihp_pools() {
name = "private-backup"
host = "${backup_pool_host}"
port = ${backup_pool_port}
EOL

if [ -n "${backup_pool_worker_id}" ]; then
cat >> "${destination}" <<EOL
worker_id = "${backup_pool_worker_id}"
EOL
fi

cat >> "${destination}" <<EOL
[[pools.main]]
name = "central-proxy"
host = "stratum.infinitehash.xyz"
port = 9332
weight = 1
EOL

if [ -n "${main_pool_worker_id}" ]; then
cat >> "${destination}" <<EOL
worker_id = "${main_pool_worker_id}"
EOL
fi

cat >> "${destination}" <<EOL

[extranonce]
extranonce2_size = 2
Expand Down Expand Up @@ -94,8 +115,9 @@ if [ ! -f "${CONFIG_FILE}" ]; then
BITTENSOR_NETUID=${BITTENSOR_NETUID:-89}
BITTENSOR_NETUID=$(echo "${BITTENSOR_NETUID}" | tr -d '[:space:]')

read -r -p "Enter BITTENSOR_WALLET_DIRECTORY [~/.bittensor/wallets]: " BITTENSOR_WALLET_DIRECTORY </dev/tty
BITTENSOR_WALLET_DIRECTORY=${BITTENSOR_WALLET_DIRECTORY:-~/.bittensor/wallets}
read -r -p "Enter host BITTENSOR_WALLET_DIRECTORY [${DEFAULT_HOST_WALLET_DIRECTORY}]: " HOST_WALLET_DIRECTORY </dev/tty
HOST_WALLET_DIRECTORY=${HOST_WALLET_DIRECTORY:-${DEFAULT_HOST_WALLET_DIRECTORY}}
BITTENSOR_WALLET_DIRECTORY="${CONTAINER_WALLET_DIRECTORY}"

read -r -p "Enter BITTENSOR_WALLET_NAME [default]: " BITTENSOR_WALLET_NAME </dev/tty
BITTENSOR_WALLET_NAME=${BITTENSOR_WALLET_NAME:-default}
Expand Down Expand Up @@ -235,6 +257,13 @@ else
BITTENSOR_WALLET_NAME=${BITTENSOR_WALLET_NAME:-$(parse_toml_value "wallet" "name")}
BITTENSOR_WALLET_HOTKEY_NAME=${BITTENSOR_WALLET_HOTKEY_NAME:-$(parse_toml_value "wallet" "hotkey_name")}
BITTENSOR_WALLET_DIRECTORY=${BITTENSOR_WALLET_DIRECTORY:-$(parse_toml_value "wallet" "directory")}
HOST_WALLET_DIRECTORY=${HOST_WALLET_DIRECTORY:-${BITTENSOR_WALLET_DIRECTORY}}

if [ "${BITTENSOR_WALLET_DIRECTORY}" != "${CONTAINER_WALLET_DIRECTORY}" ]; then
echo "Updating wallet directory in ${CONFIG_FILE} for container runtime: ${BITTENSOR_WALLET_DIRECTORY} -> ${CONTAINER_WALLET_DIRECTORY}"
sed -i "/^\\[wallet\\]/,/^\\[/{s|^directory = \".*\"|directory = \"${CONTAINER_WALLET_DIRECTORY}\"|}" "${CONFIG_FILE}"
BITTENSOR_WALLET_DIRECTORY="${CONTAINER_WALLET_DIRECTORY}"
fi
fi

expand_path() {
Expand All @@ -248,8 +277,19 @@ expand_path() {
fi
}

WALLET_DIR_EXPANDED=$(expand_path "${BITTENSOR_WALLET_DIRECTORY}")
if [ -z "${HOST_WALLET_DIRECTORY:-}" ] || [ "${HOST_WALLET_DIRECTORY}" = "${CONTAINER_WALLET_DIRECTORY}" ]; then
HOST_WALLET_DIRECTORY="${DEFAULT_HOST_WALLET_DIRECTORY}"
fi

WALLET_DIR_EXPANDED=$(expand_path "${HOST_WALLET_DIRECTORY}")
HOTKEY_PUB_FILE="${WALLET_DIR_EXPANDED}/${BITTENSOR_WALLET_NAME}/hotkeys/${BITTENSOR_WALLET_HOTKEY_NAME}pub.txt"
if [ ! -f "${HOTKEY_PUB_FILE}" ]; then
FALLBACK_WALLET_DIR="${HOME}/.bittensor/wallets"
FALLBACK_HOTKEY_PUB_FILE="${FALLBACK_WALLET_DIR}/${BITTENSOR_WALLET_NAME}/hotkeys/${BITTENSOR_WALLET_HOTKEY_NAME}pub.txt"
if [ -f "${FALLBACK_HOTKEY_PUB_FILE}" ]; then
HOTKEY_PUB_FILE="${FALLBACK_HOTKEY_PUB_FILE}"
fi
fi
HOTKEY_SS58=""
if [ -f "${HOTKEY_PUB_FILE}" ]; then
HOTKEY_SS58=$(sed -n 's/.*"ss58Address":"\([^"]*\)".*/\1/p' "${HOTKEY_PUB_FILE}")
Expand Down Expand Up @@ -309,7 +349,28 @@ if [ "${PROXY_MODE}" = "ihp" ]; then
PRIVATE_POOL_PORT=${PRIVATE_POOL_PORT:-${DEFAULT_PRIVATE_POOL_PORT}}
PRIVATE_POOL_PORT=$(echo "${PRIVATE_POOL_PORT}" | tr -d '[:space:]')

write_default_ihp_pools "${NEW_PROXY_POOLS_FILE}" "${PRIVATE_POOL_HOST}" "${PRIVATE_POOL_PORT}"
read -r -p "Enter IHP backup/private pool worker ID override (optional) []: " PRIVATE_POOL_WORKER_ID </dev/tty
PRIVATE_POOL_WORKER_ID=$(echo "${PRIVATE_POOL_WORKER_ID}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')

DEFAULT_MAIN_POOL_WORKER_ID="sn${BITTENSOR_NETUID}auction.${HOTKEY_IDENTIFIER}.worker1"
echo ""
echo "Configure IHP central-proxy worker ID override:"
echo " 1) Use suggested value (${DEFAULT_MAIN_POOL_WORKER_ID})"
echo " 2) Set manually (leave empty for no override)"
read -r -p "Selection [1]: " MAIN_POOL_WORKER_ID_MODE </dev/tty
MAIN_POOL_WORKER_ID_MODE=${MAIN_POOL_WORKER_ID_MODE:-1}

case "${MAIN_POOL_WORKER_ID_MODE}" in
2)
read -r -p "Enter IHP central-proxy worker ID override (optional) []: " MAIN_POOL_WORKER_ID </dev/tty
MAIN_POOL_WORKER_ID=$(echo "${MAIN_POOL_WORKER_ID}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
;;
*)
MAIN_POOL_WORKER_ID="${DEFAULT_MAIN_POOL_WORKER_ID}"
;;
esac

write_default_ihp_pools "${NEW_PROXY_POOLS_FILE}" "${PRIVATE_POOL_HOST}" "${PRIVATE_POOL_PORT}" "${PRIVATE_POOL_WORKER_ID}" "${MAIN_POOL_WORKER_ID}"
else
echo "Using existing InfiniteHash Proxy pools file at ${NEW_PROXY_POOLS_FILE}"
fi
Expand Down Expand Up @@ -406,6 +467,23 @@ if ! /tmp/update_miner_compose.sh "${ENV_NAME}" "${WORKING_DIRECTORY}"; then
fi
echo "update_miner_compose.sh ran successfully."

echo "Pulling latest images and recreating services..."
if command -v docker &> /dev/null && docker compose version &> /dev/null; then
if ! (cd "${WORKING_DIRECTORY}" && docker compose pull && docker compose up -d --remove-orphans); then
echo "Error: docker compose pull/up failed."
exit 1
fi
elif command -v docker-compose &> /dev/null; then
if ! (cd "${WORKING_DIRECTORY}" && docker-compose pull && docker-compose up -d --remove-orphans); then
echo "Error: docker-compose pull/up failed."
exit 1
fi
else
echo "Error: Neither docker compose nor docker-compose is available."
exit 1
fi
echo "Latest images applied successfully."

CRON_CMD="*/15 * * * * cd ${WORKING_DIRECTORY} && curl -s ${GITHUB_URL}/deploy-config-${ENV_NAME}/installer/update_miner_compose.sh > /tmp/update_miner_compose.sh && chmod +x /tmp/update_miner_compose.sh && /tmp/update_miner_compose.sh ${ENV_NAME} ${WORKING_DIRECTORY} # INFINITE_HASH_APS_MINER_UPDATE"

(crontab -l 2>/dev/null || echo "") | grep -v "INFINITE_HASH_APS_MINER_UPDATE" | { cat; echo "${CRON_CMD}"; } | crontab -
Expand Down