Files
aitbc/docs/architecture/4_blockchain-node.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.5 KiB

Blockchain Node - AITBC Documentation

PoA/PoS consensus blockchain with REST/WebSocket RPC, real-time gossip layer, and comprehensive observability

● Live

Overview

The AITBC Blockchain Node is the core infrastructure component that maintains the distributed ledger. It implements a hybrid Proof-of-Authority/Proof-of-Stake consensus mechanism with fast finality and supports high throughput for AI workload transactions.

Key Features

  • Hybrid PoA/PoS consensus with sub-second finality
  • REST and WebSocket RPC APIs
  • Real-time gossip protocol for block propagation
  • Comprehensive observability with Prometheus metrics
  • SQLModel-based data persistence
  • Built-in devnet tooling and scripts

Architecture

The blockchain node is built with a modular architecture separating concerns for consensus, storage, networking, and API layers.

Consensus Engine

Hybrid PoA/PoS with proposer rotation and validator sets

Storage Layer

SQLModel with SQLite/PostgreSQL support

Networking

WebSocket gossip + REST API

Observability

Prometheus metrics + structured logging

API Reference

The blockchain node exposes both REST and WebSocket APIs for interaction.

REST Endpoints

GET /rpc/get_head Get the latest block header

POST /rpc/send_tx Submit a new transaction

GET /rpc/get_balance/{address} Get account balance

GET /rpc/get_block/{height} Get block by height

WebSocket Subscriptions

  • new_blocks - Real-time block notifications
  • new_transactions - Transaction pool updates
  • consensus_events - Consensus round updates

Configuration

The node can be configured via environment variables or configuration file.

Key Settings

# Database
DATABASE_URL=sqlite:///blockchain.db

# Network
RPC_HOST=0.0.0.0
RPC_PORT=9080
WS_PORT=9081

# Consensus
CONSENSUS_MODE=poa
VALIDATOR_ADDRESS=0x...
BLOCK_TIME=1s

# Observability
METRICS_PORT=9090
LOG_LEVEL=info

Running a Node

Development Mode

# Initialize devnet
python -m blockchain.scripts.init_devnet

# Start node
python -m blockchain.main --config devnet.yaml

Production Mode

# Using Docker
docker run -d \
  -v /data/blockchain:/data \
  -p 9080:9080 \
  -p 9081:9081 \
  -p 9090:9090 \
  aitbc/blockchain-node:latest

Monitoring

Prometheus Metrics

Available at http://localhost:9090/metrics

Key metrics:

  • blockchain_blocks_total - Total blocks produced
  • blockchain_transactions_total - Total transactions processed
  • blockchain_consensus_rounds - Consensus rounds completed
  • blockchain_network_peers - Active peer connections

Health Checks

# Node status
curl http://localhost:9080/health

# Sync status
curl http://localhost:9080/sync_status

Troubleshooting

Common Issues

  1. Node not syncing

    • Check peer connections: curl /rpc/peers
    • Verify network connectivity
    • Check logs for consensus errors
  2. High memory usage

    • Reduce block_cache_size in config
    • Enable block pruning
  3. RPC timeouts

    • Increase rpc_timeout setting
    • Check system resources

Development

Building from Source

git clone https://github.com/aitbc/blockchain
cd blockchain
pip install -e .

Running Tests

# Unit tests
pytest tests/

# Integration tests
pytest tests/integration/

Security Considerations

  • Validator keys should be kept secure
  • Use HTTPS in production
  • Implement rate limiting on RPC endpoints
  • Regular security updates for dependencies