From e6e4110a5b15581d8d920d8c9d918a037ed37a70 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 26 Jan 2026 13:40:27 +0000 Subject: [PATCH] Add Bob Node and Lite Node installation guides with shell scripts - Rewrite README.md in English with full setup docs for both node types - Add scripts/bob-install.sh with docker-standalone, docker-compose, and manual modes - Add scripts/lite-install.sh with docker and manual modes - Both scripts support CLI options (--peers, --testnet, --avx512, etc.) - Both scripts auto-create systemd services for manual installs - Bob Node repo: krypdkat/qubicbob - Lite Node repo: hackerby888/qubic-core-lite --- README.md | 636 +++++++++++++++++++--------------------- scripts/bob-install.sh | 382 ++++++++++++++++++++++++ scripts/lite-install.sh | 372 +++++++++++++++++++++++ 3 files changed, 1060 insertions(+), 330 deletions(-) create mode 100755 scripts/bob-install.sh create mode 100755 scripts/lite-install.sh diff --git a/README.md b/README.md index 6239d2d..e63c82f 100644 --- a/README.md +++ b/README.md @@ -1,210 +1,196 @@ -# Network Guard - Qubic Node Installation Guide +# Network Guard - Qubic Node Setup Guide -Setup-Anleitungen fuer **Bob Node** und **Lite Node** im Qubic-Netzwerk. +Installation guides for **Bob Node** and **Lite Node** on the Qubic network. --- -## Inhaltsverzeichnis +## Table of Contents -- [1. Uebersicht](#1-uebersicht) +- [1. Overview](#1-overview) - [2. Bob Node](#2-bob-node) - - [2.1 Systemanforderungen](#21-systemanforderungen) - - [2.2 Installation mit Docker (Empfohlen)](#22-installation-mit-docker-empfohlen) - - [2.2.1 Standalone (All-in-One)](#221-standalone-all-in-one) - - [2.2.2 Docker Compose (Modular)](#222-docker-compose-modular) - - [2.3 Manuelle Installation (Build from Source)](#23-manuelle-installation-build-from-source) - - [2.4 Konfiguration](#24-konfiguration) - - [2.5 Wartung und Troubleshooting](#25-wartung-und-troubleshooting) + - [2.1 System Requirements](#21-system-requirements) + - [2.2 Quick Install (Script)](#22-quick-install-script) + - [2.3 Docker Setup (Manual)](#23-docker-setup-manual) + - [2.4 Build from Source (Manual)](#24-build-from-source-manual) + - [2.5 Configuration Reference](#25-configuration-reference) + - [2.6 Maintenance & Troubleshooting](#26-maintenance--troubleshooting) - [3. Lite Node](#3-lite-node) - - [3.1 Systemanforderungen](#31-systemanforderungen) - - [3.2 Installation mit Docker](#32-installation-mit-docker) - - [3.3 Manuelle Installation (Build from Source)](#33-manuelle-installation-build-from-source) - - [3.4 Konfiguration](#34-konfiguration) - - [3.5 Betrieb](#35-betrieb) -- [4. Referenzen](#4-referenzen) + - [3.1 System Requirements](#31-system-requirements) + - [3.2 Quick Install (Script)](#32-quick-install-script) + - [3.3 Docker Setup (Manual)](#33-docker-setup-manual) + - [3.4 Build from Source (Manual)](#34-build-from-source-manual) + - [3.5 Configuration Reference](#35-configuration-reference) + - [3.6 Maintenance & Troubleshooting](#36-maintenance--troubleshooting) +- [4. References](#4-references) --- -## 1. Uebersicht +## 1. Overview -| Node-Typ | Beschreibung | Repo | -|-----------|-------------|------| -| **Bob Node** | Ultra-lightweight Indexer mit REST API fuer das Qubic-Netzwerk. Archiviert Blockchain-Daten und stellt sie ueber JSON-RPC 2.0 bereit. | [krypdkat/qubicbob](https://github.com/krypdkat/qubicbob) | -| **Lite Node** | Lite-Version des Qubic Core. Laeuft direkt auf dem OS ohne UEFI-Umgebung. Unterstuetzt Mainnet (Beta) und lokales Testnet. | [vitwit/qubic-core-lite](https://github.com/vitwit/qubic-core-lite) | +| Node Type | Description | Repository | +|-----------|-------------|------------| +| **Bob Node** | Ultra-lightweight indexer with REST API & JSON-RPC 2.0 for the Qubic network. Archives blockchain data and processes logging events. | [krypdkat/qubicbob](https://github.com/krypdkat/qubicbob) | +| **Lite Node** | Lite version of Qubic Core. Runs directly on the OS without a UEFI environment. Supports mainnet (beta) and local testnet. | [hackerby888/qubic-core-lite](https://github.com/hackerby888/qubic-core-lite) | --- ## 2. Bob Node -> Bob ist ein BETA Indexer und Logging-Node fuer das Qubic-Netzwerk. Er archiviert Blockchain-Daten, verarbeitet Logging-Events und bietet eine REST API / JSON-RPC 2.0 API. +> Bob is a **BETA** indexer and logging node for the Qubic blockchain. It archives blockchain data, processes logging events, and provides a REST API / JSON-RPC 2.0 interface. -### 2.1 Systemanforderungen +### 2.1 System Requirements -| Ressource | Minimum | -|-----------|---------| +| Resource | Minimum | +|----------|---------| | RAM | 16 GB | -| CPU | 4+ Kerne mit AVX2-Support | -| Speicher | 100 GB schnelle SSD / NVMe | -| OS | Linux (Ubuntu 24.04 empfohlen) | -| Software | Docker **oder** CMake, Clang/GCC, KeyDB, KVRocks | +| CPU | 4+ cores with AVX2 support | +| Storage | 100 GB fast SSD / NVMe | +| OS | Linux (Ubuntu 24.04 recommended) | +| Software | Docker **or** CMake, Clang/GCC, KeyDB, KVRocks | -### 2.2 Installation mit Docker (Empfohlen) +### 2.2 Quick Install (Script) -> **Voraussetzung:** Docker und Docker Compose muessen installiert sein. -> -> ```bash -> # Docker installieren (falls nicht vorhanden) -> curl -fsSL https://get.docker.com | sh -> sudo usermod -aG docker $USER -> # Danach neu einloggen oder: newgrp docker -> ``` +The fastest way to get a Bob Node running. Download the script and choose a mode: -#### 2.2.1 Standalone (All-in-One) +**Option A: Docker Standalone (recommended)** -Die Standalone-Variante buendelt **Bob + Redis + KVRocks** in einem einzigen Container. Ideal fuer schnelles Setup. +All-in-one container with Bob + Redis + KVRocks bundled together. ```bash -# 1. Beispiel-Dateien herunterladen -mkdir -p ~/qubic-bob && cd ~/qubic-bob +# update sources +apt update -curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/docker-compose.standalone.yml -curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/bob.json.standalone +# download the installation script +wget -O bob-install.sh https://raw.githubusercontent.com/Pomm3sgab3l/Network_Guard/main/scripts/bob-install.sh -# 2. Konfiguration anpassen (optional) -mv bob.json.standalone bob.json -# Datei bearbeiten falls noetig: -# nano bob.json +# make it executable +chmod u+x bob-install.sh -# 3. Container starten -docker compose -f docker-compose.standalone.yml up -d +# install as Docker standalone +./bob-install.sh docker-standalone ``` -**Ports:** -- `21842` - P2P / Server Port -- `40420` - REST API / JSON-RPC +**Option B: Docker Compose (modular)** + +Separate containers for Bob, KeyDB, and KVRocks. More control and scalability. -**Logs pruefen:** ```bash -docker compose -f docker-compose.standalone.yml logs -f -``` +wget -O bob-install.sh https://raw.githubusercontent.com/Pomm3sgab3l/Network_Guard/main/scripts/bob-install.sh +chmod u+x bob-install.sh -#### 2.2.2 Docker Compose (Modular) +# install with custom peers +./bob-install.sh docker-compose --peers 1.2.3.4:21841,5.6.7.8:21841 +``` -Die modulare Variante betreibt Bob, KeyDB und KVRocks als separate Container. Bietet mehr Kontrolle und Skalierbarkeit. +**Option C: Build from source with systemd service** ```bash -# 1. Beispiel-Dateien herunterladen -mkdir -p ~/qubic-bob && cd ~/qubic-bob +wget -O bob-install.sh https://raw.githubusercontent.com/Pomm3sgab3l/Network_Guard/main/scripts/bob-install.sh +chmod u+x bob-install.sh -curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/docker-compose.yml -curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/bob.json -curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/keydb.conf -curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/kvrocks.conf +# install from source +./bob-install.sh manual --peers 1.2.3.4:21841 --threads 8 +``` -# 2. Konfiguration anpassen (optional) -# nano bob.json +**Script Options:** -# 3. Container starten -docker compose up -d -``` +| Option | Description | Default | +|--------|-------------|---------| +| `--peers ` | Trusted peers to sync from | *(none)* | +| `--threads ` | Max threads (0 = auto) | `0` | +| `--rpc-port ` | REST API / JSON-RPC port | `40420` | +| `--server-port ` | P2P server port | `21842` | +| `--data-dir ` | Data directory | `/opt/qubic-bob` | + +### 2.3 Docker Setup (Manual) + +If you prefer to set up Docker manually without the script: -**Status pruefen:** +**Prerequisites:** ```bash -docker compose ps -docker compose logs -f qubic-bob +# install Docker if not present +curl -fsSL https://get.docker.com | sh +sudo usermod -aG docker $USER +# log out and back in, or run: newgrp docker ``` -**Container stoppen:** +#### Standalone (All-in-One) + ```bash -docker compose down -``` +mkdir -p ~/qubic-bob && cd ~/qubic-bob -### 2.3 Manuelle Installation (Build from Source) +# download example files +curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/docker-compose.standalone.yml +curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/bob.json.standalone +mv bob.json.standalone bob.json -Einrichtungs-Skript fuer Ubuntu/Debian: +# edit configuration (add your peers etc.) +nano bob.json -```bash -#!/bin/bash -# bob-install.sh - Bob Node Installation Script +# start +docker compose -f docker-compose.standalone.yml up -d +``` -set -e +#### Docker Compose (Modular) -echo "=== Bob Node Installation ===" +```bash +mkdir -p ~/qubic-bob && cd ~/qubic-bob -# 1. System-Updates und Abhaengigkeiten -sudo apt update && sudo apt upgrade -y -sudo apt install -y vim net-tools tmux cmake git libjsoncpp-dev \ - build-essential uuid-dev libhiredis-dev zlib1g-dev unzip - -# 2. KeyDB installieren -echo "=== KeyDB installieren ===" -echo "deb https://download.keydb.dev/open-source-dist $(lsb_release -sc) main" | \ - sudo tee /etc/apt/sources.list.d/keydb.list -sudo wget -O /etc/apt/trusted.gpg.d/keydb.gpg https://download.keydb.dev/open-source-dist/keyring.gpg -sudo apt update -sudo apt install -y keydb - -# KeyDB starten -sudo systemctl enable keydb-server -sudo systemctl start keydb-server - -# 3. KVRocks installieren (fuer persistente Speicherung) -echo "=== KVRocks installieren ===" -cd /tmp -git clone --branch v2.9.0 https://github.com/apache/kvrocks.git -cd kvrocks -mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Release -make -j$(nproc) -sudo cp src/kvrocks /usr/local/bin/ -cd ~ +# download all required files +curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/docker-compose.yml +curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/bob.json +curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/keydb.conf +curl -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/kvrocks.conf -# 4. Bob Node klonen und bauen -echo "=== Bob Node bauen ===" -git clone https://github.com/krypdkat/qubicbob.git -cd qubicbob -mkdir build && cd build -cmake ../ -make -j$(nproc) +# edit configuration +nano bob.json -echo "=== Installation abgeschlossen ===" -echo "Binary liegt unter: $(pwd)/bob" -echo "" -echo "Starten mit: ./bob /pfad/zur/config.json" +# start +docker compose up -d ``` -**Schritt-fuer-Schritt (manuell):** +**Exposed Ports:** + +| Port | Service | +|------|---------| +| `21842` | P2P / Server | +| `40420` | REST API / JSON-RPC | + +### 2.4 Build from Source (Manual) + +Step-by-step guide for building Bob Node without Docker: ```bash -# 1. Abhaengigkeiten installieren +# 1. install dependencies sudo apt update && sudo apt upgrade -y -sudo apt install -y vim net-tools tmux cmake git libjsoncpp-dev \ - build-essential uuid-dev libhiredis-dev zlib1g-dev unzip +sudo apt install -y build-essential cmake git libjsoncpp-dev \ + uuid-dev libhiredis-dev zlib1g-dev unzip wget net-tools tmux -# 2. Repository klonen +# 2. clone the repository git clone https://github.com/krypdkat/qubicbob.git cd qubicbob -# 3. Bauen +# 3. build mkdir build && cd build cmake ../ make -j$(nproc) -# 4. Konfigurationsdatei erstellen +# 4. create config from template cp ../default_config_bob.json ./config.json -# Konfiguration anpassen: nano config.json -# 5. Starten (mit tmux fuer Persistenz) +# 5. start with tmux (keeps running after disconnect) tmux new -s bob ./bob ./config.json -# Tmux verlassen: Ctrl+B, dann D -# Wieder verbinden: tmux attach -t bob +# detach: Ctrl+B, then D +# reattach: tmux attach -t bob ``` -### 2.4 Konfiguration +> **Note:** You also need KeyDB and KVRocks running locally. The installation script (`bob-install.sh manual`) handles this automatically. -Beispiel `bob.json`: +### 2.5 Configuration Reference + +Example `bob.json`: ```json { @@ -228,95 +214,137 @@ Beispiel `bob.json`: } ``` -> **Hinweis:** Bei Docker Compose die Hostnames `keydb` und `kvrocks` statt `127.0.0.1` verwenden. - -**Wichtige Konfigurationsparameter:** - -| Parameter | Beschreibung | Standard | -|-----------|-------------|----------| -| `trusted-node` | Qubic-Peers zum Synchronisieren (`IP:PORT` oder `IP:PORT:PASSCODE`) | `[]` | -| `p2p-node` | P2P-Node-Adressen | `[]` | -| `request-cycle-ms` | Abfrage-Intervall in ms (nicht zu niedrig setzen!) | `100` | -| `request-logging-cycle-ms` | Logging-Abfrage-Intervall in ms | `30` | -| `log-level` | Log-Detailgrad (`info`, `debug`, etc.) | `info` | -| `keydb-url` | KeyDB-Verbindung | `tcp://127.0.0.1:6379` | -| `kvrocks-url` | KVRocks-Verbindung (persistente Speicherung) | `tcp://127.0.0.1:6666` | -| `run-server` | Listener-Port aktivieren | `false` | -| `server-port` | P2P-Server Port | `21842` | -| `rpc-port` | REST API / JSON-RPC Port | `40420` | -| `tick-storage-mode` | Speicher-Backend (`kvrocks`, `lastNTick`, `free`) | `lastNTick` | -| `tx-storage-mode` | TX-Speicher-Backend | `kvrocks` | -| `tx_tick_to_live` | Datenaufbewahrung (Ticks) | `3000` | -| `max-thread` | Max. Threads (0 = automatisch) | `8` | -| `spam-qu-threshold` | Spam-Filter Schwellenwert | `100` | - -### 2.5 Wartung und Troubleshooting - -**Logs anzeigen (Docker):** +> **Note:** When using Docker Compose, use container hostnames (`keydb`, `kvrocks`) instead of `127.0.0.1`. + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `trusted-node` | Qubic peers to sync from (`IP:PORT` or `IP:PORT:PASSCODE`) | `[]` | +| `p2p-node` | P2P node addresses | `[]` | +| `request-cycle-ms` | Request polling interval in ms (do not set too low!) | `100` | +| `request-logging-cycle-ms` | Logging poll interval in ms | `30` | +| `log-level` | Log verbosity (`info`, `debug`, etc.) | `info` | +| `keydb-url` | KeyDB connection string | `tcp://127.0.0.1:6379` | +| `kvrocks-url` | KVRocks connection (persistent storage) | `tcp://127.0.0.1:6666` | +| `run-server` | Enable listener port | `false` | +| `server-port` | P2P server port | `21842` | +| `rpc-port` | REST API / JSON-RPC port | `40420` | +| `tick-storage-mode` | Storage backend (`kvrocks`, `lastNTick`, `free`) | `lastNTick` | +| `tx-storage-mode` | TX storage backend | `kvrocks` | +| `tx_tick_to_live` | Data retention in ticks | `3000` | +| `max-thread` | Max threads (0 = auto) | `8` | +| `spam-qu-threshold` | Spam filter threshold | `100` | + +### 2.6 Maintenance & Troubleshooting + +**Docker commands:** ```bash -docker compose logs -f qubic-bob +docker compose ps # check status +docker compose logs -f # view logs +docker compose restart # restart +docker compose down # stop +docker compose pull && docker compose up -d # update to latest image ``` -**In den Container verbinden:** +**Systemd commands (manual install):** ```bash -docker exec -it qubic-bob /bin/bash +systemctl status qubic-bob # check status +journalctl -u qubic-bob -f # view logs +systemctl restart qubic-bob # restart +systemctl stop qubic-bob # stop ``` -**Datenbank zuruecksetzen:** +**Reset databases (Docker):** ```bash -# Docker Compose docker compose down docker volume rm qubic-bob-redis qubic-bob-kvrocks qubic-bob-data docker compose up -d ``` -**Updates einspielen (Docker):** +**Update from source (manual install):** ```bash -docker compose pull -docker compose up -d -``` - -**Updates einspielen (Manuell):** -```bash -cd ~/qubicbob +cd /opt/qubic-bob/qubicbob git pull -cd build -cmake ../ -make -j$(nproc) -# Neustart des Bob-Prozesses +cd build && cmake ../ && make -j$(nproc) +sudo systemctl restart qubic-bob ``` --- ## 3. Lite Node -> Die Lite-Version des Qubic Core laeuft direkt auf dem Betriebssystem ohne UEFI-Umgebung. Unterstuetzt Mainnet (Beta) und lokales Testnet. +> The Lite version of Qubic Core runs directly on the operating system without a UEFI environment. Supports mainnet (beta) and local testnet. -### 3.1 Systemanforderungen +### 3.1 System Requirements -**Lokales Testnet:** +**Local Testnet:** -| Ressource | Minimum | -|-----------|---------| +| Resource | Minimum | +|----------|---------| | RAM | 16 GB | -| CPU | Moderner x86_64-Prozessor | -| Speicher | Minimal | +| CPU | Modern x86_64 processor | +| Storage | Minimal | **Mainnet (Beta):** -| Ressource | Minimum | -|-----------|---------| +| Resource | Minimum | +|----------|---------| | RAM | 64 GB | -| CPU | High-Frequency mit AVX2/AVX512 (z.B. AMD 7950x) | -| Speicher | 500 GB schnelle SSD | -| Netzwerk | 1 Gbit/s synchron | -| Epoch-Dateien | spectrum, universe, contract files (siehe unten) | +| CPU | High-frequency with AVX2/AVX512 (e.g., AMD 7950x) | +| Storage | 500 GB fast SSD | +| Network | 1 Gbit/s synchronous | +| Epoch Files | spectrum, universe, contract files (see below) | -### 3.2 Installation mit Docker +### 3.2 Quick Install (Script) -> **Hinweis:** Das offizielle Repo hat keine Docker-Dateien. Hier ein Dockerfile zum Selberbauen. +**Option A: Docker** -**Dockerfile erstellen:** +```bash +# update sources +apt update + +# download the installation script +wget -O lite-install.sh https://raw.githubusercontent.com/Pomm3sgab3l/Network_Guard/main/scripts/lite-install.sh + +# make it executable +chmod u+x lite-install.sh + +# install as Docker container (testnet) +./lite-install.sh docker --testnet + +# install as Docker container (mainnet) +./lite-install.sh docker --peers 1.2.3.4,5.6.7.8 +``` + +**Option B: Build from source with systemd service** + +```bash +wget -O lite-install.sh https://raw.githubusercontent.com/Pomm3sgab3l/Network_Guard/main/scripts/lite-install.sh +chmod u+x lite-install.sh + +# install from source (testnet) +./lite-install.sh manual --testnet + +# install from source (mainnet) +./lite-install.sh manual --peers 1.2.3.4,5.6.7.8 +``` + +**Script Options:** + +| Option | Description | Default | +|--------|-------------|---------| +| `--peers ` | Peer node IPs to connect to | *(none)* | +| `--testnet` | Enable testnet mode | mainnet | +| `--port ` | Node port | `21841` | +| `--data-dir ` | Data directory | `/opt/qubic-lite` | +| `--avx512` | Enable AVX-512 support | off | +| `--security-tick ` | Quorum bypass interval (testnet only) | `32` | +| `--ticking-delay ` | Ticking delay in ms (testnet only) | `1000` | + +### 3.3 Docker Setup (Manual) + +> **Note:** The official repo does not include Docker files. Below is a custom Dockerfile for building from source. + +**Dockerfile:** ```dockerfile FROM ubuntu:24.04 AS builder @@ -326,10 +354,11 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y \ build-essential clang cmake nasm git \ libc++-dev libc++abi-dev libjsoncpp-dev uuid-dev zlib1g-dev \ + g++ libstdc++-12-dev libfmt-dev \ && rm -rf /var/lib/apt/lists/* WORKDIR /app -RUN git clone https://github.com/vitwit/qubic-core-lite.git . +RUN git clone https://github.com/hackerby888/qubic-core-lite.git . WORKDIR /app/build RUN cmake .. \ @@ -355,94 +384,46 @@ EXPOSE 21841 ENTRYPOINT ["./Qubic"] ``` -**Docker Image bauen und starten:** +**Build and run:** ```bash -# 1. Projektordner erstellen mkdir -p ~/qubic-lite && cd ~/qubic-lite -# 2. Dockerfile erstellen (Inhalt von oben einfuegen) -nano Dockerfile - -# 3. Image bauen +# save the Dockerfile above, then: docker build -t qubic-lite-node . -# 4. Fuer Testnet starten -docker run -d \ - --name qubic-lite \ - --restart unless-stopped \ +# run (testnet) +docker run -d --name qubic-lite --restart unless-stopped \ -p 21841:21841 \ qubic-lite-node \ --security-tick 32 --ticking-delay 1000 -# 5. Fuer Mainnet starten (Epoch-Dateien benoetigt) -docker run -d \ - --name qubic-lite \ - --restart unless-stopped \ +# run (mainnet - mount epoch files directory) +docker run -d --name qubic-lite --restart unless-stopped \ -p 21841:21841 \ -v ~/qubic-data:/qubic/data \ qubic-lite-node \ --peers PEER_IP_1,PEER_IP_2,PEER_IP_3 ``` -> **Wichtig:** Fuer Mainnet muessen die Epoch-Dateien (`spectrum.XXX`, `universe.XXX`, `contract0000.XXX` etc.) im gemounteten Verzeichnis liegen. - -### 3.3 Manuelle Installation (Build from Source) - -Einrichtungs-Skript fuer Ubuntu/Debian: - -```bash -#!/bin/bash -# lite-node-install.sh - Qubic Lite Node Installation Script - -set -e - -echo "=== Qubic Lite Node Installation ===" - -# 1. System-Updates und Abhaengigkeiten -sudo apt update && sudo apt upgrade -y -sudo apt install -y build-essential clang cmake nasm git \ - libc++-dev libc++abi-dev libjsoncpp-dev uuid-dev zlib1g-dev - -# 2. Repository klonen -git clone https://github.com/vitwit/qubic-core-lite.git -cd qubic-core-lite - -# 3. Build-Verzeichnis erstellen -mkdir -p build && cd build - -# 4. CMake konfigurieren -cmake .. \ - -DCMAKE_C_COMPILER=clang \ - -DCMAKE_CXX_COMPILER=clang++ \ - -DBUILD_TESTS=OFF \ - -DBUILD_BINARY=ON \ - -DCMAKE_BUILD_TYPE=Release \ - -DENABLE_AVX512=OFF +> **Important:** For mainnet, epoch files (`spectrum.XXX`, `universe.XXX`, `contract0000.XXX`, etc.) must be placed in the mounted data volume. -# 5. Bauen -cmake --build . -- -j$(nproc) - -echo "=== Installation abgeschlossen ===" -echo "Binary liegt unter: $(pwd)/src/Qubic" -echo "" -echo "Testnet starten: ./src/Qubic --security-tick 32 --ticking-delay 1000" -echo "Mainnet starten: ./src/Qubic --peers PEER_IP_1,PEER_IP_2" -``` +### 3.4 Build from Source (Manual) -**Schritt-fuer-Schritt (manuell):** +Step-by-step guide for building Lite Node without Docker: ```bash -# 1. Abhaengigkeiten installieren +# 1. install dependencies sudo apt update && sudo apt upgrade -y sudo apt install -y build-essential clang cmake nasm git \ - libc++-dev libc++abi-dev libjsoncpp-dev uuid-dev zlib1g-dev + libc++-dev libc++abi-dev libjsoncpp-dev uuid-dev zlib1g-dev \ + g++ libstdc++-12-dev libfmt-dev -# 2. Repository klonen -git clone https://github.com/vitwit/qubic-core-lite.git +# 2. clone the repository +git clone https://github.com/hackerby888/qubic-core-lite.git cd qubic-core-lite -# 3. Bauen +# 3. build mkdir -p build && cd build cmake .. \ -DCMAKE_C_COMPILER=clang \ @@ -453,111 +434,106 @@ cmake .. \ -DENABLE_AVX512=OFF cmake --build . -- -j$(nproc) -# 4. Starten (Testnet) +# 4a. start (testnet) ./src/Qubic --security-tick 32 --ticking-delay 1000 -# 5. Starten (Mainnet) - Epoch-Dateien vorher bereitstellen! +# 4b. start (mainnet - epoch files required!) ./src/Qubic --peers PEER_IP_1,PEER_IP_2,PEER_IP_3 ``` -### 3.4 Konfiguration +> **Note:** The installation script (`lite-install.sh manual`) sets up a systemd service automatically so the node starts on boot. -Die Lite Node wird ueber **Kommandozeilen-Parameter** und **Quellcode-Einstellungen** konfiguriert. +### 3.5 Configuration Reference -**Kommandozeilen-Parameter:** +The Lite Node is configured via **command-line arguments** and **source code settings**. -| Parameter | Beschreibung | Beispiel | -|-----------|-------------|---------| -| `--security-tick N` | Umgeht Quorum-Verifikation alle N Ticks (Testnet) | `--security-tick 32` | -| `--ticking-delay N` | Verlangsamt Testnet-Verarbeitung um N ms | `--ticking-delay 1000` | -| `--peers IP1,IP2` | Peer-Nodes direkt angeben | `--peers 1.2.3.4,5.6.7.8` | +**Command-Line Arguments:** -**Quellcode-Konfiguration (vor dem Build):** +| Argument | Description | Example | +|----------|-------------|---------| +| `--security-tick ` | Bypass quorum verification every n ticks (testnet) | `--security-tick 32` | +| `--ticking-delay ` | Slow down testnet processing by n ms | `--ticking-delay 1000` | +| `--peers ` | Specify peer nodes directly | `--peers 1.2.3.4,5.6.7.8` | -| Einstellung in `qubic.cpp` | Beschreibung | -|---------------------------|-------------| -| `#define TESTNET` | Aktiviert Testnet-Modus (auskommentieren fuer Mainnet) | -| `USE_SWAP` | Nutzt Disk als RAM-Fallback | +**Source Code Settings (before building):** -**Fuer Mainnet:** +| Setting | File | Description | +|---------|------|-------------| +| `#define TESTNET` | `qubic.cpp` | Enable testnet mode (comment out for mainnet) | +| `USE_SWAP` | `qubic.cpp` | Use disk as RAM fallback when memory is limited | +| `knownPublicPeers` | `private_settings.h` | Set peer IPs for mainnet | +| `TICK_STORAGE_AUTOSAVE_MODE` | `private_settings.h` | Set to `1` for snapshot persistence | -1. In `qubic.cpp` die Zeile `#define TESTNET` auskommentieren -2. In `private_settings.h` die `knownPublicPeers` mit aktiven Peer-IPs fuellen -3. Epoch-Dateien im Startverzeichnis ablegen: - - `spectrum.XXX` - - `universe.XXX` - - `contract0000.XXX` bis `contractNNNN.XXX` -4. Peers von [qubic.li Network Dashboard](https://app.qubic.li/network/live) holen +**Mainnet Preparation Checklist:** -### 3.5 Betrieb +1. Comment out `#define TESTNET` in `qubic.cpp` +2. Add active peer IPs to `knownPublicPeers` in `private_settings.h` +3. Rebuild the project +4. Place epoch files in the working directory: + - `spectrum.XXX`, `universe.XXX` + - `contract0000.XXX` through `contractNNNN.XXX` +5. Get current peers from [qubic.li Network Dashboard](https://app.qubic.li/network/live) -**Testnet starten:** -```bash -# Mit tmux fuer Persistenz -tmux new -s qubic -./Qubic --security-tick 32 --ticking-delay 1000 -# Tmux verlassen: Ctrl+B, dann D -``` +### 3.6 Maintenance & Troubleshooting -**Mainnet starten:** +**Docker commands:** ```bash -tmux new -s qubic -./Qubic --peers PEER_IP_1,PEER_IP_2,PEER_IP_3 -# F12 druecken um in den MAIN-Modus zu wechseln +docker logs -f qubic-lite # view logs +docker restart qubic-lite # restart +docker stop qubic-lite # stop +docker build -t qubic-lite-node . && \ + docker rm -f qubic-lite && \ + docker run -d --name qubic-lite ... # rebuild & restart ``` -**Als systemd Service einrichten:** +**Systemd commands (manual install):** ```bash -sudo tee /etc/systemd/system/qubic-lite.service > /dev/null <= 18.1.0, CMake >= 3.14, NASM >= 2.16.03 pruefen | -| Mainnet synchronisiert nicht | Epoch-Dateien pruefen, Peers aktualisieren | -| Nicht genug RAM | `USE_SWAP` in Quellcode aktivieren | +| Problem | Solution | +|---------|----------| +| Node stops ticking after restart | Delete the `system` file in the working directory | +| Build fails | Verify: Clang >= 18.1.0, CMake >= 3.14, NASM >= 2.16.03 | +| Mainnet won't sync | Check epoch files, update peer IPs | +| Not enough RAM | Enable `USE_SWAP` in source code before building | +| Docker build fails on AVX | Make sure host CPU supports AVX2; disable AVX-512 if unsupported | --- -## 4. Referenzen +## 4. References -| Ressource | Link | -|-----------|------| +| Resource | Link | +|----------|------| | Bob Node Repository | [github.com/krypdkat/qubicbob](https://github.com/krypdkat/qubicbob) | | Bob Node Docker Hub | [j0et0m/qubic-bob](https://hub.docker.com/r/j0et0m/qubic-bob) | | Bob Node Config Docs | [CONFIG_FILE.MD](https://github.com/krypdkat/qubicbob/blob/master/CONFIG_FILE.MD) | -| Bob Node REST API | [RESTAPI/](https://github.com/krypdkat/qubicbob/tree/master/RESTAPI) | -| Lite Node Repository | [github.com/vitwit/qubic-core-lite](https://github.com/vitwit/qubic-core-lite) | -| Lite Node Linux Build | [README_CLANG.md](https://github.com/vitwit/qubic-core-lite/blob/main/README_CLANG.md) | +| Bob Node REST API Docs | [RESTAPI/](https://github.com/krypdkat/qubicbob/tree/master/RESTAPI) | +| Bob Node Docker Docs | [docker/](https://github.com/krypdkat/qubicbob/tree/master/docker) | +| Lite Node Repository | [github.com/hackerby888/qubic-core-lite](https://github.com/hackerby888/qubic-core-lite) | +| Lite Node Linux Build Guide | [README_CLANG.md](https://github.com/hackerby888/qubic-core-lite/blob/main/README_CLANG.md) | | Qubic Core (Full Node) | [github.com/qubic/core](https://github.com/qubic/core) | -| Qubic Node Types Docs | [docs.qubic.org/learn/nodes](https://docs.qubic.org/learn/nodes/) | +| Qubic Node Types | [docs.qubic.org/learn/nodes](https://docs.qubic.org/learn/nodes/) | | Qubic Network Dashboard | [app.qubic.li/network/live](https://app.qubic.li/network/live) | -| Beispiel-Doku (qubic-li/client) | [github.com/qubic-li/client](https://github.com/qubic-li/client) | +| Example Docs (qubic-li/client) | [github.com/qubic-li/client](https://github.com/qubic-li/client) | diff --git a/scripts/bob-install.sh b/scripts/bob-install.sh new file mode 100755 index 0000000..0b70026 --- /dev/null +++ b/scripts/bob-install.sh @@ -0,0 +1,382 @@ +#!/bin/bash +############################################################################### +# Bob Node Installation Script +# Installs the Qubic Bob Node (Indexer & REST API) +# +# Usage: +# ./bob-install.sh [MODE] [OPTIONS] +# +# Modes: +# docker-standalone All-in-one Docker container (Bob + Redis + KVRocks) +# docker-compose Modular Docker setup (separate containers) +# manual Build from source with systemd service +# +# Options: +# --peers Trusted peers to sync from +# --threads Max threads (0 = auto, default: 0) +# --rpc-port REST API / JSON-RPC port (default: 40420) +# --server-port P2P server port (default: 21842) +# --data-dir Data directory (default: /opt/qubic-bob) +# +# Examples: +# ./bob-install.sh docker-standalone +# ./bob-install.sh docker-compose --peers 1.2.3.4:21841,5.6.7.8:21841 +# ./bob-install.sh manual --peers 1.2.3.4:21841 --threads 8 +# +############################################################################### + +set -e + +# ─── Colors ────────────────────────────────────────────────────────────────── +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +CYAN='\033[0;36m' +NC='\033[0m' + +# ─── Defaults ──────────────────────────────────────────────────────────────── +MODE="" +PEERS="" +MAX_THREADS=0 +RPC_PORT=40420 +SERVER_PORT=21842 +DATA_DIR="/opt/qubic-bob" +REPO_URL="https://github.com/krypdkat/qubicbob.git" +DOCKER_IMAGE="j0et0m/qubic-bob:latest" + +# ─── Functions ─────────────────────────────────────────────────────────────── + +print_banner() { + echo -e "${CYAN}" + echo "╔══════════════════════════════════════════════════╗" + echo "║ Bob Node Installation Script ║" + echo "║ Qubic Blockchain Indexer & REST API ║" + echo "╚══════════════════════════════════════════════════╝" + echo -e "${NC}" +} + +log_info() { + echo -e "${GREEN}[INFO]${NC} $1" +} + +log_warn() { + echo -e "${YELLOW}[WARN]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +check_root() { + if [ "$EUID" -ne 0 ]; then + log_error "This script must be run as root (use sudo)" + exit 1 + fi +} + +check_docker() { + if ! command -v docker &> /dev/null; then + log_info "Docker not found. Installing Docker..." + curl -fsSL https://get.docker.com | sh + systemctl enable docker + systemctl start docker + log_info "Docker installed successfully" + else + log_info "Docker is already installed" + fi + + if ! docker compose version &> /dev/null; then + log_error "Docker Compose plugin not found. Please install it." + exit 1 + fi +} + +parse_args() { + MODE="$1" + shift || true + + while [[ $# -gt 0 ]]; do + case $1 in + --peers) + PEERS="$2" + shift 2 + ;; + --threads) + MAX_THREADS="$2" + shift 2 + ;; + --rpc-port) + RPC_PORT="$2" + shift 2 + ;; + --server-port) + SERVER_PORT="$2" + shift 2 + ;; + --data-dir) + DATA_DIR="$2" + shift 2 + ;; + *) + log_error "Unknown option: $1" + show_usage + exit 1 + ;; + esac + done + + if [ -z "$MODE" ]; then + show_usage + exit 1 + fi +} + +show_usage() { + echo "Usage: $0 [MODE] [OPTIONS]" + echo "" + echo "Modes:" + echo " docker-standalone All-in-one Docker container" + echo " docker-compose Modular Docker setup" + echo " manual Build from source" + echo "" + echo "Options:" + echo " --peers Trusted peers" + echo " --threads Max threads (0=auto)" + echo " --rpc-port REST API port (default: 40420)" + echo " --server-port P2P port (default: 21842)" + echo " --data-dir Data dir (default: /opt/qubic-bob)" +} + +generate_config() { + local config_file="$1" + local keydb_host="${2:-127.0.0.1}" + local kvrocks_host="${3:-127.0.0.1}" + + local trusted_nodes="[]" + if [ -n "$PEERS" ]; then + trusted_nodes="[$(echo "$PEERS" | sed 's/,/","/g' | sed 's/^/"/' | sed 's/$/"/' )]" + fi + + cat > "$config_file" << CONFIGEOF +{ + "p2p-node": [], + "trusted-node": ${trusted_nodes}, + "request-cycle-ms": 100, + "request-logging-cycle-ms": 30, + "future-offset": 3, + "log-level": "info", + "keydb-url": "tcp://${keydb_host}:6379", + "run-server": true, + "server-port": ${SERVER_PORT}, + "rpc-port": ${RPC_PORT}, + "arbitrator-identity": "AFZPUAIYVPNUYGJRQVLUKOPPVLHAZQTGLYAAUUNBXFTVTAMSBKQBLEIEPCVJ", + "tick-storage-mode": "kvrocks", + "kvrocks-url": "tcp://${kvrocks_host}:6666", + "tx-storage-mode": "kvrocks", + "tx_tick_to_live": 10000, + "max-thread": ${MAX_THREADS}, + "spam-qu-threshold": 100 +} +CONFIGEOF + + log_info "Configuration written to ${config_file}" +} + +# ─── Docker Standalone ─────────────────────────────────────────────────────── + +install_docker_standalone() { + log_info "Installing Bob Node (Docker Standalone)..." + check_docker + + mkdir -p "$DATA_DIR" && cd "$DATA_DIR" + + # Download docker-compose file + curl -sSL -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/docker-compose.standalone.yml + + # Generate config + generate_config "$DATA_DIR/bob.json" "127.0.0.1" "127.0.0.1" + + # Start + docker compose -f docker-compose.standalone.yml up -d + + log_info "Bob Node (Standalone) is running!" + log_info "P2P Port: ${SERVER_PORT}" + log_info "RPC Port: ${RPC_PORT}" + log_info "Data Dir: ${DATA_DIR}" + echo "" + log_info "Useful commands:" + echo " docker compose -f ${DATA_DIR}/docker-compose.standalone.yml logs -f" + echo " docker compose -f ${DATA_DIR}/docker-compose.standalone.yml restart" + echo " docker compose -f ${DATA_DIR}/docker-compose.standalone.yml down" +} + +# ─── Docker Compose ────────────────────────────────────────────────────────── + +install_docker_compose() { + log_info "Installing Bob Node (Docker Compose)..." + check_docker + + mkdir -p "$DATA_DIR" && cd "$DATA_DIR" + + # Download all required files + curl -sSL -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/docker-compose.yml + curl -sSL -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/keydb.conf + curl -sSL -O https://raw.githubusercontent.com/krypdkat/qubicbob/master/docker/examples/kvrocks.conf + + # Generate config with container hostnames + generate_config "$DATA_DIR/bob.json" "keydb" "kvrocks" + + # Start + docker compose up -d + + log_info "Bob Node (Docker Compose) is running!" + log_info "P2P Port: ${SERVER_PORT}" + log_info "RPC Port: ${RPC_PORT}" + log_info "Data Dir: ${DATA_DIR}" + echo "" + log_info "Useful commands:" + echo " docker compose -C ${DATA_DIR} logs -f" + echo " docker compose -C ${DATA_DIR} restart" + echo " docker compose -C ${DATA_DIR} down" +} + +# ─── Manual Build ──────────────────────────────────────────────────────────── + +install_manual() { + log_info "Installing Bob Node (Build from Source)..." + + # Install dependencies + log_info "Installing system dependencies..." + apt update && apt upgrade -y + apt install -y build-essential cmake git libjsoncpp-dev \ + uuid-dev libhiredis-dev zlib1g-dev unzip wget \ + net-tools tmux lsb-release + + # Install KeyDB + log_info "Installing KeyDB..." + if ! command -v keydb-server &> /dev/null; then + echo "deb https://download.keydb.dev/open-source-dist $(lsb_release -sc) main" | \ + tee /etc/apt/sources.list.d/keydb.list + wget -O /etc/apt/trusted.gpg.d/keydb.gpg https://download.keydb.dev/open-source-dist/keyring.gpg + apt update + apt install -y keydb + systemctl enable keydb-server + systemctl start keydb-server + else + log_info "KeyDB is already installed" + fi + + # Install KVRocks + log_info "Installing KVRocks..." + if ! command -v kvrocks &> /dev/null; then + cd /tmp + git clone --branch v2.9.0 https://github.com/apache/kvrocks.git + cd kvrocks + mkdir -p build && cd build + cmake .. -DCMAKE_BUILD_TYPE=Release + make -j"$(nproc)" + cp src/kvrocks /usr/local/bin/ + cd /tmp && rm -rf kvrocks + + # Create KVRocks systemd service + cat > /etc/systemd/system/kvrocks.service << 'SERVICEEOF' +[Unit] +Description=KVRocks Server +After=network.target + +[Service] +Type=simple +ExecStart=/usr/local/bin/kvrocks --bind 0.0.0.0 --port 6666 --dir /var/lib/kvrocks +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +SERVICEEOF + + mkdir -p /var/lib/kvrocks + systemctl daemon-reload + systemctl enable kvrocks + systemctl start kvrocks + else + log_info "KVRocks is already installed" + fi + + # Build Bob Node + log_info "Building Bob Node..." + mkdir -p "$DATA_DIR" && cd "$DATA_DIR" + if [ -d "qubicbob" ]; then + cd qubicbob && git pull + else + git clone "$REPO_URL" + cd qubicbob + fi + mkdir -p build && cd build + cmake ../ + make -j"$(nproc)" + + # Generate config + generate_config "$DATA_DIR/qubicbob/build/config.json" + + # Create systemd service + log_info "Creating systemd service..." + cat > /etc/systemd/system/qubic-bob.service << SERVICEEOF +[Unit] +Description=Qubic Bob Node +After=network.target keydb-server.service kvrocks.service +Wants=keydb-server.service kvrocks.service + +[Service] +Type=simple +WorkingDirectory=${DATA_DIR}/qubicbob/build +ExecStart=${DATA_DIR}/qubicbob/build/bob ${DATA_DIR}/qubicbob/build/config.json +Restart=on-failure +RestartSec=10 + +[Install] +WantedBy=multi-user.target +SERVICEEOF + + systemctl daemon-reload + systemctl enable qubic-bob + systemctl start qubic-bob + + log_info "Bob Node is running as systemd service!" + log_info "P2P Port: ${SERVER_PORT}" + log_info "RPC Port: ${RPC_PORT}" + log_info "Binary: ${DATA_DIR}/qubicbob/build/bob" + log_info "Config: ${DATA_DIR}/qubicbob/build/config.json" + echo "" + log_info "Useful commands:" + echo " systemctl status qubic-bob" + echo " journalctl -u qubic-bob -f" + echo " systemctl restart qubic-bob" +} + +# ─── Main ──────────────────────────────────────────────────────────────────── + +print_banner +check_root +parse_args "$@" + +case "$MODE" in + docker-standalone) + install_docker_standalone + ;; + docker-compose) + install_docker_compose + ;; + manual) + install_manual + ;; + *) + log_error "Unknown mode: $MODE" + show_usage + exit 1 + ;; +esac + +echo "" +echo -e "${GREEN}╔══════════════════════════════════════════════════╗${NC}" +echo -e "${GREEN}║ Installation completed! ║${NC}" +echo -e "${GREEN}╚══════════════════════════════════════════════════╝${NC}" diff --git a/scripts/lite-install.sh b/scripts/lite-install.sh new file mode 100755 index 0000000..df323b6 --- /dev/null +++ b/scripts/lite-install.sh @@ -0,0 +1,372 @@ +#!/bin/bash +############################################################################### +# Qubic Lite Node Installation Script +# Installs the Qubic Core Lite Node (runs on OS without UEFI) +# +# Usage: +# ./lite-install.sh [MODE] [OPTIONS] +# +# Modes: +# docker Build and run via Docker container +# manual Build from source with systemd service +# +# Options: +# --peers Peer node IPs to connect to +# --testnet Enable testnet mode +# --port Node port (default: 21841) +# --data-dir Data directory (default: /opt/qubic-lite) +# --avx512 Enable AVX-512 support +# --security-tick Quorum bypass interval, testnet (default: 32) +# --ticking-delay Ticking delay in ms, testnet (default: 1000) +# +# Examples: +# ./lite-install.sh docker --testnet +# ./lite-install.sh docker --peers 1.2.3.4,5.6.7.8 +# ./lite-install.sh manual --testnet +# ./lite-install.sh manual --peers 1.2.3.4,5.6.7.8 --avx512 +# +############################################################################### + +set -e + +# ─── Colors ────────────────────────────────────────────────────────────────── +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +CYAN='\033[0;36m' +NC='\033[0m' + +# ─── Defaults ──────────────────────────────────────────────────────────────── +MODE="" +PEERS="" +TESTNET=false +NODE_PORT=21841 +DATA_DIR="/opt/qubic-lite" +REPO_URL="https://github.com/hackerby888/qubic-core-lite.git" +ENABLE_AVX512=false +SECURITY_TICK=32 +TICKING_DELAY=1000 + +# ─── Functions ─────────────────────────────────────────────────────────────── + +print_banner() { + echo -e "${CYAN}" + echo "╔══════════════════════════════════════════════════╗" + echo "║ Qubic Lite Node Installation Script ║" + echo "║ Core Lite (no UEFI required) ║" + echo "╚══════════════════════════════════════════════════╝" + echo -e "${NC}" +} + +log_info() { + echo -e "${GREEN}[INFO]${NC} $1" +} + +log_warn() { + echo -e "${YELLOW}[WARN]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +check_root() { + if [ "$EUID" -ne 0 ]; then + log_error "This script must be run as root (use sudo)" + exit 1 + fi +} + +check_docker() { + if ! command -v docker &> /dev/null; then + log_info "Docker not found. Installing Docker..." + curl -fsSL https://get.docker.com | sh + systemctl enable docker + systemctl start docker + log_info "Docker installed successfully" + else + log_info "Docker is already installed" + fi +} + +parse_args() { + MODE="$1" + shift || true + + while [[ $# -gt 0 ]]; do + case $1 in + --peers) + PEERS="$2" + shift 2 + ;; + --testnet) + TESTNET=true + shift + ;; + --port) + NODE_PORT="$2" + shift 2 + ;; + --data-dir) + DATA_DIR="$2" + shift 2 + ;; + --avx512) + ENABLE_AVX512=true + shift + ;; + --security-tick) + SECURITY_TICK="$2" + shift 2 + ;; + --ticking-delay) + TICKING_DELAY="$2" + shift 2 + ;; + *) + log_error "Unknown option: $1" + show_usage + exit 1 + ;; + esac + done + + if [ -z "$MODE" ]; then + show_usage + exit 1 + fi +} + +show_usage() { + echo "Usage: $0 [MODE] [OPTIONS]" + echo "" + echo "Modes:" + echo " docker Build and run via Docker" + echo " manual Build from source" + echo "" + echo "Options:" + echo " --peers Peer node IPs" + echo " --testnet Enable testnet mode" + echo " --port Node port (default: 21841)" + echo " --data-dir Data dir (default: /opt/qubic-lite)" + echo " --avx512 Enable AVX-512 support" + echo " --security-tick Quorum bypass interval (default: 32)" + echo " --ticking-delay Ticking delay ms (default: 1000)" +} + +build_run_args() { + local args="" + + if [ "$TESTNET" = true ]; then + args="--security-tick ${SECURITY_TICK} --ticking-delay ${TICKING_DELAY}" + fi + + if [ -n "$PEERS" ]; then + args="${args} --peers ${PEERS}" + fi + + echo "$args" +} + +get_avx512_flag() { + if [ "$ENABLE_AVX512" = true ]; then + echo "ON" + else + echo "OFF" + fi +} + +# ─── Docker ────────────────────────────────────────────────────────────────── + +install_docker() { + log_info "Installing Qubic Lite Node (Docker)..." + check_docker + + mkdir -p "$DATA_DIR" && cd "$DATA_DIR" + + local avx512_flag + avx512_flag=$(get_avx512_flag) + + # Create Dockerfile + cat > "$DATA_DIR/Dockerfile" << DOCKEREOF +FROM ubuntu:24.04 AS builder + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \\ + build-essential clang cmake nasm git \\ + libc++-dev libc++abi-dev libjsoncpp-dev uuid-dev zlib1g-dev \\ + g++ libstdc++-12-dev libfmt-dev \\ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app +RUN git clone ${REPO_URL} . + +WORKDIR /app/build +RUN cmake .. \\ + -DCMAKE_C_COMPILER=clang \\ + -DCMAKE_CXX_COMPILER=clang++ \\ + -DBUILD_TESTS=OFF \\ + -DBUILD_BINARY=ON \\ + -DCMAKE_BUILD_TYPE=Release \\ + -DENABLE_AVX512=${avx512_flag} \\ + && cmake --build . -- -j\$(nproc) + +FROM ubuntu:24.04 + +RUN apt-get update && apt-get install -y \\ + libc++1 libc++abi1 libjsoncpp25 \\ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /qubic +COPY --from=builder /app/build/src/Qubic . + +EXPOSE ${NODE_PORT} + +ENTRYPOINT ["./Qubic"] +DOCKEREOF + + # Build image + log_info "Building Docker image (this may take a few minutes)..." + docker build -t qubic-lite-node "$DATA_DIR" + + # Stop existing container if running + docker rm -f qubic-lite 2>/dev/null || true + + # Build run arguments + local run_args + run_args=$(build_run_args) + + # Start container + log_info "Starting Qubic Lite Node container..." + docker run -d \ + --name qubic-lite \ + --restart unless-stopped \ + -p "${NODE_PORT}:${NODE_PORT}" \ + -v "${DATA_DIR}/data:/qubic/data" \ + qubic-lite-node \ + $run_args + + log_info "Qubic Lite Node (Docker) is running!" + log_info "Port: ${NODE_PORT}" + log_info "Mode: $([ "$TESTNET" = true ] && echo 'Testnet' || echo 'Mainnet')" + log_info "Data Dir: ${DATA_DIR}/data" + echo "" + log_info "Useful commands:" + echo " docker logs -f qubic-lite" + echo " docker restart qubic-lite" + echo " docker stop qubic-lite" + + if [ "$TESTNET" = false ] && [ -z "$PEERS" ]; then + echo "" + log_warn "No peers specified for mainnet. The node may not sync." + log_warn "Use --peers to specify peer IPs or add epoch files to ${DATA_DIR}/data" + fi +} + +# ─── Manual Build ──────────────────────────────────────────────────────────── + +install_manual() { + log_info "Installing Qubic Lite Node (Build from Source)..." + + # Install dependencies + log_info "Installing system dependencies..." + apt update && apt upgrade -y + apt install -y build-essential clang cmake nasm git \ + libc++-dev libc++abi-dev libjsoncpp-dev uuid-dev zlib1g-dev \ + g++ libstdc++-12-dev libfmt-dev tmux + + # Clone or update repo + log_info "Cloning Qubic Core Lite repository..." + mkdir -p "$DATA_DIR" && cd "$DATA_DIR" + if [ -d "qubic-core-lite" ]; then + cd qubic-core-lite && git pull + else + git clone "$REPO_URL" + cd qubic-core-lite + fi + + # Build + local avx512_flag + avx512_flag=$(get_avx512_flag) + + log_info "Building Qubic Lite Node..." + mkdir -p build && cd build + cmake .. \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DBUILD_TESTS=OFF \ + -DBUILD_BINARY=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_AVX512="${avx512_flag}" + cmake --build . -- -j"$(nproc)" + + # Build run arguments + local run_args + run_args=$(build_run_args) + + # Create systemd service + log_info "Creating systemd service..." + cat > /etc/systemd/system/qubic-lite.service << SERVICEEOF +[Unit] +Description=Qubic Lite Node +After=network.target + +[Service] +Type=simple +WorkingDirectory=${DATA_DIR}/qubic-core-lite/build/src +ExecStart=${DATA_DIR}/qubic-core-lite/build/src/Qubic ${run_args} +Restart=on-failure +RestartSec=10 +LimitNOFILE=65535 + +[Install] +WantedBy=multi-user.target +SERVICEEOF + + systemctl daemon-reload + systemctl enable qubic-lite + systemctl start qubic-lite + + log_info "Qubic Lite Node is running as systemd service!" + log_info "Port: ${NODE_PORT}" + log_info "Mode: $([ "$TESTNET" = true ] && echo 'Testnet' || echo 'Mainnet')" + log_info "Binary: ${DATA_DIR}/qubic-core-lite/build/src/Qubic" + echo "" + log_info "Useful commands:" + echo " systemctl status qubic-lite" + echo " journalctl -u qubic-lite -f" + echo " systemctl restart qubic-lite" + + if [ "$TESTNET" = false ] && [ -z "$PEERS" ]; then + echo "" + log_warn "No peers specified for mainnet. The node may not sync." + log_warn "Add peers: edit /etc/systemd/system/qubic-lite.service" + log_warn "Then: systemctl daemon-reload && systemctl restart qubic-lite" + fi +} + +# ─── Main ──────────────────────────────────────────────────────────────────── + +print_banner +check_root +parse_args "$@" + +case "$MODE" in + docker) + install_docker + ;; + manual) + install_manual + ;; + *) + log_error "Unknown mode: $MODE" + show_usage + exit 1 + ;; +esac + +echo "" +echo -e "${GREEN}╔══════════════════════════════════════════════════╗${NC}" +echo -e "${GREEN}║ Installation completed! ║${NC}" +echo -e "${GREEN}╚══════════════════════════════════════════════════╝${NC}"