Skip to content

Repository files navigation

🧶 Loom Node P2P

A High-Performance Decentralized Mesh Node for the Loom Protocol

Rust libp2p License: MIT Build Status Persistence: SQLite

Loom Node is a production-grade decentralized node implementation designed for high-availability mesh networks. It features cryptographically self-verifying messages, a collaborative state machine with conflict resolution, and deep operational observability.


🏗️ Architecture at a Glance

The Loom Node is built on a modular, event-driven architecture designed for zero-trust environments and high resilience.

graph TD
    subgraph Client Interface
        API[HTTP REST API /metrics]
        RPC[JSON-RPC Interface]
    end

    subgraph Core Engine
        Bridge[Async Result Bridge]
        Engine[P2P Engine / Swarm]
        State[LWW State Machine]
    end

    subgraph Data Layer
        Persistence[SQLite Storage]
        DHT[Kademlia DHT Store]
    end
    
    API <--> Bridge
    RPC <--> Bridge
    Bridge <--> Engine
    Engine <--> State
    Engine <--> Persistence
    Engine <--> DHT

    subgraph Resilience ["Network Resilience"]
        Relay[Relay v2 Client]
        DCUTR[Direct Hole Punching]
        AutoNAT[NAT Detection]
    end
    
    Engine --- Resilience
Loading

🚀 Key Differentiators

🛡️ Self-Verifying Protocol

Every message in the Loom mesh is a cryptographically signed envelope. The protocol embeds public keys within messages, allowing any node to validate the integrity and origin of data without external identity lookups or centralized authorities.

🔄 Collaborative Ledger (CRDT-Lite)

Implements a distributed state machine using Last-Writer-Wins (LWW) conflict resolution. This ensures all nodes eventually converge on the same state even in highly partitioned or high-latency networks.

🦾 Industrial-Grade Resilience

  • Multi-Transport Support: TCP/IP with Noise encryption and Yamux multiplexing.
  • NAT Traversal: Built-in support for AutoNAT, UPnP, and DCUTR for reliable connectivity behind symmetric NATs.
  • Active Peer Reputation: Malicious or low-performing peers are automatically penalized and quarantined.

📊 Deep Observability

Native Prometheus integration provides real-time insights into:

  • Peer density and discovery latency.
  • Message propagation speeds.
  • DHT health and record persistence.
  • SQLite I/O performance.

🛠️ Getting Started

1-Click Cluster Deployment

Launch a 3-node cluster complete with a full observability stack (Prometheus & Grafana) using Docker Compose:

docker-compose up -d

🔗 Access Points

Service URL Description
Grafana http://localhost:3000 Visual health & mesh metrics (Admin/Admin)
Prometheus http://localhost:9090 Raw metric scraping & alerting
Node-A API http://localhost:8081 Control interface for the first node

🧪 Automated Sync Demo

Verify end-to-end P2P synchronization across the cluster:

python3 scripts/demonstrate_sync.py --wait

⚙️ Technical Deep Dive

Message Verification Example

// Cryptographic validation is performed at the engine level before propagation
let public_key = libp2p::identity::PublicKey::try_decode_protobuf(&envelope.public_key)?;
envelope.verify(&public_key)?; 

Module Overview

  • engine.rs: Swarm management, behavior composition, and event loop.
  • state_machine.rs: Conflict-free replicated state logic.
  • storage.rs: Thread-safe, asynchronous SQLite persistence.
  • protocol.rs: Protobuf-based message schemas and signing logic.

📜 License

Distributed under the MIT License. See LICENSE for more information.


Built for the next generation of decentralized infrastructure.

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages