Update node startup flags and bootstrap instructions

This commit is contained in:
anonpenguin 2025-08-12 22:14:04 +03:00
parent d4616545aa
commit 1f6a4cd80b
2 changed files with 37 additions and 46 deletions

View File

@ -28,24 +28,24 @@ test:
@echo "Running tests..."
go test -v ./...
# Run bootstrap node explicitly
# Run bootstrap node (auto-selects identity and data dir)
run-node:
@echo "Starting BOOTSTRAP node (role=bootstrap)..."
go run ./cmd/node -role bootstrap -data ./data/bootstrap -advertise localhost -p2p-port $${P2P:-4001} -dev-local
@echo "Starting bootstrap node..."
go run ./cmd/node --data ./data/bootstrap --p2p-port $${P2P:-4001} --rqlite-http-port $${HTTP:-5001} --rqlite-raft-port $${RAFT:-7001} --disable-anonrc
# Run second node (regular) - requires BOOTSTRAP multiaddr
# Usage: make run-node2 BOOTSTRAP=/ip4/127.0.0.1/tcp/4001/p2p/<ID> HTTP=5002 RAFT=7002 P2P=4002
# Run second node (regular) - requires join address of bootstrap node
# Usage: make run-node2 JOINADDR=/ip4/127.0.0.1/tcp/5001 HTTP=5002 RAFT=7002 P2P=4002
run-node2:
@echo "Starting REGULAR node2 (role=node)..."
@if [ -z "$(BOOTSTRAP)" ]; then echo "ERROR: Provide BOOTSTRAP multiaddr: make run-node2 BOOTSTRAP=/ip4/127.0.0.1/tcp/4001/p2p/<ID> [HTTP=5002 RAFT=7002 P2P=4002]"; exit 1; fi
go run ./cmd/node -role node -id node2 -data ./data/node2 -bootstrap $(BOOTSTRAP) -rqlite-http-port $${HTTP:-5002} -rqlite-raft-port $${RAFT:-7002} -p2p-port $${P2P:-4002} -advertise $${ADVERTISE:-localhost} -dev-local
@echo "Starting regular node2..."
@if [ -z "$(JOINADDR)" ]; then echo "ERROR: Provide join address: make run-node2 JOINADDR=/ip4/127.0.0.1/tcp/5001 [HTTP=5002 RAFT=7002 P2P=4002]"; exit 1; fi
go run ./cmd/node --id node2 --data ./data/node2 --p2p-port $${P2P:-4002} --rqlite-http-port $${HTTP:-5002} --rqlite-raft-port $${RAFT:-7002} --rqlite-join-address $(JOINADDR)
# Run third node (regular) - requires BOOTSTRAP multiaddr
# Usage: make run-node3 BOOTSTRAP=/ip4/127.0.0.1/tcp/4001/p2p/<ID> HTTP=5003 RAFT=7003 P2P=4003
# Run third node (regular) - requires join address of bootstrap node
# Usage: make run-node3 JOINADDR=/ip4/127.0.0.1/tcp/5001 HTTP=5003 RAFT=7003 P2P=4003
run-node3:
@echo "Starting REGULAR node3 (role=node)..."
@if [ -z "$(BOOTSTRAP)" ]; then echo "ERROR: Provide BOOTSTRAP multiaddr: make run-node3 BOOTSTRAP=/ip4/127.0.0.1/tcp/4001/p2p/<ID> [HTTP=5003 RAFT=7003 P2P=4003]"; exit 1; fi
go run ./cmd/node -role node -id node3 -data ./data/node3 -bootstrap $(BOOTSTRAP) -rqlite-http-port $${HTTP:-5003} -rqlite-raft-port $${RAFT:-7003} -p2p-port $${P2P:-4003} -advertise $${ADVERTISE:-localhost} -dev-local
@echo "Starting regular node3..."
@if [ -z "$(JOINADDR)" ]; then echo "ERROR: Provide join address: make run-node3 JOINADDR=/ip4/127.0.0.1/tcp/5001 [HTTP=5003 RAFT=7003 P2P=4003]"; exit 1; fi
go run ./cmd/node --id node3 --data ./data/node3 --p2p-port $${P2P:-4003} --rqlite-http-port $${HTTP:-5003} --rqlite-raft-port $${RAFT:-7003} --rqlite-join-address $(JOINADDR)
# Run basic usage example
run-example:
@ -54,8 +54,8 @@ run-example:
# Show how to run with flags
show-bootstrap:
@echo "Provide bootstrap via flags, e.g.:"
@echo " make run-node2 BOOTSTRAP=/ip4/127.0.0.1/tcp/4001/p2p/<PEER_ID> HTTP=5002 RAFT=7002 P2P=4002"
@echo "Provide join address via flags, e.g.:"
@echo " make run-node2 JOINADDR=/ip4/127.0.0.1/tcp/5001 HTTP=5002 RAFT=7002 P2P=4002"
# Run network CLI
run-cli:
@ -151,8 +151,8 @@ test-consensus: build
dev-cluster:
@echo "To start a development cluster, run these commands in separate terminals:"
@echo "1. make run-node # Start bootstrap node"
@echo "2. make run-node2 BOOTSTRAP=/ip4/127.0.0.1/tcp/4001/p2p/<ID> HTTP=5002 RAFT=7002 P2P=4002"
@echo "3. make run-node3 BOOTSTRAP=/ip4/127.0.0.1/tcp/4001/p2p/<ID> HTTP=5003 RAFT=7003 P2P=4003"
@echo "2. make run-node2 JOINADDR=/ip4/127.0.0.1/tcp/5001 HTTP=5002 RAFT=7002 P2P=4002"
@echo "3. make run-node3 JOINADDR=/ip4/127.0.0.1/tcp/5001 HTTP=5003 RAFT=7003 P2P=4003"
@echo "4. make run-example # Test basic functionality"
@echo "5. make cli-health # Check network health"
@echo "6. make cli-peers # List peers"
@ -169,9 +169,9 @@ help:
@echo " build - Build all executables"
@echo " clean - Clean build artifacts"
@echo " test - Run tests"
@echo " run-node - Start bootstrap node (role=bootstrap)"
@echo " run-node2 - Start second node (role=node). Provide BOOTSTRAP, optional HTTP/RAFT"
@echo " run-node3 - Start third node (role=node). Provide BOOTSTRAP, optional HTTP/RAFT"
@echo " run-node - Start bootstrap node"
@echo " run-node2 - Start second node (requires JOINADDR, optional HTTP/RAFT/P2P)"
@echo " run-node3 - Start third node (requires JOINADDR, optional HTTP/RAFT/P2P)"
@echo " run-example - Run usage example"
@echo " run-cli - Run network CLI help"
@echo " show-bootstrap - Show example bootstrap usage with flags"

View File

@ -159,48 +159,38 @@ git clone https://git.debros.io/DeBros/network.git
cd network
```
### 2. Generate Bootstrap Identity (Development Only)
For development, you need to generate a consistent bootstrap peer identity:
```bash
# Generate bootstrap peer identity
go run scripts/generate-bootstrap-identity.go
# This will create data/bootstrap/identity.key and show the peer ID (and multiaddr)
# Save the printed peer ID to use with the -bootstrap flag
```
**Important:** After generating the bootstrap identity, copy the printed multiaddr
or peer ID for use with the `-bootstrap` flag when starting regular nodes.
### 3. Build the Project
### 2. Build the Project
```bash
# Build all network executables
make build
```
### 4. Start the Network
```bash
# Build all network executables
make build
```
### 3. Start the Network
**Terminal 1 - Bootstrap Node:**
```bash
# Start an explicit bootstrap node (LibP2P 4001, RQLite 5001/7001)
# Start the bootstrap node (LibP2P 4001, RQLite 5001/7001)
make run-node
```
**Terminal 2 - Regular Node:**
```bash
# Replace <BOOTSTRAP_PEER_ID> with the ID printed by the identity generator
make run-node2 BOOTSTRAP=/ip4/127.0.0.1/tcp/4001/p2p/<BOOTSTRAP_PEER_ID> HTTP=5002 RAFT=7002 P2P=4002
# Start a regular node and join the cluster using the bootstrap node's RQLite HTTP address
go run ./cmd/node --id node2 --data ./data/node2 --p2p-port 4002 --rqlite-http-port 5002 --rqlite-raft-port 7002 --rqlite-join-address http://127.0.0.1:5001 --disable-anonrc
```
**Terminal 3 - Another Node (optional):**
```bash
make run-node3 BOOTSTRAP=/ip4/127.0.0.1/tcp/4001/p2p/<BOOTSTRAP_PEER_ID> HTTP=5003 RAFT=7003 P2P=4003
go run ./cmd/node --id node3 --data ./data/node3 --p2p-port 4003 --rqlite-http-port 5003 --rqlite-raft-port 7003 --rqlite-join-address http://127.0.0.1:5001 --disable-anonrc
```
### 5. Test with CLI
@ -405,12 +395,13 @@ For more advanced configuration options and development setup, see the sections
## Configuration
### Bootstrap and Ports (via flags)
### Node Startup Flags
- **Bootstrap node**: `-role bootstrap`
- **Regular node**: `-role node -bootstrap <multiaddr>`
- **Development localhost defaults**: `-dev-local` (sets `NETWORK_DEV_LOCAL=1` in-process); use this for local-only testing so the library returns localhost DB endpoints and bootstrap peers.
- **RQLite ports**: `-rqlite-http-port` (default 5001), `-rqlite-raft-port` (default 7001)
- **Bootstrap node**: Just run `make run-node` (auto-selects data dir and identity)
- **Regular node**: Use `--id`, `--data`, `--p2p-port`, `--rqlite-http-port`, `--rqlite-raft-port`, and `--rqlite-join-address <http://bootstrap_host:5001>`
- **Disable anonymous routing**: `--disable-anonrc` (optional)
- **Development localhost defaults**: Use `--disable-anonrc` for local-only testing; the library returns localhost DB endpoints and bootstrap peers.
- **RQLite ports**: `--rqlite-http-port` (default 5001), `--rqlite-raft-port` (default 7001)
Examples are shown in Quick Start above for local multi-node on a single machine.