From 88d1f35c4eacdb5e15477aeabd8e698730633ea1 Mon Sep 17 00:00:00 2001 From: msp-9009 Date: Fri, 9 Jan 2026 20:47:38 +0530 Subject: [PATCH] refactor: include relay functionality by default and remove relay support, update related scripts and configurations --- .gitignore | 1 + README.md | 7 ++----- blockdag.sh | 23 ++++++++++++----------- docker-compose.full.yml | 15 ++++++--------- docker-compose.relay.yml | 35 ----------------------------------- docker-compose.yml | 14 ++++++-------- node.sh | 12 ++++++++++++ restart.sh | 26 ++++++++++++++------------ restartWithCleanup.sh | 26 ++++++++++++++------------ stop.sh | 6 +----- 10 files changed, 68 insertions(+), 97 deletions(-) delete mode 100644 docker-compose.relay.yml diff --git a/.gitignore b/.gitignore index 8d6070f..bc3a465 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .env bin/bdag/* wallet.txt +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 47dd0bb..0aa9967 100755 --- a/README.md +++ b/README.md @@ -115,7 +115,6 @@ Optional for Linux users: ```bash ./blockdag.sh # default miner node ./blockdag.sh full # validation without mining - ./blockdag.sh relay # gateway relay mode ``` The script resolves your address, exports it as `PUB_ETH_ADDR`, selects the matching compose file, and calls node.sh`. Set `NODE_ROLE=` in your environment if you prefer not to pass a CLI argument. @@ -143,15 +142,13 @@ This repository now ships dedicated Docker Compose files for each supported node |-----------|--------------|------------| | Miner | `docker-compose.yml` | Enables mining via `--miner`/`--generate` and exposes JSON-RPC/WebSocket endpoints for local tooling. | | Full | `docker-compose.full.yml` | Syncs and validates the network without mining. | -| Relay | `docker-compose.relay.yml` | Runs the gateway stack (`--gateway`) to proxy DAG/EVM traffic for external clients. | > **Tip:** Any of the non-archive templates can double as an archive node just > by keeping the default `--gcmode=archive`. Removing that flag reverts to the > previous pruned behaviour. To start a specific role with the helper script, run `./blockdag.sh `. For -example, `./blockdag.sh relay` loads `docker-compose.relay.yml` while -`./blockdag.sh full` launches the `docker-compose.full.yml`. Use +example, `./blockdag.sh full` launches the `docker-compose.full.yml`. Use `./blockdag.sh` to fall back to the default `docker-compose.yml` miner node. ### Launching a specific node type @@ -181,7 +178,7 @@ archive deployments. Use the helper scripts at the repository root: -- `stop.sh [role|all]` – stops containers for the selected role (defaults to `miner`). Pass `all` to shut down miner, full, and relay stacks in one go. +- `stop.sh [role|all]` – stops containers for the selected role (defaults to `miner`). Pass `all` to shut down miner and full stacks in one go. - `restart.sh [role]` – shuts down Docker Compose for the selected role (defaults to `miner`), removes the image referenced by the compose file, and relaunches using your configured wallet. - `restartWithCleanup.sh [role]` – same as above but also clears `./bin/bdag/*` (data, logs, any cached binaries). **Back up your wallet before running this.** - `install_docker.sh` – Ubuntu/WSL convenience installer. Review the script before executing (`sudo ./install_docker.sh`). diff --git a/blockdag.sh b/blockdag.sh index 2ddbeb5..486babc 100755 --- a/blockdag.sh +++ b/blockdag.sh @@ -11,7 +11,6 @@ Usage: ./blockdag.sh [ROLE] ROLE may be one of: miner - use docker-compose.yml (default) full - use docker-compose.full.yml - relay - use docker-compose.relay.yml You can also set NODE_ROLE environment variable instead of passing ROLE. USAGE @@ -27,9 +26,6 @@ case "$ROLE_INPUT" in full) COMPOSE_FILE="docker-compose.full.yml" ;; - relay) - COMPOSE_FILE="docker-compose.relay.yml" - ;; default|miner) COMPOSE_FILE="docker-compose.yml" ;; @@ -41,6 +37,10 @@ case "$ROLE_INPUT" in esac ENV_FILE="$SCRIPT_DIR/.env" +NEEDS_MINING_ADDR=false +if [ "$COMPOSE_FILE" = "docker-compose.yml" ]; then + NEEDS_MINING_ADDR=true +fi # load PUB_ETH_ADDR from .env if present if [ -f "$ENV_FILE" ]; then @@ -48,13 +48,14 @@ if [ -f "$ENV_FILE" ]; then source "$ENV_FILE" fi -if [ -z "${PUB_ETH_ADDR:-}" ]; then - if [ -f "$SCRIPT_DIR/wallet.txt" ]; then - PUB_ETH_ADDR=$(tail -n 1 "$SCRIPT_DIR/wallet.txt") - else - echo "PUB_ETH_ADDR not set. Please create $ENV_FILE or wallet.txt" >&2 - exit 1 - fi +PUB_ETH_ADDR="${PUB_ETH_ADDR:-}" +if [ -z "$PUB_ETH_ADDR" ] && [ -f "$SCRIPT_DIR/wallet.txt" ]; then + PUB_ETH_ADDR=$(tail -n 1 "$SCRIPT_DIR/wallet.txt") +fi + +if $NEEDS_MINING_ADDR && [ -z "$PUB_ETH_ADDR" ]; then + echo "PUB_ETH_ADDR not set. Please create $ENV_FILE or wallet.txt" >&2 + exit 1 fi export PUB_ETH_ADDR diff --git a/docker-compose.full.yml b/docker-compose.full.yml index 2266ca6..a0086d8 100644 --- a/docker-compose.full.yml +++ b/docker-compose.full.yml @@ -1,8 +1,7 @@ -version: '3' services: full_node: - image: blockdagnetwork/awakening:v0.0.3 + image: blockdagnetwork/awakening:v0.1.0 container_name: blockdag-full-testnet restart: unless-stopped ports: @@ -16,12 +15,10 @@ services: - ./bin/bdag/logs:/bdag/logs environment: NODE_ARGS: >- - --testnet --rpclisten=0.0.0.0:38131 --notls --rpcuser=test --rpcpass=test - --walletpass=test - --evmenv="--http --http.port=18545 --http.addr=0.0.0.0 - --http.api=net,web3,eth,bdag,txpool,debug --allow-insecure-unlock --ws - --ws.addr=0.0.0.0 --ws.port=18546 --rpc.allow-unprotected-txs --gcmode=archive" - --datadir=/bdag/data + --testnet --rpclisten=0.0.0.0:38131 --notls --rpcuser=test --rpcpass=test ${MINING_ADDR_FLAG:-} + --evmenv="--http.api=net,web3,eth,bdag,txpool,debug --rpc.allow-unprotected-txs --gcmode=archive" + --miningstatesync --datadir=/bdag/data --logdir=/bdag/logs --maxpeers=250 + --evm.http.port=18545 --evm.http.addr=0.0.0.0 --evm.ws.port=18546 --addpeer=/ip4/13.245.135.249/tcp/18150/p2p/16Uiu2HAm3hjo65MZvBEJuVASMoSDsXfMzC8m2ZEAeK8CjjJkRvf9 RPC_URL: ws://127.0.0.1:18546 CONTRACT_ADDRESS: 0x96C22c86B91235165eBF1F0f41FbeadA9C323A7A @@ -30,4 +27,4 @@ services: HEALTH_MIN_PEERS: 1 volumes: - bdag_bin: {} \ No newline at end of file + bdag_bin: {} diff --git a/docker-compose.relay.yml b/docker-compose.relay.yml deleted file mode 100644 index ac492a4..0000000 --- a/docker-compose.relay.yml +++ /dev/null @@ -1,35 +0,0 @@ -version: '3' - -services: - relay_node: - image: blockdagnetwork/awakening:v0.0.3 - container_name: blockdag-relay-testnet - restart: unless-stopped - ports: - - "38131:38131" - - "18545:18545" - - "18546:18546" - - "18150:18150" - volumes: - - bdag_bin:/opt/bdag - - ./bin/bdag/data:/bdag/data - - ./bin/bdag/logs:/bdag/logs - environment: - NODE_ARGS: >- - --testnet --rpclisten=127.0.0.1:28131 --notls --rpcuser=test --rpcpass=test - --walletpass=test - --evmenv="--http --http.port=28545 --http.addr=127.0.0.1 - --http.api=net,web3,eth,bdag,txpool,debug --allow-insecure-unlock --ws - --ws.addr=0.0.0.0 --ws.port=18546 --rpc.allow-unprotected-txs --gcmode=archive" - --datadir=/bdag/data --gateway --gateway.dag.http.port=38131 - --gateway.dag.http.addr=0.0.0.0 --gateway.evm.http.port=18545 - --gateway.evm.http.addr=0.0.0.0 - --addpeer=/ip4/13.245.135.249/tcp/18150/p2p/16Uiu2HAm3hjo65MZvBEJuVASMoSDsXfMzC8m2ZEAeK8CjjJkRvf9 - RPC_URL: ws://127.0.0.1:18546 - CONTRACT_ADDRESS: 0x96C22c86B91235165eBF1F0f41FbeadA9C323A7A - ROLLOUT_WINDOW: 30m - CONTRACT_DEPLOY_BLOCK: 257509 - HEALTH_MIN_PEERS: 1 - -volumes: - bdag_bin: {} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 84afb72..906c013 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,7 @@ -version: '3' services: miner_node: - image: blockdagnetwork/awakening:v0.0.3 + image: blockdagnetwork/awakening:v0.1.0 container_name: blockdag-miner-testnet restart: unless-stopped ports: @@ -16,12 +15,11 @@ services: - ./bin/bdag/logs:/bdag/logs environment: NODE_ARGS: >- - --testnet --rpclisten=0.0.0.0:38131 --notls --rpcuser=test --rpcpass=test - --miner - --evmenv="--http --http.port=18545 --http.addr=0.0.0.0 - --http.api=net,web3,eth,bdag,txpool,debug --allow-insecure-unlock --ws - --ws.addr=0.0.0.0 --ws.port=18546 --rpc.allow-unprotected-txs --gcmode=archive" - --miningaddr=${MINING_ADDRESS} --generate --datadir=/bdag/data + --testnet --rpclisten=0.0.0.0:38131 --notls --rpcuser=test --rpcpass=test --miner + --miningaddr=${MINING_ADDRESS} --generate + --evmenv="--http.api=net,web3,eth,bdag,txpool,debug --allow-insecure-unlock --rpc.allow-unprotected-txs --gcmode=archive" + --miningstatesync --datadir=/bdag/data --logdir=/bdag/logs --maxpeers=250 + --evm.http.port=18545 --evm.http.addr=0.0.0.0 --evm.ws.port=18546 --addpeer=/ip4/13.245.135.249/tcp/18150/p2p/16Uiu2HAm3hjo65MZvBEJuVASMoSDsXfMzC8m2ZEAeK8CjjJkRvf9 RPC_URL: ws://127.0.0.1:18546 CONTRACT_ADDRESS: 0x96C22c86B91235165eBF1F0f41FbeadA9C323A7A diff --git a/node.sh b/node.sh index 2222c83..50ec76e 100755 --- a/node.sh +++ b/node.sh @@ -24,6 +24,18 @@ if [ ! -f "$compose_path" ]; then fi export MINING_ADDRESS="$mining_address" +if [ -n "${MINING_ADDRESS:-}" ]; then + export MINING_ADDR_FLAG="--miner --miningaddr=$MINING_ADDRESS" +else + export MINING_ADDR_FLAG="" +fi + +# Force amd64 image on ARM hosts since the blockdag image is not multi-arch. +arch=$(uname -m) +if [ -z "${DOCKER_DEFAULT_PLATFORM:-}" ] && [[ "$arch" =~ ^(arm64|aarch64)$ ]]; then + export DOCKER_DEFAULT_PLATFORM=linux/amd64 + echo "Detected $arch host; using DOCKER_DEFAULT_PLATFORM=$DOCKER_DEFAULT_PLATFORM" +fi if docker compose version >/dev/null 2>&1; then echo "Using docker compose with file $compose_path" diff --git a/restart.sh b/restart.sh index 866ffd4..6f84393 100755 --- a/restart.sh +++ b/restart.sh @@ -10,7 +10,7 @@ usage() { cat <<'USAGE' Usage: ./restart.sh [ROLE] -ROLE matches the options from blockdag.sh (miner, full, relay). +ROLE matches the options from blockdag.sh (miner, full). If omitted, the miner template is used. NODE_ROLE environment variable can also set the default role. USAGE @@ -23,9 +23,6 @@ resolve_compose_file() { full) echo "docker-compose.full.yml" ;; - relay) - echo "docker-compose.relay.yml" - ;; miner|default) echo "docker-compose.yml" ;; @@ -49,6 +46,10 @@ if ! COMPOSE_FILE=$(resolve_compose_file "$ROLE_INPUT"); then usage >&2 exit 1 fi +NEEDS_MINING_ADDR=false +if [ "$COMPOSE_FILE" = "docker-compose.yml" ]; then + NEEDS_MINING_ADDR=true +fi if [[ "$COMPOSE_FILE" = /* ]]; then compose_path="$COMPOSE_FILE" @@ -62,14 +63,15 @@ fi # shellcheck disable=SC1090 source "$ENV_FILE" fi - - if [ -z "${PUB_ETH_ADDR:-}" ]; then - if [ -f "$SCRIPT_DIR/wallet.txt" ]; then - PUB_ETH_ADDR=$(tail -n 1 "$SCRIPT_DIR/wallet.txt") - else - echo "PUB_ETH_ADDR not set. Please populate $ENV_FILE or wallet.txt" >&2 - exit 1 - fi + + PUB_ETH_ADDR="${PUB_ETH_ADDR:-}" + if [ -z "$PUB_ETH_ADDR" ] && [ -f "$SCRIPT_DIR/wallet.txt" ]; then + PUB_ETH_ADDR=$(tail -n 1 "$SCRIPT_DIR/wallet.txt") + fi + + if $NEEDS_MINING_ADDR && [ -z "$PUB_ETH_ADDR" ]; then + echo "PUB_ETH_ADDR not set. Please populate $ENV_FILE or wallet.txt" >&2 + exit 1 fi if docker compose version >/dev/null 2>&1; then diff --git a/restartWithCleanup.sh b/restartWithCleanup.sh index e365588..5f349c0 100755 --- a/restartWithCleanup.sh +++ b/restartWithCleanup.sh @@ -10,7 +10,7 @@ usage() { cat <<'USAGE' Usage: ./restartWithCleanup.sh [ROLE] -ROLE matches the options from blockdag.sh (miner, full, relay). +ROLE matches the options from blockdag.sh (miner, full). If omitted, the miner template is used. NODE_ROLE environment variable can also set the default role. USAGE @@ -23,9 +23,6 @@ resolve_compose_file() { full) echo "docker-compose.full.yml" ;; - relay) - echo "docker-compose.relay.yml" - ;; miner|default) echo "docker-compose.yml" ;; @@ -49,6 +46,10 @@ if ! COMPOSE_FILE=$(resolve_compose_file "$ROLE_INPUT"); then usage >&2 exit 1 fi +NEEDS_MINING_ADDR=false +if [ "$COMPOSE_FILE" = "docker-compose.yml" ]; then + NEEDS_MINING_ADDR=true +fi if [[ "$COMPOSE_FILE" = /* ]]; then compose_path="$COMPOSE_FILE" @@ -62,14 +63,15 @@ fi # shellcheck disable=SC1090 source "$ENV_FILE" fi - - if [ -z "${PUB_ETH_ADDR:-}" ]; then - if [ -f "$SCRIPT_DIR/wallet.txt" ]; then - PUB_ETH_ADDR=$(tail -n 1 "$SCRIPT_DIR/wallet.txt") - else - echo "PUB_ETH_ADDR not set. Please populate $ENV_FILE or wallet.txt" >&2 - exit 1 - fi + + PUB_ETH_ADDR="${PUB_ETH_ADDR:-}" + if [ -z "$PUB_ETH_ADDR" ] && [ -f "$SCRIPT_DIR/wallet.txt" ]; then + PUB_ETH_ADDR=$(tail -n 1 "$SCRIPT_DIR/wallet.txt") + fi + + if $NEEDS_MINING_ADDR && [ -z "$PUB_ETH_ADDR" ]; then + echo "PUB_ETH_ADDR not set. Please populate $ENV_FILE or wallet.txt" >&2 + exit 1 fi if docker compose version >/dev/null 2>&1; then diff --git a/stop.sh b/stop.sh index 00906c3..8cc3fd1 100755 --- a/stop.sh +++ b/stop.sh @@ -11,7 +11,6 @@ Usage: ./stop.sh [ROLE] ROLE may be one of: miner - stop stack defined in docker-compose.yml (default) full - stop stack defined in docker-compose.full.yml - relay - stop stack defined in docker-compose.relay.yml all - stop all of the above stacks You can also set NODE_ROLE to pick the default role instead of passing ROLE. @@ -23,14 +22,11 @@ resolve_compose_files() { case "$role_input" in all) - echo "docker-compose.yml docker-compose.full.yml docker-compose.relay.yml" + echo "docker-compose.yml docker-compose.full.yml" ;; full) echo "docker-compose.full.yml" ;; - relay) - echo "docker-compose.relay.yml" - ;; miner|default) echo "docker-compose.yml" ;;