diff options
| author | Your Name <you@example.com> | 2026-05-28 17:54:44 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-28 17:54:44 +0530 |
| commit | 96589ce5d0bc49a3f6b006b0bb443b81d1dd8e03 (patch) | |
| tree | 764de0a8a3a69e4e8b87fd3b63f66bf488a2da9b /PLAN_BITAXE_FIXES.md | |
| parent | 953393da1617ff4d4f6cd065f7fe1346e9b9a00e (diff) | |
feat: implement 3 missing API functions + test + fix plan
- tollgate_core_on_share_accepted(): tracks hashrate, creates/extends
mining sessions, calls platform callback
- tollgate_core_calc_hashprice(): returns nbits-derived hashprice or
manual override from platform
- tollgate_core_get_mining_status_json(): returns proxy stats as JSON
- test_mining_api: 19 assertions covering all 3 functions
- PLAN_BITAXE_FIXES.md: comprehensive fix plan with checklist
Diffstat (limited to 'PLAN_BITAXE_FIXES.md')
| -rw-r--r-- | PLAN_BITAXE_FIXES.md | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/PLAN_BITAXE_FIXES.md b/PLAN_BITAXE_FIXES.md new file mode 100644 index 0000000..9514dbf --- /dev/null +++ b/PLAN_BITAXE_FIXES.md | |||
| @@ -0,0 +1,141 @@ | |||
| 1 | # TollGate on NerdQAxePlus/BitAxe — Fix Plan | ||
| 2 | |||
| 3 | **Created:** 2026-05-28 | ||
| 4 | **Branch:** `feature/tollgate-core-v2` (esp32-tollgate), `develop` (NerdQAxePlus) | ||
| 5 | **Component version:** v1.2.0 → v1.3.0 | ||
| 6 | |||
| 7 | --- | ||
| 8 | |||
| 9 | ## Phase 1: Implement 3 Missing API Functions in tollgate_core | ||
| 10 | |||
| 11 | **File:** `components/tollgate_core/src/tollgate_core.c` | ||
| 12 | |||
| 13 | - [ ] 1a. Implement `tollgate_core_on_share_accepted(uint32_t client_ip, double difficulty)` | ||
| 14 | - Call `tollgate_core_mining_update_hashrate(client_ip, true)` | ||
| 15 | - Get client stats via `tollgate_core_mining_get_client_stats(client_ip)` | ||
| 16 | - Find or create session via `tollgate_core_session_find_by_ip()` / `tollgate_core_session_create()` | ||
| 17 | - Calculate allotment via `tollgate_core_mining_shares_to_allotment_ms()` or `_bytes()` based on metric | ||
| 18 | - Extend session via `tollgate_core_session_extend(session, allotment)` | ||
| 19 | - Call `s_platform->on_share_accepted(difficulty)` if set | ||
| 20 | |||
| 21 | - [ ] 1b. Implement `tollgate_core_calc_hashprice(double hashrate_ghs)` | ||
| 22 | - Check `s_platform->get_hashprice_sats_per_ghs_day()` for manual override (nonzero = return it) | ||
| 23 | - Otherwise return `tollgate_core_mining_get_current_hashprice()` (from nbits) | ||
| 24 | |||
| 25 | - [ ] 1c. Implement `tollgate_core_get_mining_status_json(void)` | ||
| 26 | - Follow `tollgate_core_get_status_json()` pattern (cJSON create → add fields → print → delete) | ||
| 27 | - Get proxy stats via `tollgate_core_stratum_proxy_get_stats()` | ||
| 28 | - JSON fields: `hashprice`, `nbits`, `total_shares`, `total_accepted`, `total_rejected`, `active_miners`, `hashrate_ghs` | ||
| 29 | |||
| 30 | - [ ] 1d. Add unit tests for new functions in `tests/unit/test_mining_api.c` | ||
| 31 | - [ ] 1e. `make test-unit` — all tests pass | ||
| 32 | - [ ] 1f. `idf.py build` — esp32-tollgate builds | ||
| 33 | |||
| 34 | --- | ||
| 35 | |||
| 36 | ## Phase 2: Wire tick() into NerdQAxePlus Main Loop | ||
| 37 | |||
| 38 | **File:** `esp-miner-nerdqaxeplus/main/main.cpp` (line 331 while loop) | ||
| 39 | |||
| 40 | - [ ] 2a. Add `tollgate_core_tick()` inside the 10s loop, guarded by `#ifdef TOLLGATE` | ||
| 41 | - [ ] 2b. `TOLLGATE=1 BOARD=NERDQAXEPLUS idf.py build` passes | ||
| 42 | |||
| 43 | --- | ||
| 44 | |||
| 45 | ## Phase 3: Wire WiFi AP Client Events | ||
| 46 | |||
| 47 | **File:** `esp-miner-nerdqaxeplus/components/connect/connect.c` (event_handler line 74) | ||
| 48 | |||
| 49 | - [ ] 3a. Add `#include "tollgate_core.h"` guarded by `#ifdef TOLLGATE` | ||
| 50 | - [ ] 3b. Add `WIFI_EVENT_AP_STACONNECTED` handler: resolve MAC→IP via `esp_wifi_ap_get_sta_list_with_ip()`, call `tollgate_core_client_connected(mac, ip)` | ||
| 51 | - [ ] 3c. Add `WIFI_EVENT_AP_STADISCONNECTED` handler: call `tollgate_core_client_disconnected(mac)` | ||
| 52 | - [ ] 3d. `TOLLGATE=1 BOARD=NERDQAXEPLUS idf.py build` passes | ||
| 53 | |||
| 54 | --- | ||
| 55 | |||
| 56 | ## Phase 4: Make Stratum Proxy Functional | ||
| 57 | |||
| 58 | **File:** `components/tollgate_core/src/tollgate_core_stratum_proxy.c` | ||
| 59 | |||
| 60 | - [ ] 4a. Line-buffer recv data, parse downstream miner messages using `tollgate_core_stratum_parse_*()`: | ||
| 61 | - `mining.subscribe` → respond with extranonce | ||
| 62 | - `mining.authorize` → respond with success | ||
| 63 | - `mining.submit` → validate difficulty, increment counters, call `tollgate_core_on_share_accepted()`, respond accept/reject | ||
| 64 | - [ ] 4b. Use real jobs from `tollgate_core_stratum_proxy_set_job()` instead of zeroed placeholders | ||
| 65 | |||
| 66 | **File:** `esp-miner-nerdqaxeplus/main/tasks/create_jobs_task.cpp` (line 176) | ||
| 67 | |||
| 68 | - [ ] 4c. Hook `create_job_mining_notify()` to forward pool jobs to proxy via `tollgate_core_stratum_proxy_set_job()`, guarded by `#ifdef TOLLGATE` | ||
| 69 | |||
| 70 | **File:** `esp-miner-nerdqaxeplus/main/stratum/stratum_manager.cpp` (line 179) | ||
| 71 | |||
| 72 | - [ ] 4d. Hook `mining.set_difficulty` to call `tollgate_core_mining_set_current_nbits()`, guarded by `#ifdef TOLLGATE` | ||
| 73 | |||
| 74 | - [ ] 4e. `idf.py build` passes for esp32-tollgate | ||
| 75 | - [ ] 4f. `TOLLGATE=1 BOARD=NERDQAXEPLUS idf.py build` passes | ||
| 76 | |||
| 77 | --- | ||
| 78 | |||
| 79 | ## Phase 5: Wire Share Accepted for Self-Mining Credit | ||
| 80 | |||
| 81 | **File:** `esp-miner-nerdqaxeplus/main/tollgate_platform.cpp` (line 137) | ||
| 82 | |||
| 83 | - [ ] 5a. Update `tollgate_on_share_accepted(double difficulty)` to call `tollgate_core_on_share_accepted(owner_ip, difficulty)` crediting the owner session | ||
| 84 | - [ ] 5b. `TOLLGATE=1 BOARD=NERDQAXEPLUS idf.py build` passes | ||
| 85 | |||
| 86 | --- | ||
| 87 | |||
| 88 | ## Phase 6: Dynamic AP IP and DNS | ||
| 89 | |||
| 90 | **File:** `esp-miner-nerdqaxeplus/main/tollgate_platform.cpp` (line 158) | ||
| 91 | |||
| 92 | - [ ] 6a. Replace hardcoded `192.168.4.1` with actual AP IP from `esp_netif_get_ip_info()` on AP netif | ||
| 93 | - [ ] 6b. Replace hardcoded upstream DNS `8.8.8.8` with STA gateway IP | ||
| 94 | - [ ] 6c. `TOLLGATE=1 BOARD=NERDQAXEPLUS idf.py build` passes | ||
| 95 | |||
| 96 | --- | ||
| 97 | |||
| 98 | ## Phase 7: Sync tollgate_core to NerdQAxePlus + Build Verify | ||
| 99 | |||
| 100 | - [ ] 7a. rsync `esp32-tollgate/components/tollgate_core/` → `esp-miner-nerdqaxeplus/components/tollgate_core/` | ||
| 101 | - [ ] 7b. `make test-unit` — all esp32-tollgate tests pass | ||
| 102 | - [ ] 7c. `idf.py build` — esp32-tollgate builds | ||
| 103 | - [ ] 7d. `TOLLGATE=1 BOARD=NERDQAXEPLUS idf.py build` — NerdQAxePlus builds | ||
| 104 | |||
| 105 | --- | ||
| 106 | |||
| 107 | ## Phase 8: Hardware Smoke Test on NerdQAxePlus | ||
| 108 | |||
| 109 | - [ ] 8a. Flash NerdQAxePlus with `TOLLGATE=1` to a NerdQAxe+ board | ||
| 110 | - [ ] 8b. Connect to AP, verify captive portal loads | ||
| 111 | - [ ] 8c. Test Cashu payment flow | ||
| 112 | - [ ] 8d. Connect Stratum miner to port 3334, verify shares tracked and sessions extended | ||
| 113 | - [ ] 8e. Verify board's own ASIC mining credits the owner | ||
| 114 | - [ ] 8f. Test grant/reset endpoints | ||
| 115 | - [ ] 8g. Test internet passthrough after payment | ||
| 116 | |||
| 117 | --- | ||
| 118 | |||
| 119 | ## Phase 9: Commit, Push, Publish | ||
| 120 | |||
| 121 | - [ ] 9a. Commit all tollgate_core changes to esp32-tollgate `feature/tollgate-core-v2` | ||
| 122 | - [ ] 9b. Push esp32-tollgate to nostr | ||
| 123 | - [ ] 9c. Commit all NerdQAxePlus integration to `develop` | ||
| 124 | - [ ] 9d. Push NerdQAxePlus to nostr | ||
| 125 | - [ ] 9e. Bump tollgate_core to v1.3.0 in `idf_component.yml` | ||
| 126 | - [ ] 9f. Re-publish to IDF Component Registry | ||
| 127 | |||
| 128 | --- | ||
| 129 | |||
| 130 | ## Dependency Order | ||
| 131 | |||
| 132 | ``` | ||
| 133 | Phase 1 → Phase 5 → Phase 7 → Phase 8 | ||
| 134 | Phase 1 → Phase 4 → Phase 7 → Phase 8 | ||
| 135 | Phase 2 → Phase 7 | ||
| 136 | Phase 3 → Phase 7 | ||
| 137 | Phase 6 → Phase 7 | ||
| 138 | Phase 7 → Phase 8 → Phase 9 | ||
| 139 | ``` | ||
| 140 | |||
| 141 | Phases 1–6 are independent (different files). Phase 7 bundles them. Phase 8 needs hardware. | ||