Compare commits

...
3 Commits
Author SHA1 Message Date
noah 1323dc1571 Add bounded read-only SSH board probes 2026-10-17 08:00:36 -06:00
noah 848a78ed5f docs: shorten Toolkit entry guide 2026-10-17 01:42:12 -06:00
noah 8d092ae417 Publish Toolkit benchmarks on the standing Alkane runner 2026-10-17 01:21:21 -06:00
7 changed files with 287 additions and 46 deletions
+34
View File
@@ -0,0 +1,34 @@
name: public-benchmark-pages
on:
schedule:
- cron: '*/15 * * * *'
workflow_dispatch:
concurrency:
group: alkane-toolkit-public-benchmark-pages
cancel-in-progress: false
jobs:
publish:
runs-on: alkane-pages
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Install SSH client
run: |
apt-get update -qq
apt-get install -y -qq --no-install-recommends openssh-client
- name: Render measured benchmark history
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: python3 ci/bench_history.py render
- name: Publish public benchmark page
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
BENCH_PAGES_DEPLOY_KEY: ${{ secrets.BENCH_PAGES_DEPLOY_KEY }}
run: python3 ci/publish-bench-pages.py toolkit
- name: Clean generated page
if: always()
run: python3 ci/cleanup-generated.py
+1 -7
View File
@@ -49,7 +49,7 @@ jobs:
run: | run: |
apt-get update -qq apt-get update -qq
apt-get install -y -qq --no-install-recommends \ apt-get install -y -qq --no-install-recommends \
libssl-dev pkg-config ca-certificates openssh-client >/dev/null libssl-dev pkg-config ca-certificates >/dev/null
echo "libssl-dev + pkg-config installed (openssl-sys needs them)" echo "libssl-dev + pkg-config installed (openssl-sys needs them)"
- name: Cache vendored wxWidgets build - name: Cache vendored wxWidgets build
@@ -112,12 +112,6 @@ jobs:
with: with:
name: alkane-toolkit-benchmark-site-preview name: alkane-toolkit-benchmark-site-preview
path: bench-site/index.html path: bench-site/index.html
- name: Publish public benchmark page
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
BENCH_PAGES_DEPLOY_KEY: ${{ secrets.BENCH_PAGES_DEPLOY_KEY }}
run: python3 ci/publish-bench-pages.py toolkit
- name: Headless UI self-test - name: Headless UI self-test
run: | run: |
apt-get update -qq && apt-get install -y -qq --no-install-recommends \ apt-get update -qq && apt-get install -y -qq --no-install-recommends \
+21 -33
View File
@@ -10,9 +10,9 @@
![dependencies](https://gitea.bluefla.re/blueflare/alkane-toolkit/raw/branch/ci-badges/badges/dependencies.svg) ![dependencies](https://gitea.bluefla.re/blueflare/alkane-toolkit/raw/branch/ci-badges/badges/dependencies.svg)
![license](https://gitea.bluefla.re/blueflare/alkane-toolkit/raw/branch/ci-badges/badges/license.svg) ![license](https://gitea.bluefla.re/blueflare/alkane-toolkit/raw/branch/ci-badges/badges/license.svg)
Desktop fleet discovery and monitoring for ASIC miners. The Rust GUI uses Desktop miner discovery and monitoring. The Rust GUI uses wxWidgets through
wxWidgets through a patched [wx-rs bridge](thirdparty/wx-rs). Firmware a patched [wx-rs bridge](thirdparty/wx-rs). Firmware installation is under
installation is under development. development.
## Run locally ## Run locally
@@ -22,50 +22,38 @@ scripts/build-gui-linux.sh
ALKANE_FAKE_SCAN=1 ~/.cache/alkane-tk-target/release/alkane-toolkit ALKANE_FAKE_SCAN=1 ~/.cache/alkane-tk-target/release/alkane-toolkit
``` ```
The first command builds wxWidgets 3.3.3 once. Linux runtime needs GTK 3 The first command builds wxWidgets 3.3.3 once. Linux needs GTK 3. Fake scan
(`libgtk-3-0` on Debian/Ubuntu). The fake scan uses offline fixtures and uses offline fixtures and does not contact hardware. For Windows and macOS,
does not contact hardware. Windows and macOS use their respective use the matching `scripts/build-gui-*.sh` script.
`scripts/build-gui-*.sh` scripts and platform toolchains.
## Current scope ## Current scope
- Discover miners by CIDR or IP range with vendored - Discover miners by CIDR or IP range with vendored [asic-rs](vendor/asic-rs).
[asic-rs](vendor/asic-rs), and show model, firmware, health, hashrate, - Show model, firmware, health, hashrate, temperatures, fans, PSU, and workers.
temperatures, fans, PSU, and pool workers. - Filter and sort the desktop table; inspect probes with `miner_probe`.
- 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.
The installer and some operator actions remain roadmap items; see the Discovery is read-only. The installer and operator actions remain in the
[implementation plan](docs/IMPLEMENTATION-PLAN.md) and [implementation plan](docs/IMPLEMENTATION-PLAN.md) and
[firmware parity matrix](docs/aftermarket-parity-roadmap.md). A listed [firmware matrix](docs/aftermarket-parity-roadmap.md).
firmware or board is not an install claim. Discovery is read-only.
## Development ## Development
```sh ```sh
export WX_RS_WXCONFIG="$HOME/.cache/wx-3.3.3-linux/bin/wx-config" WX_RS_WXCONFIG="$HOME/.cache/wx-3.3.3-linux/bin/wx-config" \
export CARGO_TARGET_DIR="$HOME/.cache/alkane-tk-target" CARGO_TARGET_DIR="$HOME/.cache/alkane-tk-target" \
cargo test -p alkane-gui --offline 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
``` ```
Keep build output off the source share. `main` runs the full CI gate and Keep build output off the source share. `main` runs full CI and publishes
publishes qualifying releases; `next` builds `-rc` candidates. Badges qualifying releases; `next` builds `-rc` candidates. Badges measure host
report host tests and benchmarks, not installation support. Benchmark code, not installation support. See the public
comparisons require the same CPU class. The code quality letter reports the [benchmark history](https://blueflare.gitea.bluefla.re/alkane-benchmarks/toolkit/).
Clippy gate; the separate coverage badge reports exercised lines.
The [benchmark history](https://blueflare.gitea.bluefla.re/alkane-benchmarks/toolkit/)
is readable without a Gitea login.
## Firmware safety ## Firmware safety
The [SDK install rules](https://gitea.bluefla.re/blueflare/alkane-sdk/src/branch/main/docs/install-methods.md) require Installation must follow the [SDK install rules](https://gitea.bluefla.re/blueflare/alkane-sdk/src/branch/main/docs/install-methods.md):
serial and recovery checks for risky writes. Installation must never write use the exact board's packer and boot-switch procedure, verify through an
the bootloader or secure region, must verify over an independent channel, independent channel, and never write bootloader or secure regions.
and must use the packer and boot-switch procedure for the exact board.
## License ## License
+8 -1
View File
@@ -126,7 +126,7 @@ def render_html(index: dict) -> str:
def main() -> None: def main() -> None:
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("action", choices=("prepare", "publish")) parser.add_argument("action", choices=("prepare", "publish", "render"))
args = parser.parse_args() args = parser.parse_args()
api = os.environ["GITHUB_API_URL"].rstrip("/") api = os.environ["GITHUB_API_URL"].rstrip("/")
repo = os.environ["GITHUB_REPOSITORY"] repo = os.environ["GITHUB_REPOSITORY"]
@@ -141,6 +141,13 @@ def main() -> None:
Path("badges/bench-baseline.json").write_text(json.dumps(baseline) + "\n") Path("badges/bench-baseline.json").write_text(json.dumps(baseline) + "\n")
print(f"Loaded {len(baseline)} prior benchmark measurements") print(f"Loaded {len(baseline)} prior benchmark measurements")
return return
if args.action == "render":
if not index["entries"]:
raise ValueError("no measured benchmark history to publish")
Path("bench-site").mkdir(exist_ok=True)
Path("bench-site/index.html").write_text(render_html(index))
print(f"Rendered {len(index['entries'])} measured benchmark commits")
return
metrics = {"bench_ns_per_op": bench_badge.require_suite(bench_badge.parse_bench( metrics = {"bench_ns_per_op": bench_badge.require_suite(bench_badge.parse_bench(
Path("bench-current.txt").read_text())), "bench_host": benchmark_host()} Path("bench-current.txt").read_text())), "bench_host": benchmark_host()}
timestamp = datetime.now(timezone.utc).isoformat(timespec="seconds") timestamp = datetime.now(timezone.utc).isoformat(timespec="seconds")
+1 -1
View File
@@ -9,7 +9,7 @@ import sys
ROOT = Path(__file__).resolve().parents[1] ROOT = Path(__file__).resolve().parents[1]
DIRECTORIES = ("target", "dist", "coverage") DIRECTORIES = ("target", "dist", "coverage", "bench-site")
FILES = ("bench-current.txt",) FILES = ("bench-current.txt",)
+3 -3
View File
@@ -16,6 +16,7 @@ GUARD_REPO = "https://gitea.bluefla.re/blueflare/alkane-benchmarks.git"
GUARD_COMMIT = "ea160545c49bc419a245692deda8dd7db7a611eb" GUARD_COMMIT = "ea160545c49bc419a245692deda8dd7db7a611eb"
PAGES_HOST = "gitea.bluefla.re" PAGES_HOST = "gitea.bluefla.re"
PAGES_HOST_FINGERPRINT = "SHA256:lqB5cmC9E5HNeg/lkzdOwQ++I8A70Wx7lnNs6liN24g" PAGES_HOST_FINGERPRINT = "SHA256:lqB5cmC9E5HNeg/lkzdOwQ++I8A70Wx7lnNs6liN24g"
PAGES_HOST_KEY = "[gitea.bluefla.re]:2222 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO1II6NkmRW+QAd+Wj+7qbNrA8Oo+/N/WRog4hELskn/"
def run(*args: str, env: dict[str, str] | None = None, def run(*args: str, env: dict[str, str] | None = None,
@@ -62,16 +63,15 @@ def publish(site: str) -> None:
key_path = temporary / "deploy_key" key_path = temporary / "deploy_key"
key_path.write_text(key.rstrip("\n") + "\n") key_path.write_text(key.rstrip("\n") + "\n")
key_path.chmod(0o600) key_path.chmod(0o600)
scanned = run("ssh-keyscan", "-p", "2222", "-t", "ed25519", PAGES_HOST)
known_hosts = temporary / "known_hosts" known_hosts = temporary / "known_hosts"
known_hosts.write_text(scanned.stdout) known_hosts.write_text(PAGES_HOST_KEY + "\n")
fingerprint = run("ssh-keygen", "-lf", str(known_hosts)).stdout.split()[1] fingerprint = run("ssh-keygen", "-lf", str(known_hosts)).stdout.split()[1]
if fingerprint != PAGES_HOST_FINGERPRINT: if fingerprint != PAGES_HOST_FINGERPRINT:
raise ValueError("benchmark Pages SSH host key changed") raise ValueError("benchmark Pages SSH host key changed")
git_env = os.environ.copy() git_env = os.environ.copy()
ssh_command = (f"ssh -i {shlex.quote(str(key_path))} -o IdentitiesOnly=yes " ssh_command = (f"ssh -i {shlex.quote(str(key_path))} -o IdentitiesOnly=yes "
f"-o UserKnownHostsFile={shlex.quote(str(known_hosts))} " f"-o UserKnownHostsFile={shlex.quote(str(known_hosts))} "
"-o StrictHostKeyChecking=yes") "-o StrictHostKeyChecking=yes -o ConnectTimeout=10")
git_env["GIT_SSH_COMMAND"] = ssh_command git_env["GIT_SSH_COMMAND"] = ssh_command
git_env["GIT_TERMINAL_PROMPT"] = "0" git_env["GIT_TERMINAL_PROMPT"] = "0"
checkout = temporary / "site" checkout = temporary / "site"
+219 -1
View File
@@ -1 +1,219 @@
// alkane-access // SPDX-License-Identifier: MIT
//! Bounded, read-only SSH probes for board identification.
use std::fs;
use std::io::{self, Read};
use std::net::IpAddr;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::thread;
use std::time::{Duration, Instant};
const MAX_PROBE_BYTES: usize = 64 * 1024;
const PROBE_TIMEOUT: Duration = Duration::from_secs(12);
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Probe {
KernelRelease,
MtdTable,
DeviceTreeModel,
}
impl Probe {
fn command(self) -> &'static str {
match self {
Self::KernelRelease => "uname -r",
Self::MtdTable => "cat /proc/mtd",
Self::DeviceTreeModel => "cat /proc/device-tree/model",
}
}
}
#[derive(Debug)]
pub enum AccessError {
InvalidTarget,
InvalidKnownHosts,
Timeout,
OutputTooLarge,
RemoteFailure,
Io(io::Error),
}
impl From<io::Error> for AccessError {
fn from(error: io::Error) -> Self {
Self::Io(error)
}
}
pub struct SshTarget {
address: IpAddr,
port: u16,
user: String,
known_hosts: PathBuf,
}
impl SshTarget {
pub fn new(
address: IpAddr,
port: u16,
user: &str,
known_hosts: &Path,
) -> Result<Self, AccessError> {
if port == 0
|| user.is_empty()
|| !user
.bytes()
.all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-' | b'.'))
{
return Err(AccessError::InvalidTarget);
}
if !known_hosts.is_absolute()
|| !fs::metadata(known_hosts).is_ok_and(|metadata| metadata.is_file())
{
return Err(AccessError::InvalidKnownHosts);
}
Ok(Self {
address,
port,
user: user.to_owned(),
known_hosts: known_hosts.to_owned(),
})
}
fn command(&self, probe: Probe) -> Command {
let mut command = Command::new("ssh");
command
.arg("-F")
.arg("none")
.arg("-o")
.arg("BatchMode=yes")
.arg("-o")
.arg("StrictHostKeyChecking=yes")
.arg("-o")
.arg("GlobalKnownHostsFile=none")
.arg("-o")
.arg(format!("UserKnownHostsFile={}", self.known_hosts.display()))
.arg("-o")
.arg("ConnectTimeout=5")
.arg("-o")
.arg("ServerAliveInterval=5")
.arg("-o")
.arg("ServerAliveCountMax=1")
.arg("-o")
.arg("RequestTTY=no")
.arg("-p")
.arg(self.port.to_string())
.arg(format!("{}@{}", self.user, self.address))
.arg(probe.command());
command
}
pub fn probe(&self, probe: Probe) -> Result<Vec<u8>, AccessError> {
run_bounded(self.command(probe))
}
}
fn collect_bounded<R: Read + Send + 'static>(
mut reader: R,
) -> thread::JoinHandle<Result<Vec<u8>, AccessError>> {
thread::spawn(move || {
let mut data = Vec::new();
let mut chunk = [0_u8; 4096];
loop {
let count = reader.read(&mut chunk)?;
if count == 0 {
return Ok(data);
}
if data.len() + count > MAX_PROBE_BYTES {
return Err(AccessError::OutputTooLarge);
}
data.extend_from_slice(&chunk[..count]);
}
})
}
fn run_bounded(command: Command) -> Result<Vec<u8>, AccessError> {
run_bounded_with_timeout(command, PROBE_TIMEOUT)
}
fn run_bounded_with_timeout(
mut command: Command,
timeout: Duration,
) -> Result<Vec<u8>, AccessError> {
command
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let mut child = command.spawn()?;
let stdout = collect_bounded(child.stdout.take().expect("piped stdout"));
let stderr = collect_bounded(child.stderr.take().expect("piped stderr"));
let deadline = Instant::now() + timeout;
let result = loop {
if let Some(status) = child.try_wait()? {
break status.success();
}
if Instant::now() >= deadline {
let _ = child.kill();
let _ = child.wait();
let _ = stdout.join();
let _ = stderr.join();
return Err(AccessError::Timeout);
}
thread::sleep(Duration::from_millis(10));
};
let output = stdout.join().map_err(|_| AccessError::RemoteFailure)??;
let error_output = stderr.join().map_err(|_| AccessError::RemoteFailure)??;
if !result || !error_output.is_empty() {
return Err(AccessError::RemoteFailure);
}
Ok(output)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn target_rejects_injected_user_and_unknown_host_file() {
let address = "127.0.0.1".parse().unwrap();
assert!(matches!(
SshTarget::new(
address,
22,
"root;id",
Path::new("/etc/ssh/ssh_known_hosts")
),
Err(AccessError::InvalidTarget)
));
assert!(matches!(
SshTarget::new(address, 22, "root", Path::new("relative-known-hosts")),
Err(AccessError::InvalidKnownHosts)
));
}
#[cfg(unix)]
#[test]
fn bounded_runner_rejects_excess_output_and_failed_command() {
let mut success = Command::new("/bin/sh");
success.args(["-c", "printf board"]);
assert_eq!(run_bounded(success).unwrap(), b"board");
let mut overflow = Command::new("/bin/sh");
overflow.args(["-c", "head -c 70000 /dev/zero"]);
assert!(matches!(
run_bounded(overflow),
Err(AccessError::OutputTooLarge)
));
let mut failed = Command::new("/bin/sh");
failed.args(["-c", "exit 7"]);
assert!(matches!(
run_bounded(failed),
Err(AccessError::RemoteFailure)
));
let mut hanging = Command::new("/bin/sleep");
hanging.arg("1");
assert!(matches!(
run_bounded_with_timeout(hanging, Duration::from_millis(20)),
Err(AccessError::Timeout)
));
}
}