Files
aitbc/docs/development/8_blockchain-node-deployment.md
aitbc 19d415a235
Some checks failed
Blockchain Synchronization Verification / sync-verification (push) Failing after 3s
CLI Tests / test-cli (push) Failing after 3s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Successful in 2s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 3s
Cross-Chain Functionality Tests / test-cross-chain-bridge (push) Has been skipped
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Successful in 2s
Cross-Chain Functionality Tests / aggregate-results (push) Has been skipped
Deploy to Testnet / deploy-testnet (push) Successful in 1m12s
Documentation Validation / validate-docs (push) Failing after 8s
Documentation Validation / validate-policies-strict (push) Successful in 3s
Integration Tests / test-service-integration (push) Successful in 2m6s
Multi-Chain Island Architecture Tests / test-multi-chain-island (push) Successful in 2s
Multi-Node Blockchain Health Monitoring / health-check (push) Failing after 4s
P2P Network Verification / p2p-verification (push) Successful in 4s
Package Tests / Python package - aitbc-agent-sdk (push) Successful in 32s
Package Tests / Python package - aitbc-core (push) Successful in 14s
Package Tests / Python package - aitbc-crypto (push) Successful in 12s
Package Tests / Python package - aitbc-sdk (push) Successful in 9s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 8s
Package Tests / JavaScript package - aitbc-token (push) Successful in 17s
Python Tests / test-python (push) Successful in 15s
Security Scanning / security-scan (push) Successful in 27s
Node Failover Simulation / failover-test (push) Successful in 7s
Multi-Node Stress Testing / stress-test (push) Successful in 6s
Cross-Node Transaction Testing / transaction-test (push) Successful in 4s
feat: add SQLCipher database encryption support and consolidate agent documentation
- Add SQLCipher encryption for ait-mainnet database with configurable flag
- Add db_encryption_enabled and db_encryption_key_path config settings
- Implement encryption key loading and PRAGMA key setup via connection events
- Add shutdown_db function for proper database cleanup
- Export middleware classes in aitbc/__init__.py
- Fix import path in sync.py for settings
- Remove duplicate agent documentation from docs
2026-05-03 12:00:38 +02:00

3.1 KiB

Blockchain Node Deployment Guide

Prerequisites

  • Python 3.13.5+
  • SQLite 3.35+
  • 512 MB RAM minimum (1 GB recommended)
  • 10 GB disk space

Configuration

All settings via environment variables or .env file:

# Core
CHAIN_ID=ait-devnet
DB_PATH=./data/chain.db
PROPOSER_ID=ait-devnet-proposer
BLOCK_TIME_SECONDS=2

# RPC
RPC_BIND_HOST=0.0.0.0
RPC_BIND_PORT=8080

# Block Production
MAX_BLOCK_SIZE_BYTES=1000000
MAX_TXS_PER_BLOCK=500
MIN_FEE=0

# Mempool
MEMPOOL_BACKEND=database        # "memory" or "database"
MEMPOOL_MAX_SIZE=10000

# Circuit Breaker
CIRCUIT_BREAKER_THRESHOLD=5
CIRCUIT_BREAKER_TIMEOUT=30

# Sync
TRUSTED_PROPOSERS=proposer-a,proposer-b
MAX_REORG_DEPTH=10
SYNC_VALIDATE_SIGNATURES=true

# Gossip
GOSSIP_BACKEND=memory           # "memory" or "broadcast"
GOSSIP_BROADCAST_URL=            # Required for broadcast backend

Installation

cd apps/blockchain-node
pip install -e .

Running

Development

uvicorn aitbc_chain.app:app --host 127.0.0.1 --port 8080 --reload

Production

uvicorn aitbc_chain.app:app \
  --host 0.0.0.0 \
  --port 8080 \
  --workers 1 \
  --timeout-keep-alive 30 \
  --access-log \
  --log-level info

Note: Use --workers 1 because the PoA proposer must run as a single instance.

Systemd Service

[Unit]
Description=AITBC Blockchain Node
After=network.target

[Service]
Type=simple
User=aitbc
WorkingDirectory=/opt/aitbc/apps/blockchain-node
EnvironmentFile=/opt/aitbc/.env
ExecStart=/opt/aitbc/venv/bin/uvicorn aitbc_chain.app:app --host 0.0.0.0 --port 8080 --workers 1
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Endpoints

Method Path Description
GET /health Health check
GET /metrics Prometheus metrics
GET /rpc/head Chain head
GET /rpc/blocks/{height} Block by height
GET /rpc/blocks Latest blocks
GET /rpc/tx/{hash} Transaction by hash
POST /rpc/sendTx Submit transaction
POST /rpc/importBlock Import block from peer
GET /rpc/syncStatus Sync status
POST /rpc/admin/mintFaucet Mint devnet funds

Monitoring

Health Check

curl http://localhost:8080/health

Key Metrics

  • poa_proposer_running — 1 if proposer is active
  • chain_head_height — Current block height
  • mempool_size — Pending transactions
  • circuit_breaker_state — 0=closed, 1=open
  • rpc_requests_total — Total RPC requests
  • rpc_rate_limited_total — Rate-limited requests

Alerting Rules (Prometheus)

- alert: ProposerDown
  expr: poa_proposer_running == 0
  for: 1m

- alert: CircuitBreakerOpen
  expr: circuit_breaker_state == 1
  for: 30s

- alert: HighErrorRate
  expr: rate(rpc_server_errors_total[5m]) > 0.1
  for: 2m

Troubleshooting

  • Proposer not producing blocks: Check poa_proposer_running metric, review logs for DB errors
  • Rate limiting: Increase max_requests in middleware or add IP allowlist
  • DB locked: Switch to MEMPOOL_BACKEND=database for separate mempool DB
  • Sync failures: Check TRUSTED_PROPOSERS config, verify peer connectivity