Overview

NCN Network v2 consists of five main components that work together to provide decentralized AI inference.


Component Architecture

┌──────────────────────────────────────────────────────────────────────────┐
│                           NCN Network v2                                  │
│                                                                          │
│    ┌────────────────────────────────────────────────────────────────┐    │
│    │                        User Layer                               │    │
│    │   ┌──────────────────────────────────────────────────────┐     │    │
│    │   │               Test Client                             │     │    │
│    │   │   Example application for testing the network         │     │    │
│    │   └──────────────────────────────────────────────────────┘     │    │
│    └────────────────────────────────────────────────────────────────┘    │
│                                  │                                        │
│                                  ▼                                        │
│    ┌────────────────────────────────────────────────────────────────┐    │
│    │                       Gateway Layer                             │    │
│    │   ┌──────────────────────────────────────────────────────┐     │    │
│    │   │              Gateway Node                             │     │    │
│    │   │   • Routes inference requests                         │     │    │
│    │   │   • Manages compute reservations                      │     │    │
│    │   │   • Processes payments                                │     │    │
│    │   │   • Subnet CLI for management                         │     │    │
│    │   └──────────────────────────────────────────────────────┘     │    │
│    └────────────────────────────────────────────────────────────────┘    │
│                                  │                                        │
│                                  ▼                                        │
│    ┌────────────────────────────────────────────────────────────────┐    │
│    │                       Compute Layer                             │    │
│    │   ┌──────────────────────────────────────────────────────┐     │    │
│    │   │              Compute Node                             │     │    │
│    │   │   • Executes AI models                                │     │    │
│    │   │   • Sandboxed Python execution                        │     │    │
│    │   │   • Signs computation results                         │     │    │
│    │   │   • Model caching and management                      │     │    │
│    │   └──────────────────────────────────────────────────────┘     │    │
│    └────────────────────────────────────────────────────────────────┘    │
│                                  │                                        │
│                                  ▼                                        │
│    ┌────────────────────────────────────────────────────────────────┐    │
│    │                    Coordination Layer                           │    │
│    │   ┌──────────────────────────────────────────────────────┐     │    │
│    │   │              P2P Registry                             │     │    │
│    │   │   • Node discovery                                    │     │    │
│    │   │   • Validator consensus                               │     │    │
│    │   │   • Subnet management                                 │     │    │
│    │   │   • DHT-based storage                                 │     │    │
│    │   └──────────────────────────────────────────────────────┘     │    │
│    └────────────────────────────────────────────────────────────────┘    │
│                                  │                                        │
│                                  ▼                                        │
│    ┌────────────────────────────────────────────────────────────────┐    │
│    │                      Blockchain Layer                           │    │
│    │   ┌──────────────────────────────────────────────────────┐     │    │
│    │   │             Smart Contracts                           │     │    │
│    │   │   • InferencePayment (payment handling)               │     │    │
│    │   │   • NCNToken (ERC20 payment token)                    │     │    │
│    │   │   • ValidatorRegistry (on-chain validators)           │     │    │
│    │   └──────────────────────────────────────────────────────┘     │    │
│    └────────────────────────────────────────────────────────────────┘    │
│                                                                          │
└──────────────────────────────────────────────────────────────────────────┘

Component Summary

Component
Purpose
Technology
Documentation

Request routing & payments

Rust, Tokio, Tonic

Model execution

Rust, Python

Coordination & consensus

Rust, libp2p

On-chain payments

Solidity

Testing & examples

Rust


Communication Protocols

Source
Destination
Protocol
Port

Client

Gateway

gRPC

50051

Client

Gateway

HTTP REST

8080

Client

Gateway

WebSocket

9000

Gateway

Compute

gRPC (stream)

50051

Gateway

Registry

gRPC

50050

Compute

Registry

gRPC

50050

Registry

Registry

libp2p

8828

All

Blockchain

JSON-RPC

External


Data Flow

Inference Request Flow


Build Instructions

Build All Components

Build Individual Components

Build Smart Contracts


Dependencies

Rust Crates (Workspace)

Python Dependencies

Smart Contract Dependencies


Configuration Quick Reference

Component
Config File
Key Settings

Gateway

gateway_node/.env

GATEWAY_PRIVATE_KEY, RPC_URL, REGISTRY_GRPC_ADDR

Compute

Environment vars

GATEWAY_ADDR, MODEL_PATH, SANDBOX_MODE

Registry

Command line

--p2p-listen-addr, --grpc-listen-addr

Contracts

contracts/.env

PRIVATE_KEY, RPC_URL

See Configuration Guide for complete details.


Quick Start

1. Start P2P Registry

2. Start Gateway

3. Start Compute Node

4. Run Test Client


Next Steps

Explore each component in detail:

Last updated