Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc573f075a | ||
|
|
1c364d4ff1 | ||
|
|
d54bd6473f | ||
|
|
a5b07d22ae | ||
|
|
3d17326460 | ||
|
|
56339a5eca | ||
|
|
00bb760451 |
@@ -11,6 +11,7 @@ jobs:
|
||||
candidate:
|
||||
runs-on: alkane-ci
|
||||
env:
|
||||
CARGO_TARGET_DIR: target
|
||||
WX_PREFIX: /root/.cache/wx-3.3.3-linux
|
||||
WX_RS_WXCONFIG: /root/.cache/wx-3.3.3-linux/bin/wx-config
|
||||
steps:
|
||||
@@ -46,3 +47,6 @@ jobs:
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: python3 ci/release-rc.py "${{ steps.version.outputs.tag }}" true "dist/alkane-toolkit-${{ steps.version.outputs.version }}-linux-x86_64.tar.gz"
|
||||
- name: Clean generated Toolkit build
|
||||
if: always()
|
||||
run: python3 ci/cleanup-generated.py
|
||||
|
||||
@@ -14,6 +14,7 @@ jobs:
|
||||
release:
|
||||
runs-on: alkane-ci
|
||||
env:
|
||||
CARGO_TARGET_DIR: target
|
||||
WX_PREFIX: /root/.cache/wx-3.3.3-linux
|
||||
# Set once for the whole job so build/clippy/test/bench steps don't each
|
||||
# re-export it (round 18 #12).
|
||||
@@ -166,7 +167,7 @@ jobs:
|
||||
python3 ci/gen-badges.py --tests "$PASS" \
|
||||
--coverage "${{ steps.cov.outputs.pct }}" \
|
||||
--bench-coverage "${{ steps.benchcov.outputs.pct }}" \
|
||||
--bench-delta "$BENCH_DELTA"
|
||||
--bench-delta "$BENCH_DELTA" --clippy clean
|
||||
|
||||
- name: Publish measured badges
|
||||
env:
|
||||
@@ -203,3 +204,6 @@ jobs:
|
||||
- name: No release needed
|
||||
if: steps.ver.outputs.release != 'true'
|
||||
run: echo "No backend/UI change since ${{ steps.ver.outputs.last_tag }} - skipping release."
|
||||
- name: Clean generated Toolkit build
|
||||
if: always()
|
||||
run: python3 ci/cleanup-generated.py
|
||||
|
||||
@@ -14,6 +14,7 @@ jobs:
|
||||
verify:
|
||||
runs-on: alkane-ci
|
||||
env:
|
||||
CARGO_TARGET_DIR: target
|
||||
WX_PREFIX: /root/.cache/wx-3.3.3-linux
|
||||
WX_RS_WXCONFIG: /root/.cache/wx-3.3.3-linux/bin/wx-config
|
||||
steps:
|
||||
@@ -76,3 +77,6 @@ jobs:
|
||||
else
|
||||
echo "cargo-audit not installed on this runner; skipping"
|
||||
fi
|
||||
- name: Clean generated Toolkit build
|
||||
if: always()
|
||||
run: python3 ci/cleanup-generated.py
|
||||
|
||||
Generated
+1
@@ -75,6 +75,7 @@ dependencies = [
|
||||
"alkane-artifacts",
|
||||
"alkane-core",
|
||||
"sha2",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# alkane-toolkit
|
||||
# Alkane Toolkit
|
||||
|
||||
[](https://gitea.bluefla.re/blueflare/alkane-toolkit/actions)
|
||||

|
||||
@@ -10,118 +10,61 @@
|
||||

|
||||

|
||||
|
||||
The CI badge shows the last completed attempt for this branch while newer
|
||||
runs are queued. Badge SVGs are stored in a private, machine-maintained branch.
|
||||
The code-quality letter requires warnings-denied Clippy and measured test plus
|
||||
UI self-test line coverage: A at 90%, B at 80%, C at 70%, D at 60%, and F
|
||||
below 60%. A missing coverage measurement displays pending.
|
||||
The benchmark delta compares an earlier commit only when its CPU class
|
||||
matches the current dedicated runner; otherwise it establishes a new
|
||||
baseline. Main CI runs microbenchmarks serially to avoid test contention.
|
||||
Desktop fleet discovery and monitoring for ASIC miners. The Rust GUI uses
|
||||
wxWidgets through a patched [wx-rs bridge](thirdparty/wx-rs). Firmware
|
||||
installation is under development.
|
||||
|
||||
A cross-platform desktop toolkit for discovering, monitoring, and re-flashing
|
||||
ASIC miners. It scans a fleet over the network, shows live health and hashrate
|
||||
in a sortable table. The install path is under development for **stock** and
|
||||
**alkaneOS** firmware on boards running stock, VNish/AnthillOS, Braiins OS+,
|
||||
LuxOS, ePIC, HiveOn, BixBit, WardenOS).
|
||||
|
||||
The core and UI are pure Rust; the native window is wxWidgets driven through a
|
||||
vendored, patched [wx-rs](thirdparty/wx-rs) bridge, so there is no Electron,
|
||||
no web view, and a single self-contained binary per platform.
|
||||
|
||||
## What it does
|
||||
|
||||
- **Discover** a fleet by CIDR or IP range and identify each miner's make,
|
||||
model, control board, and firmware (via a vendored [asic-rs](vendor/asic-rs)).
|
||||
- **Monitor** hashrate vs. expected, per-board health, chip temperatures, fans,
|
||||
PSU state, and pool workers, with an Excel-style filter and drag-reorderable
|
||||
columns.
|
||||
- **Operate** miners from a right-click menu: flash the locate light, pause /
|
||||
resume, restart, set a power or hashrate target, select a firmware profile
|
||||
(LuxOS/VNish presets), configure pools, set the timezone, and change the
|
||||
password -- each action offered only when every selected miner supports it.
|
||||
- **Install firmware**: push stock or aftermarket images, or revert an
|
||||
aftermarket miner to stock, behind a typed confirmation.
|
||||
|
||||
Discovery and telemetry are read-only and safe to run against any fleet; every
|
||||
mutating action is capability-gated and, where destructive, confirmed.
|
||||
|
||||
## Build and run (Debian/Ubuntu)
|
||||
## Run locally
|
||||
|
||||
```sh
|
||||
scripts/build-wx-linux.sh # once: builds the vendored wxWidgets 3.3.3 into ~/.cache
|
||||
scripts/build-gui-linux.sh # cargo build --release -p alkane-gui
|
||||
~/.cache/alkane-tk-target/release/alkane-toolkit
|
||||
scripts/build-wx-linux.sh
|
||||
scripts/build-gui-linux.sh
|
||||
ALKANE_FAKE_SCAN=1 ~/.cache/alkane-tk-target/release/alkane-toolkit
|
||||
```
|
||||
|
||||
Runtime needs GTK 3: `sudo apt install libgtk-3-0`. To explore the UI with no
|
||||
hardware, run the offline demo fleet:
|
||||
The first command builds wxWidgets 3.3.3 once. Linux runtime needs GTK 3
|
||||
(`libgtk-3-0` on Debian/Ubuntu). The fake scan uses offline fixtures and
|
||||
does not contact hardware. Windows and macOS use their respective
|
||||
`scripts/build-gui-*.sh` scripts and platform toolchains.
|
||||
|
||||
```sh
|
||||
ALKANE_FAKE_SCAN=1 alkane-toolkit
|
||||
```
|
||||
## Current scope
|
||||
|
||||
Windows and macOS share all GUI code; only the C++ bridge and wx build differ
|
||||
(`scripts/build-gui-windows.sh` needs an msys2 toolchain, `-macos.sh` needs a
|
||||
Mac).
|
||||
- Discover miners by CIDR or IP range with vendored
|
||||
[asic-rs](vendor/asic-rs), and show model, firmware, health, hashrate,
|
||||
temperatures, fans, PSU, and pool workers.
|
||||
- Filter, sort, and reorder columns in the desktop table.
|
||||
- Probe discovery, telemetry, presets, and write actions with the
|
||||
`miner_probe` CLI. Run it without arguments for the verb list.
|
||||
|
||||
## Command-line probe
|
||||
|
||||
`miner_probe` is a headless companion for hardware checks that should not go
|
||||
through the window event loop -- discovery, telemetry, and each write action:
|
||||
|
||||
```sh
|
||||
miner_probe scan 10.0.0.0/24 # discover + telemetry (TSV)
|
||||
miner_probe presets 10.0.0.5 # list a firmware's selectable profiles
|
||||
miner_probe setpreset 10.0.0.5 540MHz
|
||||
```
|
||||
|
||||
Run `miner_probe` with no arguments for the full verb list.
|
||||
The installer and some operator actions remain roadmap items; see the
|
||||
[implementation plan](docs/IMPLEMENTATION-PLAN.md) and
|
||||
[firmware parity matrix](docs/aftermarket-parity-roadmap.md). A listed
|
||||
firmware or board is not an install claim. Discovery is read-only.
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
export WX_RS_WXCONFIG="$HOME/.cache/wx-3.3.3-linux/bin/wx-config"
|
||||
export CARGO_TARGET_DIR="$HOME/.cache/alkane-tk-target" # keep the target tree off the source share
|
||||
|
||||
cargo test -p alkane-gui # unit tests
|
||||
cargo test -p alkane-gui --release -- --ignored bench_ # microbenchmarks
|
||||
cargo clippy -p alkane-gui --no-deps --bins -- -D warnings # lint gate
|
||||
xvfb-run -a env ALKANE_SELFTEST=1 \
|
||||
"$CARGO_TARGET_DIR/release/alkane-toolkit" # headless UI self-test
|
||||
ci/coverage.sh --summary-only # coverage (tests + self-test)
|
||||
export CARGO_TARGET_DIR="$HOME/.cache/alkane-tk-target"
|
||||
cargo test -p alkane-gui --offline
|
||||
cargo clippy -p alkane-gui --no-deps --bins -- -D warnings
|
||||
scripts/ui-selftest.sh
|
||||
ci/coverage.sh --summary-only
|
||||
```
|
||||
|
||||
CI mirrors these: `verify.yml` runs lint, tests, benchmarks, the self-test, and
|
||||
a dependency audit on development branches. `release.yml` runs the full gate
|
||||
on every `main` push and cuts an `X.Y.Z` release when the change warrants it.
|
||||
`next.yml` builds release candidates with little testing and publishes `-rc`
|
||||
releases. Dependencies are vendored under `vendor/`, so builds never touch the
|
||||
network.
|
||||
Keep build output off the source share. `main` runs the full CI gate and
|
||||
publishes qualifying releases; `next` builds `-rc` candidates. Badges
|
||||
report host tests and benchmarks, not installation support. Benchmark
|
||||
comparisons require the same CPU class. The code quality letter reports the
|
||||
Clippy gate; the separate coverage badge reports exercised lines.
|
||||
|
||||
## Architecture
|
||||
## Firmware safety
|
||||
|
||||
- `crates/alkane-gui` -- the application: scan engine, data model, wxWidgets UI,
|
||||
and the `miner_probe` CLI (the other `crates/alkane-*` are early scaffolding).
|
||||
- `vendor/asic-rs` -- the miner-discovery and control library, vendored and
|
||||
extended through numbered patches under `thirdparty/asic-rs/patches`.
|
||||
- `thirdparty/wx-rs` -- the patched wxWidgets bridge (see `docs/adr/0002`,
|
||||
`0003`).
|
||||
|
||||
See [`docs/IMPLEMENTATION-PLAN.md`](docs/IMPLEMENTATION-PLAN.md) for the roadmap
|
||||
and [`docs/aftermarket-parity-roadmap.md`](docs/aftermarket-parity-roadmap.md)
|
||||
for the firmware config/scan parity work.
|
||||
|
||||
## Firmware safety rules
|
||||
|
||||
Encoded in code, from alkane-sdk `docs/install-methods.md`:
|
||||
|
||||
1. Never write the bootloader or secure region.
|
||||
2. Verify on a channel the installer does not control.
|
||||
3. Reboot is root-only; a dropped SSH connection can still be success.
|
||||
4. A packer is per board; never reuse one across boards.
|
||||
5. Boot-switch handling is an explicit, verified step.
|
||||
The [SDK install rules](https://gitea.bluefla.re/blueflare/alkane-sdk/src/branch/main/docs/install-methods.md) require
|
||||
serial and recovery checks for risky writes. Installation must never write
|
||||
the bootloader or secure region, must verify over an independent channel,
|
||||
and must use the packer and boot-switch procedure for the exact board.
|
||||
|
||||
## License
|
||||
|
||||
Licensed under the [MIT license](LICENSE).
|
||||
[MIT](LICENSE). Vendored dependencies keep their own terms.
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Remove generated Toolkit CI work after the release asset is uploaded."""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DIRECTORIES = ("target", "dist", "coverage")
|
||||
FILES = ("bench-current.txt",)
|
||||
|
||||
|
||||
def cleanup() -> None:
|
||||
if not os.environ.get("GITHUB_RUN_ID"):
|
||||
raise ValueError("cleanup is restricted to CI runs")
|
||||
for name in DIRECTORIES:
|
||||
path = ROOT / name
|
||||
if path.is_symlink() or path.parent.resolve() != ROOT.resolve():
|
||||
raise ValueError(f"unsafe generated directory: {path}")
|
||||
if path.is_dir():
|
||||
shutil.rmtree(path)
|
||||
print(f"Removed generated directory: {name}")
|
||||
elif path.exists():
|
||||
raise ValueError(f"expected a generated directory: {path}")
|
||||
for name in FILES:
|
||||
path = ROOT / name
|
||||
if path.is_symlink() or path.parent.resolve() != ROOT.resolve():
|
||||
raise ValueError(f"unsafe generated file: {path}")
|
||||
if path.is_file():
|
||||
path.unlink()
|
||||
print(f"Removed generated file: {name}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
cleanup()
|
||||
except (OSError, ValueError) as error:
|
||||
print(f"ERROR: Toolkit cleanup: {error}", file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
+13
-12
@@ -2,10 +2,11 @@
|
||||
# Measure line coverage from BOTH the unit tests AND the headless UI self-test.
|
||||
#
|
||||
# The self-test (ALKANE_SELFTEST=1) builds the real wxWidgets table, renders every
|
||||
# fixture through the real widgets, and checks each cell against the model -- it
|
||||
# exercises most of ui.rs. Because it runs as a separate binary invocation, a plain
|
||||
# `cargo llvm-cov` (which only runs the #[test]s) never counts it, so ui.rs shows
|
||||
# ~4% even though it is integration-tested. This combines both runs' coverage.
|
||||
# fixture through the real widgets, and checks each cell against the model.
|
||||
# It covers the fixture-rendering path, while interactive event handlers need
|
||||
# separate tests. Because it runs as a separate binary invocation, a plain
|
||||
# `cargo llvm-cov` (which only runs the #[test]s) never counts it. This
|
||||
# combines both runs' coverage.
|
||||
#
|
||||
# Usage: ci/coverage.sh [extra `cargo llvm-cov report` args, e.g. --summary-only]
|
||||
set -euo pipefail
|
||||
@@ -16,8 +17,12 @@ export WX_RS_WXCONFIG="${WX_RS_WXCONFIG:-$HOME/.cache/wx-3.3.3-linux/bin/wx-conf
|
||||
# default; override with CARGO_LLVM_COV_FLAGS if you need something else.
|
||||
read -ra CARGO_FLAGS <<<"${CARGO_LLVM_COV_FLAGS:---offline}"
|
||||
|
||||
# A display for the self-test's real widgets.
|
||||
need_xvfb() { command -v xvfb-run >/dev/null 2>&1; }
|
||||
# A display is required for the self-test; skipping it would publish an
|
||||
# incomplete coverage number as if the measured test set had run.
|
||||
if ! command -v xvfb-run >/dev/null 2>&1; then
|
||||
echo "coverage.sh: xvfb-run is required for the UI self-test" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cargo llvm-cov clean --workspace
|
||||
|
||||
@@ -27,12 +32,8 @@ cargo llvm-cov --no-report "${CARGO_FLAGS[@]}" \
|
||||
-p alkane-artifacts -p alkane-flash -p alkane-cli
|
||||
|
||||
# 2. Headless UI self-test, under the same instrumentation, its coverage appended.
|
||||
if need_xvfb; then
|
||||
xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 \
|
||||
cargo llvm-cov run --no-report "${CARGO_FLAGS[@]}" --bin alkane-toolkit
|
||||
else
|
||||
echo "coverage.sh: xvfb-run not found; skipping the self-test run (unit tests only)" >&2
|
||||
fi
|
||||
xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 \
|
||||
cargo llvm-cov run --no-report "${CARGO_FLAGS[@]}" --bin alkane-toolkit
|
||||
|
||||
# 3. Merged report, our source only (vendored asic-rs + the patched wx-rs bridge
|
||||
# are out of scope).
|
||||
|
||||
+5
-10
@@ -131,15 +131,10 @@ def cov_color(pct: float) -> str:
|
||||
return "red"
|
||||
|
||||
|
||||
def quality_grade(clippy: str, coverage: float | None) -> str:
|
||||
if clippy != "clean":
|
||||
return "F"
|
||||
if coverage is None:
|
||||
def quality_grade(clippy: str | None) -> str:
|
||||
if clippy is None:
|
||||
return "pending"
|
||||
for minimum, grade in ((90, "A"), (80, "B"), (70, "C"), (60, "D")):
|
||||
if coverage >= minimum:
|
||||
return grade
|
||||
return "F"
|
||||
return "A" if clippy == "clean" else "F"
|
||||
|
||||
|
||||
def human(n: int) -> str:
|
||||
@@ -170,7 +165,7 @@ def main() -> int:
|
||||
# percentage string (e.g. "-3.2"), or "NEW"/"" when there is no baseline yet
|
||||
# (round 19 #1). Takes precedence over --bench for the bench badge.
|
||||
ap.add_argument("--bench-delta", default=None)
|
||||
ap.add_argument("--clippy", default="clean")
|
||||
ap.add_argument("--clippy", choices=("clean", "failed"))
|
||||
args = ap.parse_args()
|
||||
for value in (args.coverage, args.bench_coverage):
|
||||
if value is not None and (not math.isfinite(value) or not 0 <= value <= 100):
|
||||
@@ -191,7 +186,7 @@ def main() -> int:
|
||||
write("loc", "lines of code", human(loc), loc_color(loc))
|
||||
write("license", "license", lic, "blue")
|
||||
write("dependencies", "dependencies", str(deps), "blue")
|
||||
grade = quality_grade(args.clippy, args.coverage)
|
||||
grade = quality_grade(args.clippy)
|
||||
write("quality", "code quality", grade,
|
||||
{"A": "brightgreen", "B": "yellowgreen", "C": "yellow",
|
||||
"D": "orange", "F": "red", "pending": "lightgrey"}[grade])
|
||||
|
||||
@@ -9,3 +9,4 @@ alkane-core = { path = "../alkane-core" }
|
||||
alkane-artifacts = { path = "../alkane-artifacts" }
|
||||
sha2.workspace = true
|
||||
thiserror.workspace = true
|
||||
tempfile = "3"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
use alkane_artifacts::VerifiedArtifact;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::io::{Read, Seek, SeekFrom};
|
||||
use std::io::{Read, Seek, SeekFrom, Write};
|
||||
use thiserror::Error;
|
||||
|
||||
pub struct PartitionSpec {
|
||||
@@ -90,6 +90,34 @@ fn digest_bytes(hex: &str) -> Result<[u8; 32], FlashError> {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn stage_verified_artifact(
|
||||
artifact: &mut VerifiedArtifact,
|
||||
size: u64,
|
||||
expected: [u8; 32],
|
||||
) -> Result<std::fs::File, FlashError> {
|
||||
let mut staged = tempfile::tempfile().map_err(|e| FlashError::ArtifactIo(e.to_string()))?;
|
||||
artifact
|
||||
.reader()
|
||||
.seek(SeekFrom::Start(0))
|
||||
.map_err(|e| FlashError::ArtifactIo(e.to_string()))?;
|
||||
let mut source = DigestReader {
|
||||
inner: artifact.reader(),
|
||||
remaining: size,
|
||||
digest: Sha256::new(),
|
||||
};
|
||||
std::io::copy(&mut source, &mut staged).map_err(|e| FlashError::ArtifactIo(e.to_string()))?;
|
||||
if source.remaining != 0 || <[u8; 32]>::from(source.digest.finalize()) != expected {
|
||||
return Err(FlashError::ArtifactChanged);
|
||||
}
|
||||
staged
|
||||
.flush()
|
||||
.map_err(|e| FlashError::ArtifactIo(e.to_string()))?;
|
||||
staged
|
||||
.seek(SeekFrom::Start(0))
|
||||
.map_err(|e| FlashError::ArtifactIo(e.to_string()))?;
|
||||
Ok(staged)
|
||||
}
|
||||
|
||||
struct DigestReader<'a> {
|
||||
inner: &'a mut dyn Read,
|
||||
remaining: u64,
|
||||
@@ -145,6 +173,10 @@ pub fn write_verified<W: Writer, R: IndependentReadback>(
|
||||
artifact
|
||||
.revalidate()
|
||||
.map_err(|_| FlashError::ArtifactChanged)?;
|
||||
let expected = digest_bytes(&artifact.record().sha256)?;
|
||||
// The source path may change while backup or transport I/O runs. Copy and
|
||||
// verify it before any device write; the anonymous file is removed on drop.
|
||||
let mut staged = stage_verified_artifact(artifact, size, expected)?;
|
||||
let backup = writer
|
||||
.backup(partition)
|
||||
.map_err(|e| FlashError::Write(e.to_string()))?;
|
||||
@@ -154,13 +186,8 @@ pub fn write_verified<W: Writer, R: IndependentReadback>(
|
||||
{
|
||||
return Err(FlashError::BackupIncomplete);
|
||||
}
|
||||
let expected = digest_bytes(&artifact.record().sha256)?;
|
||||
artifact
|
||||
.reader()
|
||||
.seek(SeekFrom::Start(0))
|
||||
.map_err(|e| FlashError::ArtifactIo(e.to_string()))?;
|
||||
let mut stream = DigestReader {
|
||||
inner: artifact.reader(),
|
||||
inner: &mut staged,
|
||||
remaining: size,
|
||||
digest: Sha256::new(),
|
||||
};
|
||||
@@ -203,6 +230,7 @@ mod tests {
|
||||
max_read: Option<u64>,
|
||||
writes: usize,
|
||||
contents: Vec<u8>,
|
||||
mutate_source_on_write: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl Writer for MockWriter {
|
||||
@@ -231,6 +259,9 @@ mod tests {
|
||||
_: u64,
|
||||
) -> Result<(), Self::Error> {
|
||||
self.writes += 1;
|
||||
if let Some(path) = &self.mutate_source_on_write {
|
||||
std::fs::write(path, b"PK\x03\x04changed").map_err(|_| "mutation failed")?;
|
||||
}
|
||||
if let Some(limit) = self.max_read {
|
||||
image
|
||||
.take(limit)
|
||||
@@ -285,6 +316,7 @@ mod tests {
|
||||
max_read: None,
|
||||
writes: 0,
|
||||
contents: Vec::new(),
|
||||
mutate_source_on_write: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,4 +427,20 @@ mod tests {
|
||||
assert_eq!(writer.writes, 1);
|
||||
std::fs::remove_file(path).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn writes_verified_snapshot_when_source_changes_during_transport() {
|
||||
let (path, mut image) = artifact("mutated-during-write");
|
||||
let mut writer = writer();
|
||||
writer.mutate_source_on_write = Some(path.clone());
|
||||
let mut readback = MockReadback {
|
||||
channel: "serial",
|
||||
digest: digest_bytes(SHA).unwrap(),
|
||||
};
|
||||
let receipt = write_verified(&partition(), &mut image, &mut writer, &mut readback).unwrap();
|
||||
assert_eq!(receipt.image_sha256, digest_bytes(SHA).unwrap());
|
||||
assert_eq!(writer.contents, IMAGE);
|
||||
assert_eq!(std::fs::read(&path).unwrap(), b"PK\x03\x04changed");
|
||||
std::fs::remove_file(path).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2604,6 +2604,38 @@ mod tests {
|
||||
assert!(per.as_millis() < 100, "cell rendering regressed: {per:?}");
|
||||
}
|
||||
|
||||
/// Microbenchmark: component health scores and operator-facing diagnostics
|
||||
/// recomputed when scan results refresh the table.
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn bench_health_diagnostics() {
|
||||
use std::hint::black_box;
|
||||
use std::time::Instant;
|
||||
|
||||
let rows = bench_fleet();
|
||||
let iters = 1000u32;
|
||||
let start = Instant::now();
|
||||
let mut sink = 0usize;
|
||||
for _ in 0..iters {
|
||||
for row in &rows {
|
||||
for facet in [
|
||||
HealthFacet::Overall,
|
||||
HealthFacet::Power,
|
||||
HealthFacet::Fans,
|
||||
HealthFacet::Boards,
|
||||
] {
|
||||
sink += black_box(row.health_score(facet)) as usize;
|
||||
}
|
||||
sink += row.health_summary().len();
|
||||
sink += row.health_tooltips(4, 3).iter().map(String::len).sum::<usize>();
|
||||
}
|
||||
}
|
||||
black_box(sink);
|
||||
let per = start.elapsed() / iters;
|
||||
println!("bench_health_diagnostics: {} rows = {:?}/refresh", rows.len(), per);
|
||||
assert!(per.as_millis() < 20, "health diagnostics regressed: {per:?}/refresh");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn selection_survives_upsert() {
|
||||
let mut rows = bench_fleet();
|
||||
|
||||
@@ -58,7 +58,11 @@ pub fn firmware_family(raw: &str) -> (String, Option<String>) {
|
||||
// Vendor prefixes asic-rs prepends on stock-firmware family strings, matched
|
||||
// case-insensitively.
|
||||
for vendor in ["AntMiner", "WhatsMiner"] {
|
||||
if trimmed.len() > vendor.len() && trimmed[..vendor.len()].eq_ignore_ascii_case(vendor) {
|
||||
if trimmed.len() > vendor.len()
|
||||
&& trimmed
|
||||
.get(..vendor.len())
|
||||
.is_some_and(|prefix| prefix.eq_ignore_ascii_case(vendor))
|
||||
{
|
||||
let rest = trimmed[vendor.len()..].trim();
|
||||
if !rest.is_empty() {
|
||||
return (rest.to_string(), Some(vendor.to_string()));
|
||||
@@ -477,6 +481,35 @@ mod tests {
|
||||
assert_eq!(firmware_family("Braiins"), ("Braiins".to_string(), None));
|
||||
// A bare vendor word with nothing after it is left as-is (not emptied).
|
||||
assert_eq!(firmware_family("AntMiner"), ("AntMiner".to_string(), None));
|
||||
// Firmware strings arrive from the network and may contain UTF-8 at
|
||||
// the byte position used to check a vendor prefix.
|
||||
let non_ascii = "AntMine\u{e9} Stock";
|
||||
assert_eq!(firmware_family(non_ascii), (non_ascii.to_string(), None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "microbenchmark"]
|
||||
fn bench_naming_transforms() {
|
||||
let cases = [
|
||||
("Antminer", "S19jPro", "AntMiner Stock", "Xilinx"),
|
||||
("Antminer", "S21Pro", "VNish", "CVITek"),
|
||||
("Whatsminer", "M30SPlusVE40", "WhatsMiner Stock", "H616"),
|
||||
("Whatsminer", "M50SPlusPlusVK30", "Braiins", "H6"),
|
||||
];
|
||||
let iterations = 20_000;
|
||||
let started = std::time::Instant::now();
|
||||
for index in 0..iterations {
|
||||
let (make, model, firmware, board) = cases[index % cases.len()];
|
||||
let clean = clean_model(make, model);
|
||||
std::hint::black_box(firmware_family(firmware));
|
||||
std::hint::black_box(control_board_code(make, board, &clean));
|
||||
std::hint::black_box(chip_type_for_model(make, model));
|
||||
std::hint::black_box(clean);
|
||||
}
|
||||
let elapsed = started.elapsed();
|
||||
let per = elapsed / iterations as u32;
|
||||
println!("bench_naming_transforms: {per:?}/record");
|
||||
assert!(elapsed < std::time::Duration::from_millis(500));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
# UI Spec — primary view
|
||||
# Primary view
|
||||
|
||||
Source: operator description, 2026-09-15. Status: ACCEPTED (v1 scope).
|
||||
|
||||
## Header (above the table)
|
||||
## Header
|
||||
|
||||
- **KPI block, top left — 6 KPIs:**
|
||||
- **KPI block, top left: 6 KPIs:**
|
||||
1. Total miners
|
||||
2. Hashing
|
||||
3. Slow
|
||||
@@ -31,7 +31,7 @@ Source: operator description, 2026-09-15. Status: ACCEPTED (v1 scope).
|
||||
4. Cooling (fan)
|
||||
5. Firmware
|
||||
6. Pool worker account name
|
||||
7. …then the remaining statistics in registry order.
|
||||
7. Remaining statistics in registry order.
|
||||
|
||||
## Data sources
|
||||
|
||||
@@ -45,10 +45,10 @@ Source: operator description, 2026-09-15. Status: ACCEPTED (v1 scope).
|
||||
ships with the board registry; missing band = excluded from Slow, counted
|
||||
in Hashing).
|
||||
|
||||
## Implementation notes
|
||||
## Implementation
|
||||
|
||||
- wxWidgets: the view is a `wxDataViewListCtrl`/`wxDataViewCtrl` (virtual
|
||||
list — thousands of rows without materializing cells), checkbox column +
|
||||
list for thousands of rows without materializing cells), checkbox column +
|
||||
IP column fixed via attribute/serializer, drag reorder via `wxReorderable`
|
||||
column events, sort via column header click events mapped to the model.
|
||||
- Filter panel: per-column distinct-value checklist with text search,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ADR 0001: Recipes as data, interpreted by one engine
|
||||
# ADR 0001: Recipe engine
|
||||
|
||||
Status: ACCEPTED
|
||||
Date: 2026-09-14
|
||||
|
||||
@@ -1,41 +1,27 @@
|
||||
# ADR 0002: GUI bindings — wxWidgets shell in C++ + Rust core, spike to revisit
|
||||
# ADR 0002: GUI bindings
|
||||
|
||||
Status: RESOLVED 2026-09-15 - the operator chose Option B (pure Rust via
|
||||
wx-rs) with vendoring (ADR-0003). wx-rs 0.2.0 was extended via the patch
|
||||
queue: Linux/GTK3 wx-config build path plus the widget bridge (panel,
|
||||
sizers, static text, button, text ctrl, checkbox, checklistbox, dialog,
|
||||
data view list ctrl, timer). The app ships this way; no C++ shell.
|
||||
Date: 2026-09-14
|
||||
Resolved: 2026-09-15
|
||||
|
||||
## Context
|
||||
|
||||
The toolkit must present a native cross-platform GUI (wxWidgets chosen).
|
||||
Rust bindings to wxWidgets checked on crates.io 2026-09-14:
|
||||
|
||||
- `wxRust` 0.0.1-alpha — unmaintained since 2022.
|
||||
- `wx-rs` 0.2.0 (2023, self-contained) — ~6k downloads, no 1.0.
|
||||
|
||||
Betting the GUI on alpha bindings risks weeks of binding-gap debugging
|
||||
(paste-heavy widgets, worker threads + event loops, GTK/WinCocoa quirks).
|
||||
The toolkit needs a native wxWidgets GUI. At the time of evaluation,
|
||||
`wxRust` 0.0.1-alpha had seen no maintenance since 2022, and `wx-rs`
|
||||
0.2.0 lacked widgets needed for the Toolkit.
|
||||
|
||||
## Decision
|
||||
|
||||
Default: **thin C++17 wxWidgets shell (`gui/`) + Rust core exposed over a
|
||||
small stable C ABI** (cdylib from `alkane-core`, header generated with
|
||||
cbindgen). The shell holds frames, lists, the install wizard, and event
|
||||
glue only — no business logic, no safety logic. All invariants, engines,
|
||||
and tests live in Rust where they are testable headlessly.
|
||||
The operator chose a Rust GUI through a vendored, patched `wx-rs` 0.2.0.
|
||||
The patch queue adds the Linux/GTK3 build path and bindings for panels,
|
||||
sizers, controls, dialogs, data views, timers, and event dispatch. The
|
||||
application uses this bridge; it has no separate C++ shell.
|
||||
|
||||
Gate: M0 runs a time-boxed `wx-rs` spike (window + list/tree + wizard flow
|
||||
+ worker-thread progress + cancel on Linux and Windows). If the spike is
|
||||
solid, flip to pure Rust; either way the decision is recorded before M3.
|
||||
The original proposal was a small C++17 wxWidgets shell calling a Rust
|
||||
core through a C ABI. The `wx-rs` spike met the GUI need, so that proposal
|
||||
was not adopted.
|
||||
|
||||
## Consequences
|
||||
|
||||
- The repo builds two things: a Rust workspace and a small C++ app linked
|
||||
against the core cdylib. CMake in `gui/`.
|
||||
- Core API surface stays small and event-oriented (discover, identify,
|
||||
plan, execute, cancel, progress events, log tail) — good FFI hygiene and
|
||||
a natural match for the CLI too (D4).
|
||||
- If wx-rs wins the spike, the C ABI is kept as an integration boundary for
|
||||
scripted/HIL use anyway.
|
||||
- Keep business logic and safety checks in testable Rust code.
|
||||
- Carry wx-rs changes as numbered patches under `thirdparty/wx-rs/patches`.
|
||||
- Recheck the bridge on Linux, Windows, and macOS packaging changes.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ADR 0003: Vendoring policy — pristine upstream archives + patch queue
|
||||
# ADR 0003: Vendoring
|
||||
|
||||
Status: ACCEPTED
|
||||
Date: 2026-09-15
|
||||
@@ -42,7 +42,7 @@ thirdparty/
|
||||
|
||||
Rules:
|
||||
|
||||
1. Never edit a vendored pristine tree in place — every local change is a
|
||||
1. Never edit a vendored pristine tree in place. Every local change is a
|
||||
patch in `patches/`, applied by the build in numeric order. This makes
|
||||
an upstream update: replace pristine archive, `git apply` surviving
|
||||
patches, rebase the rest.
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# scripts/build-wx-linux.sh to produce it).
|
||||
set -e
|
||||
REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
trap 'bash "$REPO/scripts/clean-old-builds.sh" || true' 0
|
||||
WX_PREFIX="${1:-$HOME/.cache/wx-3.3.3-linux}"
|
||||
if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then
|
||||
"$REPO/scripts/build-wx-linux.sh"
|
||||
|
||||
@@ -6,6 +6,21 @@ REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
SRC="$REPO/thirdparty/wxwidgets/wxWidgets-3.3.3"
|
||||
BUILD="$HOME/.cache/wxbuild/wxWidgets-3.3.3"
|
||||
PREFIX="$HOME/.cache/wx-3.3.3-linux"
|
||||
cleanup_wx_build() {
|
||||
python3 - "$BUILD" "$HOME/.cache/wxbuild" <<'PY'
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
build, parent = map(Path, sys.argv[1:])
|
||||
if (build.name != "wxWidgets-3.3.3" or build.parent != parent
|
||||
or build.is_symlink() or parent.is_symlink()):
|
||||
raise SystemExit("refusing unsafe wxWidgets build cleanup path")
|
||||
if build.is_dir():
|
||||
shutil.rmtree(build)
|
||||
PY
|
||||
}
|
||||
trap cleanup_wx_build 0
|
||||
[ -d "$BUILD" ] || { mkdir -p "$HOME/.cache/wxbuild"; cp -r "$SRC" "$BUILD"; }
|
||||
[ -d "$BUILD" ] || { echo "thirdparty wxWidgets tree missing"; exit 1; }
|
||||
chmod +x "$BUILD/configure" "$BUILD/config.guess" "$BUILD/config.sub" "$BUILD/install-sh" 2>/dev/null || true
|
||||
|
||||
@@ -18,6 +18,15 @@
|
||||
set -uo pipefail
|
||||
|
||||
TARGET="${CARGO_TARGET_DIR:-$HOME/.cache/alkane-tk-target}"
|
||||
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
case "$(realpath -m "$TARGET")" in
|
||||
"$HOME/.cache/alkane-tk-target"|"$REPO/target") ;;
|
||||
*) echo "clean-old-builds: refusing unexpected target $TARGET" >&2; exit 1 ;;
|
||||
esac
|
||||
if [ -L "$TARGET" ]; then
|
||||
echo "clean-old-builds: refusing symlink target $TARGET" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$TARGET" ]; then
|
||||
echo "clean-old-builds: no target dir at $TARGET (nothing to do)"
|
||||
exit 0
|
||||
|
||||
+27
-17
@@ -8,13 +8,13 @@
|
||||
#
|
||||
# Usage: scripts/ui-screenshot.sh [out.png] [--live] [binary]
|
||||
set -u
|
||||
REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
REPO=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
WX_PREFIX="${WX_PREFIX:-$HOME/.cache/wx-3.3.3-linux}"
|
||||
export WX_RS_WXCONFIG="${WX_RS_WXCONFIG:-$WX_PREFIX/bin/wx-config}"
|
||||
|
||||
OUT="${1:-alkane-toolkit.png}"
|
||||
LIVE=0; BIN=""
|
||||
shift 2>/dev/null || true
|
||||
[ "$#" -eq 0 ] || shift
|
||||
for a in "$@"; do
|
||||
case "$a" in
|
||||
--live) LIVE=1 ;;
|
||||
@@ -32,17 +32,31 @@ if [ -z "$BIN" ]; then
|
||||
fi
|
||||
[ -x "$BIN" ] || { echo "binary not found: $BIN" >&2; exit 3; }
|
||||
|
||||
DISP=":98"
|
||||
FAKE_ENV="ALKANE_FAKE_SCAN=1"
|
||||
[ "$LIVE" = "1" ] && FAKE_ENV=""
|
||||
|
||||
Xvfb "$DISP" -screen 0 1280x850x24 -nolisten tcp >/dev/null 2>&1 &
|
||||
DISPLAY_FILE=$(mktemp)
|
||||
XPID=""; APID=""; WARM=""
|
||||
cleanup() {
|
||||
[ -z "$APID" ] || kill "$APID" 2>/dev/null || true
|
||||
[ -z "$WARM" ] || kill "$WARM" 2>/dev/null || true
|
||||
[ -z "$XPID" ] || kill "$XPID" 2>/dev/null || true
|
||||
rm -f "$DISPLAY_FILE"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
Xvfb -displayfd 3 -screen 0 1280x850x24 -nolisten tcp 3>"$DISPLAY_FILE" >/dev/null 2>&1 &
|
||||
XPID=$!
|
||||
sleep 1.2
|
||||
for _ in {1..30}; do
|
||||
[ -s "$DISPLAY_FILE" ] && break
|
||||
kill -0 "$XPID" 2>/dev/null || { echo "Xvfb exited before startup" >&2; exit 3; }
|
||||
sleep 0.1
|
||||
done
|
||||
[ -s "$DISPLAY_FILE" ] || { echo "Xvfb did not start" >&2; exit 3; }
|
||||
DISP=":$(cat "$DISPLAY_FILE")"
|
||||
# warm the font/GTK caches so the first window map is not stalled
|
||||
DISPLAY="$DISP" xclock >/dev/null 2>&1 & WARM=$!; sleep 1.2; kill "$WARM" 2>/dev/null
|
||||
# shellcheck disable=SC2086
|
||||
DISPLAY="$DISP" GDK_BACKEND=x11 $FAKE_ENV "$BIN" >/dev/null 2>&1 &
|
||||
if [ "$LIVE" = "1" ]; then
|
||||
DISPLAY="$DISP" GDK_BACKEND=x11 "$BIN" >/dev/null 2>&1 &
|
||||
else
|
||||
DISPLAY="$DISP" GDK_BACKEND=x11 ALKANE_FAKE_SCAN=1 "$BIN" >/dev/null 2>&1 &
|
||||
fi
|
||||
APID=$!
|
||||
WID=""; t=0
|
||||
while [ "$t" -lt 25 ]; do
|
||||
@@ -52,10 +66,6 @@ while [ "$t" -lt 25 ]; do
|
||||
[ -n "$line" ] && { WID=$(echo "$line" | awk '{print $1}'); break; }
|
||||
done
|
||||
sleep 2 # let it paint and drain a scan tick
|
||||
if [ -n "$WID" ]; then
|
||||
DISPLAY="$DISP" import -window "$WID" "$OUT" && echo "wrote $OUT (window $WID, ${t}s)"
|
||||
else
|
||||
DISPLAY="$DISP" import -window root "$OUT"; echo "no app window; captured root -> $OUT" >&2
|
||||
fi
|
||||
kill "$APID" 2>/dev/null
|
||||
kill "$XPID" 2>/dev/null
|
||||
[ -n "$WID" ] || { echo "no app window mapped" >&2; exit 1; }
|
||||
DISPLAY="$DISP" import -window "$WID" "$OUT" || exit 1
|
||||
echo "wrote $OUT (window $WID, ${t}s)"
|
||||
|
||||
Reference in New Issue
Block a user