diff --git a/installer/README.md b/installer/README.md index 8ec711e..2c19f53 100644 --- a/installer/README.md +++ b/installer/README.md @@ -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. @@ -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. diff --git a/installer/miner_install.sh b/installer/miner_install.sh index 22d4762..eb0ca44 100644 --- a/installer/miner_install.sh +++ b/installer/miner_install.sh @@ -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}") @@ -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}" <> "${destination}" <> "${destination}" <> "${destination}" <> "${destination}" < ${CONTAINER_WALLET_DIRECTORY}" + sed -i "/^\\[wallet\\]/,/^\\[/{s|^directory = \".*\"|directory = \"${CONTAINER_WALLET_DIRECTORY}\"|}" "${CONFIG_FILE}" + BITTENSOR_WALLET_DIRECTORY="${CONTAINER_WALLET_DIRECTORY}" + fi fi expand_path() { @@ -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}") @@ -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/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 -