Overview

This section provides detailed documentation of NCN Network v2's architecture, from high-level system design to specific implementation details.


Architecture Documentation

High-level system design including:

  • Component responsibilities

  • Data flow patterns

  • Design principles

  • Scalability considerations

Network communication patterns:

  • P2P network structure (Kademlia DHT)

  • Service discovery mechanisms

  • gRPC communication channels

  • Multi-protocol client interfaces

Blockchain payment integration:

  • End-to-end payment sequence

  • Fee calculation and distribution

  • Smart contract interactions

  • Transaction confirmation

Validator consensus mechanism:

  • Preprocessing validation

  • Completion validation

  • M-of-N signature scheme

  • Validator reputation and slashing

Security architecture:

  • Threat model

  • Sandboxed execution

  • Cryptographic signing

  • Access control


Quick Reference

System Diagram

Component Summary

Component
Technology
Primary Role
Key Interfaces

Gateway Node

Rust, Tokio, Tonic

Request routing, payments

gRPC, HTTP, WebSocket

Compute Node

Rust, Python

Model execution

gRPC (to Gateway)

P2P Registry

Rust, libp2p

Coordination, validation

gRPC, P2P

Smart Contracts

Solidity, Foundry

Payment handling

Ethereum ABI

Communication Protocols

Protocol
Use Case
Port (Default)

gRPC

Service-to-service

50050, 50051

HTTP REST

Client requests

8080

WebSocket

Real-time updates

9000

libp2p

P2P coordination

8828

JSON-RPC

Blockchain

External

Data Flow Overview


Design Principles

1. Decentralization

  • No single point of failure

  • P2P coordination via DHT

  • Multiple gateway and compute nodes

2. Security First

  • Sandboxed model execution

  • Cryptographic attestations

  • Payment verification

3. Scalability

  • Horizontal scaling of compute nodes

  • Async I/O with Tokio

  • Efficient binary protocols (protobuf)

4. Transparency

  • On-chain payment records

  • Validator signatures

  • Execution logs

5. Operator Economics

  • Gateway operators earn routing fees

  • Compute operators earn execution fees

  • Validators earn consensus fees


Technology Stack

Backend Services

Layer
Technology
Purpose

Runtime

Tokio

Async runtime

RPC

Tonic

gRPC framework

Web

Axum

HTTP server

P2P

libp2p

P2P networking

Crypto

ethers-rs

Ethereum integration

Serialization

Protobuf

Binary encoding

Smart Contracts

Technology
Purpose

Solidity

Contract language

Foundry

Development framework

OpenZeppelin

Security libraries

Model Execution

Technology
Purpose

Python

Executor runtime

PyTorch

ML framework

seccomp

Syscall filtering

Landlock

Filesystem isolation


Next Steps

Dive deeper into specific architecture topics:

  1. System Overview - Complete system design

  2. Payment Flow - Payment mechanics

  3. Security Model - Security architecture

Last updated