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 = 0The coordinate is derived from:
- PoW Hash – sha256(proof_of_work_data)
- Challenge Slot – current Solana slot number
- 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 } }- Verify proof – check MML and neural path validity
- Compute depth – BFS from origin to measure block distance in lattice
- Store block – insert at coord with recorded depth
- 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:
curl https://status.rpc.gateway.tribewarez.com/api/hexchain/statusResponse:
{
"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 latticelatest_depth– maximum distance (blocks) from origincurrent_challenge– active challenge for miners (null if none)
POST /api/hexchain/challenge
Generate a new challenge:
curl -X POST https://status.rpc.gateway.tribewarez.com/api/hexchain/challenge \
-H "Content-Type: application/json" \
-d '{
"slot": 98765,
"slot_hash": "0x1234567890abcdef..."
}'Response:
{
"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 identifiercoord– target HCP coordinate for this challengeslot– echoed slot number
POST /api/hexchain/submit
Submit a completed proof:
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):
{
"accepted": true,
"depth": 64,
"block_hash": "0xdeadbeef..."
}Response (rejected):
{
"accepted": false,
"error": "Invalid MML path"
}Request:
challenge_id– from/api/hexchain/challengeblock.coord– HCP coordinateblock.pow_hash– proof hash
Response:
accepted(bool) – whether proof was valid and inserteddepth(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:
curl https://status.rpc.gateway.tribewarez.com/api/hexchain/latticeResponse:
{
"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:
curl https://status.rpc.gateway.tribewarez.com/api/hexchain/lattice/1/-1/0Response (found):
{
"coord": {"q": 1, "r": -1, "s": 0},
"block_hash": "0xef567890...",
"depth": 1
}Response (not found):
{
"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
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
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:
./pot-o-mine \
--rpc-url https://pot.rpc.gateway.tribewarez.com \
--status-api-url https://status.rpc.gateway.tribewarez.com \
--device-type esp32The CLI:
- Polls
/api/hexchain/challengefor the current challenge - Computes MML and neural path PoW
- Submits to
/api/hexchain/submit - Updates the hexchain dashboard in real-time
Using pot-o-mine-dashboard.py
Real-time TUI showing hexchain metrics:
python3 pot-o-mine-dashboard.pyDisplays:
- 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:
POST /devices/register {
"pubkey": "...",
"device_type": "esp32",
"port": 5000
}Firmware then:
- Fetches challenges from hexchain endpoint
- Performs tensor ops locally
- 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:
POT_O_CONSENSUS_ENABLED=1 cargo run --releaseProof rejected: "Invalid MML"
Cause: Miner computed suboptimal path or wrong challenge ID
Fix: Verify challenge ID matches and re-fetch challenge:
curl https://status.rpc.gateway.tribewarez.com/api/hexchain/statusLattice queries timeout
Cause: Too many blocks; query is expensive
Fix: Use coordinate-specific queries:
curl https://status.rpc.gateway.tribewarez.com/api/hexchain/lattice/0/0/0