Skip to content

TribeWarez/esp-pot-o-miner

Repository files navigation

ESP PoT-O Miner Firmware

CI Releases License: MIT

Mining firmware for ESP32-S and ESP8266 microcontrollers.
Connects to pot.rpc.gateway.tribewarez.com to fetch PoT-O challenges, execute tensor operations on-device, and submit proofs.

Device Capabilities

Device Max Tensor Working Memory Supported Ops
ESP32-S 64×64 320 KB matrix_multiply, convolution, relu, sigmoid, dot_product, normalize
ESP8266 32×32 80 KB relu, sigmoid, dot_product, normalize

Quick Start

Prerequisites

Configure WiFi

Edit include/pot_o_config.h:

#define WIFI_SSID "YOUR_SSID"
#define WIFI_PASS "YOUR_PASS"

Or pass via build flags:

pio run -e esp32s -t upload --build-flag="-DWIFI_SSID='\"MySSID\"' -DWIFI_PASS='\"MyPass\"'"

Build & Upload

# ESP32-S
pio run -e esp32s -t upload

# ESP8266 (NodeMCU v2)
pio run -e esp8266 -t upload

# Monitor serial output
pio device monitor -b 115200

Mining Flow

  1. Boot → Connect WiFi → Register device with RPC
  2. Loop:
    • POST /challenge → get tensor challenge
    • Execute tensor operation (matrix multiply, convolution, activation, etc.)
    • Compute MML score (entropy-based approximation of DEFLATE ratio)
    • Search nonces for neural path match within Hamming distance tolerance
    • POST /submit → submit proof for on-chain verification
  3. Progress (recommended): POST /devices/progress with challenge_id, hash, and device_id every few seconds while mining so the status dashboard shows live activity.
  4. Heartbeat every 30s via GET /health

For full CLI and ESP integration details (curl examples, device_id on submit, progress reporting), see the validator root CLI_AND_ESP_GUIDE.md.

Firmware self-check on boot (optional)

To keep devices up to date, you can perform a lightweight self-check against the status gateway when the ESP boots:

  • Base URL: https://status.rpc.gateway.tribewarez.com
  • Endpoint: /api/device/self-check
  • Query parameters:
    • device_type: esp32 or esp8266
    • channel: e.g. testnet
    • kind: firmware
    • current_version: firmware version string compiled into the binary (e.g. POT_O_VERSION)

Example HTTP request:

GET https://status.rpc.gateway.tribewarez.com/api/device/self-check?device_type=esp32&channel=testnet&kind=firmware&current_version=1.0.0

If the response reports update_required or update_recommended and includes an artifact.download_url, you can:

  1. Download the new firmware image with a small HTTPS client.
  2. Verify the checksum (if present).
  3. Flash the new image according to your OTA update strategy for the device.

The exact OTA mechanism depends on your hardware and bootloader, but this endpoint gives you a single, canonical source of truth for which firmware version to run per device type and channel.

Architecture

  • Core library (reusable across firmware repos): lib/pot_o_firmware_core/
    • Tensor ops (base + ESP32 tiled matmul, optional ESP-DSP), neural path, SHA-256, MML score.
    • See lib/pot_o_firmware_core/README.md for API and optional build flags (USE_ESP_DSP, USE_FAST_ACTIVATIONS, USE_SIN_LUT).
  • App: src/main.cpp — setup, mining loop, HTTP client, proof assembly. Includes pot_o/*.h from the core lib.
  • Legacy redirects: include/*.h redirect to pot_o/*.h for backward compatibility.

Hardware SHA on ESP32 is enabled via sdkconfig.defaults (CONFIG_MBEDTLS_HARDWARE_SHA=y).

RPC Endpoint

Default: https://pot.rpc.gateway.tribewarez.com

Override in platformio.ini build flags:

build_flags =
    -DPOT_RPC_HOST=\"your-host.example.com\"
    -DPOT_RPC_PORT=8900
    -DPOT_RPC_TLS=0

License

MIT

Packages

 
 
 

Contributors