Skip to content

Hexchain Integration (v0.4.1)

Hexchain is the core consensus mechanism in PoT-O v0.4.1, introducing spatial lattice-based block ordering using Hex Coordinate Projection (HCP) for a deterministic, peer-to-peer consensus model.

Overview

Unlike traditional linear blockchains, Hexchain organizes blocks into a hexagonal lattice in 3D space using axial coordinates (q, r, s). This enables:

  • Geographic distribution – nodes position blocks based on their content hash, creating natural spatial ordering
  • Leaderless consensus – no central validator; all nodes derive the same lattice structure from PoW proofs
  • Fork resolution – coordinate conflicts are resolved by proof depth, ensuring convergence
  • P2P scalability – lattice geometry allows efficient peer discovery and incremental sync

Architecture

Hex Coordinate Projection (HCP)

Each block is assigned a coordinate in the hexagonal lattice:

coord = (q, r, s) where q + r + s = 0

The coordinate is derived from:

  1. PoW Hash – sha256(proof_of_work_data)
  2. Challenge Slot – current Solana slot number
  3. Lattice Mapping – hash bits → q, r, s values

Block Insertion

When a miner submits a proof:

POST /api/hexchain/submit { challenge_id, block { coord, pow_hash } }
  1. Verify proof – check MML and neural path validity
  2. Compute depth – BFS from origin to measure block distance in lattice
  3. Store block – insert at coord with recorded depth
  4. Broadcast – propagate to peers via P2P network

Network Topology

The hexchain P2P network uses lattice-aware peering:

  • Nodes connect to geographically close peers (nearby coordinates)
  • Each node maintains a local view of the lattice around its origin
  • Consensus emerges from all nodes independently deriving the same lattice structure

API Reference

GET /api/hexchain/status

Get the current lattice state:

bash
curl https://status.rpc.gateway.tribewarez.com/api/hexchain/status

Response:

json
{
  "occupied_coords": 1024,
  "latest_depth": 256,
  "current_challenge": {
    "id": "challenge_abc123",
    "coord": {"q": 5, "r": -3, "s": -2},
    "slot": 98765
  }
}

Fields:

  • occupied_coords – number of blocks in the lattice
  • latest_depth – maximum distance (blocks) from origin
  • current_challenge – active challenge for miners (null if none)

POST /api/hexchain/challenge

Generate a new challenge:

bash
curl -X POST https://status.rpc.gateway.tribewarez.com/api/hexchain/challenge \
  -H "Content-Type: application/json" \
  -d '{
    "slot": 98765,
    "slot_hash": "0x1234567890abcdef..."
  }'

Response:

json
{
  "id": "challenge_xyz789",
  "coord": {"q": 3, "r": -1, "s": -2},
  "slot": 98765
}

Parameters:

  • slot – current Solana slot (u64)
  • slot_hash – slot hash bytes (hex string)

Response:

  • id – unique challenge identifier
  • coord – target HCP coordinate for this challenge
  • slot – echoed slot number

POST /api/hexchain/submit

Submit a completed proof:

bash
curl -X POST https://status.rpc.gateway.tribewarez.com/api/hexchain/submit \
  -H "Content-Type: application/json" \
  -d '{
    "challenge_id": "challenge_xyz789",
    "block": {
      "coord": {"q": 3, "r": -1, "s": -2},
      "pow_hash": "0xdeadbeef..."
    }
  }'

Response (success):

json
{
  "accepted": true,
  "depth": 64,
  "block_hash": "0xdeadbeef..."
}

Response (rejected):

json
{
  "accepted": false,
  "error": "Invalid MML path"
}

Request:

  • challenge_id – from /api/hexchain/challenge
  • block.coord – HCP coordinate
  • block.pow_hash – proof hash

Response:

  • accepted (bool) – whether proof was valid and inserted
  • depth (int) – block's distance from origin (if accepted)
  • block_hash (string) – hex-encoded block hash

GET /api/hexchain/lattice

Fetch all blocks in the lattice:

bash
curl https://status.rpc.gateway.tribewarez.com/api/hexchain/lattice

Response:

json
{
  "blocks": [
    {
      "coord": {"q": 0, "r": 0, "s": 0},
      "block_hash": "0xabcd1234...",
      "depth": 0
    },
    {
      "coord": {"q": 1, "r": -1, "s": 0},
      "block_hash": "0xef567890...",
      "depth": 1
    }
  ]
}

GET /api/hexchain/lattice/{q}/{r}/

Fetch a block at a specific coordinate:

bash
curl https://status.rpc.gateway.tribewarez.com/api/hexchain/lattice/1/-1/0

Response (found):

json
{
  "coord": {"q": 1, "r": -1, "s": 0},
  "block_hash": "0xef567890...",
  "depth": 1
}

Response (not found):

json
{
  "error": "No block at this coordinate"
}

PoT-O Serialization (v0.4.1)

Hexchain requires aligned serialization of PoW proofs. The miner CLI (pot-o-mine) and dashboard automatically handle this.

Challenge Structure

rust
pub struct HexChallenge {
    pub id: String,
    pub coord: HCPCoord,
    pub slot: u64,
}

pub struct HCPCoord {
    pub q: i32,
    pub r: i32,
    pub s: i32,
}

Proof Structure

rust
pub struct HexProof {
    pub challenge_id: String,
    pub block: HexBlock,
}

pub struct HexBlock {
    pub coord: HCPCoord,
    pub pow_hash: Vec<u8>,
}

Mining with Hexchain

Using pot-o-mine CLI

The miner automatically connects to both the standard PoT-O API and hexchain endpoints:

bash
./pot-o-mine \
  --rpc-url https://pot.rpc.gateway.tribewarez.com \
  --status-api-url https://status.rpc.gateway.tribewarez.com \
  --device-type esp32

The CLI:

  1. Polls /api/hexchain/challenge for the current challenge
  2. Computes MML and neural path PoW
  3. Submits to /api/hexchain/submit
  4. Updates the hexchain dashboard in real-time

Using pot-o-mine-dashboard.py

Real-time TUI showing hexchain metrics:

bash
python3 pot-o-mine-dashboard.py

Displays:

  • Current challenge coordinate (q, r, s)
  • Lattice depth and occupied blocks
  • Miner stats by device type
  • P2P network peer count

ESP32 Firmware

ESP firmware syncs with hexchain via device registration:

bash
POST /devices/register {
  "pubkey": "...",
  "device_type": "esp32",
  "port": 5000
}

Firmware then:

  1. Fetches challenges from hexchain endpoint
  2. Performs tensor ops locally
  3. Reports progress via /devices/progress

Consensus Guarantees

Hexchain provides:

  • Deterministic ordering – given the same proofs, all nodes derive the same lattice
  • No forks – coordinate + depth uniquely identifies a block
  • Incremental sync – nodes can sync part of the lattice and fill gaps later
  • Byzantine tolerance – invalid proofs are rejected; malicious peers are ignored

Troubleshooting

Challenge returns 500

Cause: Hexchain consensus engine not initialized or backend error

Fix: Ensure pot-o-validator is running with hexchain enabled:

bash
POT_O_CONSENSUS_ENABLED=1 cargo run --release

Proof rejected: "Invalid MML"

Cause: Miner computed suboptimal path or wrong challenge ID

Fix: Verify challenge ID matches and re-fetch challenge:

bash
curl https://status.rpc.gateway.tribewarez.com/api/hexchain/status

Lattice queries timeout

Cause: Too many blocks; query is expensive

Fix: Use coordinate-specific queries:

bash
curl https://status.rpc.gateway.tribewarez.com/api/hexchain/lattice/0/0/0

Further Reading

TribeWarez Blockchain Ecosystem