Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1da1b88201 | ||
|
|
d9dc60918c | ||
|
|
bb31a7befc | ||
|
|
b1b7a3dbc0 | ||
|
|
8275f893dd | ||
|
|
36f12d6d4e | ||
|
|
a4d82bf45b | ||
|
|
d925414bc8 | ||
|
|
9f9fe18926 | ||
|
|
d8d044f439 | ||
|
|
517bee9b9e | ||
|
|
10d7fd6d95 | ||
|
|
9b440a46e3 | ||
|
|
c3b0dc6c8a | ||
|
|
bfda29a845 | ||
|
|
2c58cbac48 | ||
|
|
174b162dfd |
@@ -1,35 +0,0 @@
|
|||||||
name: public-benchmark-pages
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_run:
|
|
||||||
workflows: [build-test-release]
|
|
||||||
types: [completed]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: alkane-toolkit-public-benchmark-pages
|
|
||||||
cancel-in-progress: false
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: alkane-verify
|
|
||||||
container:
|
|
||||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Install SSH client
|
|
||||||
run: bash ci/ensure-build-deps.sh ssh
|
|
||||||
- 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
|
|
||||||
@@ -9,7 +9,7 @@ jobs:
|
|||||||
publish:
|
publish:
|
||||||
runs-on: alkane-verify
|
runs-on: alkane-verify
|
||||||
container:
|
container:
|
||||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041
|
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||||
permissions:
|
permissions:
|
||||||
actions: read
|
actions: read
|
||||||
contents: write
|
contents: write
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ jobs:
|
|||||||
windows:
|
windows:
|
||||||
runs-on: alkane-ci
|
runs-on: alkane-ci
|
||||||
container:
|
container:
|
||||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041
|
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||||
env:
|
env:
|
||||||
CARGO_TARGET_DIR: target
|
CARGO_TARGET_DIR: target
|
||||||
CARGO_BUILD_JOBS: 2
|
CARGO_BUILD_JOBS: 2
|
||||||
@@ -64,6 +64,14 @@ jobs:
|
|||||||
- name: Build Windows candidate
|
- name: Build Windows candidate
|
||||||
if: steps.version.outputs.release == 'true'
|
if: steps.version.outputs.release == 'true'
|
||||||
run: bash ci/windows-ci.sh build
|
run: bash ci/windows-ci.sh build
|
||||||
|
- name: Sign Windows candidate (Azure Artifact Signing)
|
||||||
|
if: steps.version.outputs.release == 'true'
|
||||||
|
env:
|
||||||
|
AZURE_SIGNING_PROFILE: ${{ vars.AZURE_SIGNING_PROFILE }}
|
||||||
|
AZURE_SIGNING_TENANT_ID: ${{ secrets.AZURE_SIGNING_TENANT_ID }}
|
||||||
|
AZURE_SIGNING_CLIENT_ID: ${{ secrets.AZURE_SIGNING_CLIENT_ID }}
|
||||||
|
AZURE_SIGNING_CLIENT_SECRET: ${{ secrets.AZURE_SIGNING_CLIENT_SECRET }}
|
||||||
|
run: bash ci/windows-ci.sh sign
|
||||||
- name: Package Windows candidate
|
- name: Package Windows candidate
|
||||||
if: steps.version.outputs.release == 'true'
|
if: steps.version.outputs.release == 'true'
|
||||||
run: bash ci/windows-ci.sh package "${{ steps.version.outputs.version }}"
|
run: bash ci/windows-ci.sh package "${{ steps.version.outputs.version }}"
|
||||||
@@ -80,7 +88,7 @@ jobs:
|
|||||||
needs: windows
|
needs: windows
|
||||||
runs-on: alkane-ci
|
runs-on: alkane-ci
|
||||||
container:
|
container:
|
||||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041
|
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||||
env:
|
env:
|
||||||
CARGO_TARGET_DIR: target
|
CARGO_TARGET_DIR: target
|
||||||
CARGO_BUILD_JOBS: 2
|
CARGO_BUILD_JOBS: 2
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
name: pages
|
||||||
|
|
||||||
|
# The project site, https://blueflare.gitea.bluefla.re/alkane-toolkit/ :
|
||||||
|
# overview, user manual (docs/manual), code-quality dashboard (from the
|
||||||
|
# quality record main CI publishes with the badges) and benchmark history.
|
||||||
|
# Rebuilt after every main build-test-release run and published to this
|
||||||
|
# repository's gh-pages branch.
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: [build-test-release]
|
||||||
|
types: [completed]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: alkane-toolkit-pages
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: alkane-verify
|
||||||
|
container:
|
||||||
|
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install page tools
|
||||||
|
run: bash ci/ensure-build-deps.sh pages
|
||||||
|
- name: Render measured benchmark history
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
run: python3 ci/bench_history.py render
|
||||||
|
- name: Fetch measured quality record
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
run: python3 ci/fetch-quality.py quality.json
|
||||||
|
- name: Build site
|
||||||
|
run: |
|
||||||
|
python3 ci/build-pages.py --out site --quality quality.json \
|
||||||
|
--bench bench-site/index.html --sha "$GITHUB_SHA"
|
||||||
|
- name: Publish site
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
run: python3 ci/publish-pages.py site
|
||||||
|
- name: Clean generated site
|
||||||
|
if: always()
|
||||||
|
run: python3 ci/cleanup-generated.py
|
||||||
@@ -23,7 +23,7 @@ jobs:
|
|||||||
windows:
|
windows:
|
||||||
runs-on: alkane-ci
|
runs-on: alkane-ci
|
||||||
container:
|
container:
|
||||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041
|
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||||
env:
|
env:
|
||||||
CARGO_TARGET_DIR: target
|
CARGO_TARGET_DIR: target
|
||||||
CARGO_BUILD_JOBS: 2
|
CARGO_BUILD_JOBS: 2
|
||||||
@@ -91,6 +91,14 @@ jobs:
|
|||||||
- name: Headless UI self-test (Windows build, under Wine)
|
- name: Headless UI self-test (Windows build, under Wine)
|
||||||
run: bash ci/windows-ci.sh selftest
|
run: bash ci/windows-ci.sh selftest
|
||||||
|
|
||||||
|
- name: Sign Windows executable (Azure Artifact Signing)
|
||||||
|
env:
|
||||||
|
AZURE_SIGNING_PROFILE: ${{ vars.AZURE_SIGNING_PROFILE }}
|
||||||
|
AZURE_SIGNING_TENANT_ID: ${{ secrets.AZURE_SIGNING_TENANT_ID }}
|
||||||
|
AZURE_SIGNING_CLIENT_ID: ${{ secrets.AZURE_SIGNING_CLIENT_ID }}
|
||||||
|
AZURE_SIGNING_CLIENT_SECRET: ${{ secrets.AZURE_SIGNING_CLIENT_SECRET }}
|
||||||
|
run: bash ci/windows-ci.sh sign
|
||||||
|
|
||||||
- name: Package Windows artifact
|
- name: Package Windows artifact
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
run: bash ci/windows-ci.sh package "${{ steps.ver.outputs.version }}"
|
run: bash ci/windows-ci.sh package "${{ steps.ver.outputs.version }}"
|
||||||
@@ -120,7 +128,7 @@ jobs:
|
|||||||
needs: windows
|
needs: windows
|
||||||
runs-on: alkane-ci
|
runs-on: alkane-ci
|
||||||
container:
|
container:
|
||||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041
|
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||||
env:
|
env:
|
||||||
CARGO_TARGET_DIR: target
|
CARGO_TARGET_DIR: target
|
||||||
CARGO_BUILD_JOBS: 2
|
CARGO_BUILD_JOBS: 2
|
||||||
@@ -263,8 +271,10 @@ jobs:
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
rustup component add llvm-tools-preview >/dev/null 2>&1 || true
|
rustup component add llvm-tools-preview >/dev/null 2>&1 || true
|
||||||
[ "$(cargo llvm-cov --version)" = 'cargo-llvm-cov 0.8.7' ]
|
[ "$(cargo llvm-cov --version)" = 'cargo-llvm-cov 0.8.7' ]
|
||||||
PCT=$(bash ci/coverage.sh --summary-only \
|
# Keep the whole table: gen-badges turns it into the per-crate and
|
||||||
| awk '/^TOTAL/{gsub(/%/,"",$10); print $10}')
|
# per-file breakdown on the Pages quality dashboard.
|
||||||
|
bash ci/coverage.sh --summary-only | tee coverage-summary.txt
|
||||||
|
PCT=$(awk '/^TOTAL/{gsub(/%/,"",$10); print $10}' coverage-summary.txt)
|
||||||
[ -n "$PCT" ] || { echo "coverage report produced no TOTAL line" >&2; exit 1; }
|
[ -n "$PCT" ] || { echo "coverage report produced no TOTAL line" >&2; exit 1; }
|
||||||
echo "pct=${PCT}" >> "$GITHUB_OUTPUT"
|
echo "pct=${PCT}" >> "$GITHUB_OUTPUT"
|
||||||
echo "line coverage (tests + self-test): ${PCT}%"
|
echo "line coverage (tests + self-test): ${PCT}%"
|
||||||
@@ -292,7 +302,8 @@ jobs:
|
|||||||
python3 ci/gen-badges.py --tests "$PASS" \
|
python3 ci/gen-badges.py --tests "$PASS" \
|
||||||
--coverage "${{ steps.cov.outputs.pct }}" \
|
--coverage "${{ steps.cov.outputs.pct }}" \
|
||||||
--bench-coverage "${{ steps.benchcov.outputs.pct }}" \
|
--bench-coverage "${{ steps.benchcov.outputs.pct }}" \
|
||||||
--bench-delta "$BENCH_DELTA" --clippy clean
|
--bench-delta "$BENCH_DELTA" --clippy clean \
|
||||||
|
--coverage-summary coverage-summary.txt
|
||||||
|
|
||||||
- name: Publish measured badges
|
- name: Publish measured badges
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ jobs:
|
|||||||
check:
|
check:
|
||||||
runs-on: alkane-fast
|
runs-on: alkane-fast
|
||||||
container:
|
container:
|
||||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041
|
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||||
env:
|
env:
|
||||||
CARGO_BUILD_JOBS: 2
|
CARGO_BUILD_JOBS: 2
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ jobs:
|
|||||||
verify:
|
verify:
|
||||||
runs-on: alkane-verify
|
runs-on: alkane-verify
|
||||||
container:
|
container:
|
||||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041
|
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||||
outputs:
|
outputs:
|
||||||
surface: ${{ steps.surface.outputs.surface }}
|
surface: ${{ steps.surface.outputs.surface }}
|
||||||
env:
|
env:
|
||||||
@@ -203,7 +203,7 @@ jobs:
|
|||||||
if: needs.verify.outputs.surface == 'full'
|
if: needs.verify.outputs.surface == 'full'
|
||||||
runs-on: alkane-verify
|
runs-on: alkane-verify
|
||||||
container:
|
container:
|
||||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041
|
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||||
env:
|
env:
|
||||||
CARGO_TARGET_DIR: target
|
CARGO_TARGET_DIR: target
|
||||||
CARGO_BUILD_JOBS: 2
|
CARGO_BUILD_JOBS: 2
|
||||||
|
|||||||
@@ -63,6 +63,18 @@ jobs:
|
|||||||
$os = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
|
$os = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
|
||||||
"Testing run $env:RUN_ID on Windows $($os.DisplayVersion) build $($os.CurrentBuild)"
|
"Testing run $env:RUN_ID on Windows $($os.DisplayVersion) build $($os.CurrentBuild)"
|
||||||
|
|
||||||
|
- name: Authenticode signature (native Windows)
|
||||||
|
env:
|
||||||
|
SIGNING_ENABLED: ${{ vars.AZURE_SIGNING_PROFILE }}
|
||||||
|
run: |
|
||||||
|
# Windows itself judges the signature: chain to a trusted root,
|
||||||
|
# intact file hash, valid timestamp. Required once signing is on.
|
||||||
|
$sig = Get-AuthenticodeSignature "$env:ALKANE_NATIVE\alkane-toolkit.exe"
|
||||||
|
Write-Host "Signature: $($sig.Status) $($sig.StatusMessage)"
|
||||||
|
if ($sig.SignerCertificate) { Write-Host "Signer: $($sig.SignerCertificate.Subject)" }
|
||||||
|
if ($sig.TimeStamperCertificate) { Write-Host "Timestamp: $($sig.TimeStamperCertificate.Subject)" }
|
||||||
|
if ($env:SIGNING_ENABLED -and $sig.Status -ne 'Valid') { exit 1 }
|
||||||
|
|
||||||
- name: Unit tests (native Windows)
|
- name: Unit tests (native Windows)
|
||||||
run: |
|
run: |
|
||||||
$failed = @()
|
$failed = @()
|
||||||
|
|||||||
@@ -2,3 +2,8 @@
|
|||||||
**/target
|
**/target
|
||||||
.claude/
|
.claude/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
# Internal working notes live outside this public repository.
|
||||||
|
/AGENTS.md
|
||||||
|
/HANDOFF.md
|
||||||
|
/CLAUDE.md
|
||||||
|
code-review-report*.md
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2026 Blueflare
|
Copyright (c) 2026 BlueFlare Energy Solutions Inc.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
# Alkane Toolkit
|
# Alkane Toolkit
|
||||||
|
|
||||||
[](https://gitea.bluefla.re/blueflare/alkane-toolkit/actions)
|
[](https://gitea.bluefla.re/blueflare/alkane-toolkit/actions)
|
||||||

|
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/)
|
||||||

|
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/#coverage)
|
||||||

|
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/bench/)
|
||||||

|
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/)
|
||||||

|
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/#coverage)
|
||||||

|
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/)
|
||||||

|
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/)
|
||||||

|
[](LICENSE)
|
||||||
|
|
||||||
The code quality grade reports GUI Clippy and first-party Rust formatting checks
|
The badges link to the [project site](https://blueflare.gitea.bluefla.re/alkane-toolkit/): the [manual](https://blueflare.gitea.bluefla.re/alkane-toolkit/manual/),
|
||||||
from the last successful main build. Test coverage has a separate badge.
|
the [code-quality dashboard](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/) (how the grade is set, coverage by
|
||||||
|
crate and file) and the [benchmark history](https://blueflare.gitea.bluefla.re/alkane-toolkit/bench/).
|
||||||
|
|
||||||
Desktop miner discovery and monitoring. The Rust GUI uses wxWidgets through
|
Desktop miner discovery and monitoring. The Rust GUI uses wxWidgets through
|
||||||
a patched [wx-rs bridge](thirdparty/wx-rs). In-app image flashing is disabled
|
a patched [wx-rs bridge](thirdparty/wx-rs). In-app image flashing is disabled
|
||||||
@@ -31,7 +32,9 @@ uses offline fixtures and does not contact hardware.
|
|||||||
Windows 10/11 builds are cross-compiled on Linux (`scripts/build-wx-windows.sh`,
|
Windows 10/11 builds are cross-compiled on Linux (`scripts/build-wx-windows.sh`,
|
||||||
then `scripts/build-gui-windows.sh`) and attached to every release as a
|
then `scripts/build-gui-windows.sh`) and attached to every release as a
|
||||||
self-contained `alkane-toolkit.exe`; see [docs/windows.md](docs/windows.md).
|
self-contained `alkane-toolkit.exe`; see [docs/windows.md](docs/windows.md).
|
||||||
macOS is not built.
|
macOS builds run on a Mac (`scripts/build-wx-macos.sh`, then
|
||||||
|
`scripts/build-gui-macos.sh`) and produce one universal app for Apple Silicon
|
||||||
|
and Intel, macOS 11 or later; see [docs/macos.md](docs/macos.md).
|
||||||
|
|
||||||
## Current scope
|
## Current scope
|
||||||
|
|
||||||
@@ -42,8 +45,7 @@ macOS is not built.
|
|||||||
aftermarket firmware to stock.
|
aftermarket firmware to stock.
|
||||||
|
|
||||||
Discovery is read-only. Control and restore actions change miners. Check the
|
Discovery is read-only. Control and restore actions change miners. Check the
|
||||||
selected devices before applying them. See the [implementation plan](docs/IMPLEMENTATION-PLAN.md)
|
selected devices before applying them.
|
||||||
and [firmware matrix](docs/aftermarket-parity-roadmap.md) for planned coverage.
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
@@ -55,8 +57,8 @@ WX_RS_WXCONFIG="$HOME/.cache/wx-3.3.3-linux/bin/wx-config" \
|
|||||||
|
|
||||||
Keep build output off the source share. `main` runs full CI and publishes
|
Keep build output off the source share. `main` runs full CI and publishes
|
||||||
qualifying releases; `next` builds `-rc` candidates. Badges measure host
|
qualifying releases; `next` builds `-rc` candidates. Badges measure host
|
||||||
code, not installation support. See the public
|
code, not installation support. See the
|
||||||
[benchmark history](https://blueflare.gitea.bluefla.re/alkane-benchmarks/toolkit/).
|
[benchmark history](https://blueflare.gitea.bluefla.re/alkane-toolkit/bench/).
|
||||||
|
|
||||||
## Firmware safety
|
## Firmware safety
|
||||||
|
|
||||||
|
|||||||
Executable
+293
@@ -0,0 +1,293 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
"""Build the Alkane Toolkit Pages site (served from this repo's gh-pages).
|
||||||
|
|
||||||
|
build-pages.py --out site [--manual docs/manual] [--quality quality.json]
|
||||||
|
[--bench bench-site/index.html] [--sha SHA]
|
||||||
|
|
||||||
|
Pages:
|
||||||
|
/ overview and downloads
|
||||||
|
/manual/ the user manual, one page per docs/manual/NN-name.md chapter
|
||||||
|
/quality/ code-quality dashboard from the measured quality.json that main
|
||||||
|
CI publishes next to the badges (ci/gen-badges.py)
|
||||||
|
/bench/ the measured benchmark history (ci/bench_history.py render)
|
||||||
|
|
||||||
|
Every value taken from CI data is HTML-escaped; the manual is Markdown written
|
||||||
|
in this repository.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import html
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import markdown
|
||||||
|
|
||||||
|
REPO = "https://gitea.bluefla.re/blueflare/alkane-toolkit"
|
||||||
|
RELEASES = REPO + "/releases"
|
||||||
|
SECTIONS = (("", "Overview"), ("manual/", "Manual"), ("quality/", "Code quality"),
|
||||||
|
("bench/", "Benchmarks"))
|
||||||
|
|
||||||
|
CSS = """
|
||||||
|
:root { --bg:#ffffff; --fg:#1f2328; --muted:#59636e; --line:#d1d9e0; --card:#f6f8fa;
|
||||||
|
--accent:#d9822b; --link:#0969da; --good:#1a7f37; --warn:#9a6700; --bad:#cf222e; }
|
||||||
|
@media (prefers-color-scheme: dark) { :root { --bg:#0d1117; --fg:#e6edf3; --muted:#9198a1;
|
||||||
|
--line:#30363d; --card:#151b23; --link:#4493f8; --good:#3fb950; --warn:#d29922; --bad:#f85149; } }
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
body { margin:0; background:var(--bg); color:var(--fg);
|
||||||
|
font:16px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,Ubuntu,sans-serif; }
|
||||||
|
a { color:var(--link); text-decoration:none; } a:hover { text-decoration:underline; }
|
||||||
|
header { border-bottom:1px solid var(--line); }
|
||||||
|
header .bar, main { max-width:1040px; margin:0 auto; padding:0 16px; }
|
||||||
|
header .bar { display:flex; align-items:center; gap:24px; height:56px; flex-wrap:wrap; }
|
||||||
|
header .brand { font-weight:700; color:var(--fg); display:flex; gap:8px; align-items:center; }
|
||||||
|
header .brand i { width:20px; height:20px; border-radius:5px; background:var(--accent); display:inline-block; }
|
||||||
|
header nav { display:flex; gap:18px; flex-wrap:wrap; }
|
||||||
|
header nav a { color:var(--muted); } header nav a.on { color:var(--fg); font-weight:600; }
|
||||||
|
main { padding:28px 16px 64px; }
|
||||||
|
h1 { font-size:1.9rem; margin:.2em 0 .4em; } h2 { margin-top:1.8em; border-bottom:1px solid var(--line); padding-bottom:.25em; }
|
||||||
|
code { background:var(--card); border:1px solid var(--line); border-radius:5px; padding:.1em .35em; font-size:.92em; }
|
||||||
|
pre { background:var(--card); border:1px solid var(--line); border-radius:8px; padding:12px; overflow:auto; }
|
||||||
|
pre code { border:0; padding:0; }
|
||||||
|
table { border-collapse:collapse; width:100%; margin:1em 0; display:block; overflow-x:auto; }
|
||||||
|
th, td { border:1px solid var(--line); padding:6px 10px; text-align:left; vertical-align:top; }
|
||||||
|
th { background:var(--card); }
|
||||||
|
td.num, th.num { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
|
||||||
|
.cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:12px; margin:1.2em 0; }
|
||||||
|
.card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:14px; }
|
||||||
|
.card b { display:block; font-size:1.6rem; } .card span { color:var(--muted); font-size:.9rem; }
|
||||||
|
.good { color:var(--good); } .warn { color:var(--warn); } .bad { color:var(--bad); }
|
||||||
|
.bar-cell { min-width:120px; } .meter { height:8px; background:var(--line); border-radius:4px; overflow:hidden; }
|
||||||
|
.meter i { display:block; height:100%; }
|
||||||
|
.layout { display:grid; grid-template-columns:220px 1fr; gap:32px; }
|
||||||
|
.layout aside ol { padding-left:1.2em; margin:0; } .layout aside li { margin:.3em 0; }
|
||||||
|
.layout aside a.on { font-weight:600; color:var(--fg); }
|
||||||
|
@media (max-width:760px) { .layout { grid-template-columns:1fr; } }
|
||||||
|
.buttons a { display:inline-block; margin:4px 8px 4px 0; padding:8px 14px; border-radius:8px;
|
||||||
|
border:1px solid var(--line); background:var(--card); color:var(--fg); }
|
||||||
|
.buttons a.primary { background:var(--accent); border-color:var(--accent); color:#fff; }
|
||||||
|
footer { color:var(--muted); font-size:.85rem; margin-top:48px; }
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def page(title: str, body: str, depth: int, current: str, sha: str) -> str:
|
||||||
|
up = "../" * depth
|
||||||
|
nav = "".join(
|
||||||
|
f'<a href="{up}{path}"{" class=on" if path == current else ""}>{label}</a>'
|
||||||
|
for path, label in SECTIONS)
|
||||||
|
built = f"Built from {html.escape(sha[:10])}. " if sha else ""
|
||||||
|
return f"""<!doctype html>
|
||||||
|
<html lang="en"><head><meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>{html.escape(title)} - Alkane Toolkit</title>
|
||||||
|
<link rel="stylesheet" href="{up}style.css"></head>
|
||||||
|
<body><header><div class="bar"><a class="brand" href="{up}"><i></i>Alkane Toolkit</a>
|
||||||
|
<nav>{nav}<a href="{RELEASES}">Downloads</a><a href="{REPO}">Source</a></nav></div></header>
|
||||||
|
<main>{body}
|
||||||
|
<footer>{built}Alkane Toolkit is MIT licensed.</footer></main></body></html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def write(out: Path, rel: str, text: str) -> None:
|
||||||
|
path = out / rel
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_text(text, encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
# ---- manual -----------------------------------------------------------------
|
||||||
|
|
||||||
|
def chapters(manual: Path) -> list[tuple[str, str, str]]:
|
||||||
|
"""(slug, title, markdown) for docs/manual/NN-slug.md, in file-name order."""
|
||||||
|
out = []
|
||||||
|
for path in sorted(manual.glob("[0-9][0-9]-*.md")):
|
||||||
|
text = path.read_text(encoding="utf-8")
|
||||||
|
m = re.search(r"^# (.+)$", text, re.M)
|
||||||
|
title = m.group(1).strip() if m else path.stem
|
||||||
|
out.append((path.stem[3:], title, text))
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def build_manual(out: Path, manual: Path, sha: str) -> None:
|
||||||
|
items = chapters(manual)
|
||||||
|
if not items:
|
||||||
|
raise SystemExit(f"no manual chapters in {manual}")
|
||||||
|
|
||||||
|
def toc(current: str) -> str:
|
||||||
|
links = "".join(
|
||||||
|
f'<li><a href="{slug}.html"{" class=on" if slug == current else ""}>'
|
||||||
|
f"{html.escape(title)}</a></li>" for slug, title, _ in items)
|
||||||
|
return f"<aside><ol>{links}</ol></aside>"
|
||||||
|
|
||||||
|
for slug, title, text in items:
|
||||||
|
# Chapters link to each other as NN-name.md in the repo; on the site
|
||||||
|
# they are name.html.
|
||||||
|
text = re.sub(r"\]\((?:\./)?[0-9][0-9]-([a-z0-9-]+)\.md(#[^)]*)?\)", r"](\1.html\2)", text)
|
||||||
|
body_html = markdown.markdown(text, extensions=["tables", "fenced_code", "toc"])
|
||||||
|
write(out, f"manual/{slug}.html",
|
||||||
|
page(title, f'<div class="layout">{toc(slug)}<article>{body_html}</article></div>',
|
||||||
|
1, "manual/", sha))
|
||||||
|
first = items[0][0]
|
||||||
|
listing = "".join(f'<li><a href="{s}.html">{html.escape(t)}</a></li>' for s, t, _ in items)
|
||||||
|
write(out, "manual/index.html",
|
||||||
|
page("Manual", f"<h1>Manual</h1><p>Start with "
|
||||||
|
f'<a href="{first}.html">{html.escape(items[0][1])}</a>.</p><ol>{listing}</ol>',
|
||||||
|
1, "manual/", sha))
|
||||||
|
|
||||||
|
|
||||||
|
# ---- quality dashboard ---------------------------------------------------------
|
||||||
|
|
||||||
|
def pct_class(pct: float | None) -> str:
|
||||||
|
if pct is None:
|
||||||
|
return ""
|
||||||
|
return "good" if pct >= 80 else "warn" if pct >= 40 else "bad"
|
||||||
|
|
||||||
|
|
||||||
|
def meter(pct: float) -> str:
|
||||||
|
colour = {"good": "var(--good)", "warn": "var(--warn)", "bad": "var(--bad)"}[pct_class(pct)]
|
||||||
|
return f'<div class="meter"><i style="width:{max(0.0, min(pct, 100.0)):.1f}%;background:{colour}"></i></div>'
|
||||||
|
|
||||||
|
|
||||||
|
def build_quality(out: Path, quality: dict | None, sha: str) -> None:
|
||||||
|
e = html.escape
|
||||||
|
if not quality:
|
||||||
|
write(out, "quality/index.html", page(
|
||||||
|
"Code quality", "<h1>Code quality</h1><p>No measurement has been published yet; "
|
||||||
|
"the next main build will fill this page.</p>", 1, "quality/", sha))
|
||||||
|
return
|
||||||
|
grade = str(quality.get("grade", "pending"))
|
||||||
|
cov = quality.get("coverage_pct")
|
||||||
|
bench_cov = quality.get("bench_coverage_pct")
|
||||||
|
delta = quality.get("bench_delta_pct")
|
||||||
|
|
||||||
|
def card(value: str, label: str, cls: str = "") -> str:
|
||||||
|
return f'<div class="card"><b class="{cls}">{value}</b><span>{label}</span></div>'
|
||||||
|
|
||||||
|
cards = "".join([
|
||||||
|
card(e(grade), "Quality grade", {"A": "good", "B": "good", "C": "warn"}.get(grade, "bad")),
|
||||||
|
card(e(str(quality.get("tests_passed", "-"))), "Tests passing", "good"),
|
||||||
|
card(f"{cov:.1f}%" if cov is not None else "-", "Line coverage", pct_class(cov)),
|
||||||
|
card(f"{bench_cov:.1f}%" if bench_cov is not None else "-", "Benchmark coverage", pct_class(bench_cov)),
|
||||||
|
card(e(str(quality.get("clippy") or "-")), "Clippy (warnings are errors)",
|
||||||
|
"good" if quality.get("clippy") == "clean" else "bad"),
|
||||||
|
card(e(str(quality.get("rustfmt") or "-")), "rustfmt", "good" if quality.get("rustfmt") == "clean" else ""),
|
||||||
|
card(f"{quality.get('loc', 0):,}", "Lines of Rust"),
|
||||||
|
card(e(str(quality.get("dependencies", "-"))), "Crates in Cargo.lock"),
|
||||||
|
card((f"{'+' if delta > 0 else ''}{delta:.1f}%" if delta is not None else "-"),
|
||||||
|
"Benchmarks vs previous" + (" (same inputs)" if quality.get("bench_same_inputs") else ""),
|
||||||
|
"" if delta is None else "good" if delta >= 2 else "" if delta > -2 else "warn"),
|
||||||
|
])
|
||||||
|
bands = ", ".join(f"{e(str(letter))} at {floor:.0f}% or more"
|
||||||
|
for floor, letter in quality.get("grade_bands", []))
|
||||||
|
grade_rule = (f"<p>The grade is F if Clippy or rustfmt fails on main. Otherwise it is the "
|
||||||
|
f"line-coverage band: {bands}, and F below that. The coverage badge uses the "
|
||||||
|
f"same bands for its colour, so the two never disagree.</p>")
|
||||||
|
|
||||||
|
crates = quality.get("coverage_by_crate", {})
|
||||||
|
loc = quality.get("loc_by_crate", {})
|
||||||
|
rows = []
|
||||||
|
for name in sorted(set(crates) | set(loc)):
|
||||||
|
c = crates.get(name)
|
||||||
|
if c and c["lines"]:
|
||||||
|
pct = 100.0 * (c["lines"] - c["missed"]) / c["lines"]
|
||||||
|
cov_cells = (f'<td class="num {pct_class(pct)}">{pct:.1f}%</td>'
|
||||||
|
f'<td class="bar-cell">{meter(pct)}</td>'
|
||||||
|
f'<td class="num">{c["lines"] - c["missed"]:,} / {c["lines"]:,}</td>')
|
||||||
|
else:
|
||||||
|
cov_cells = '<td class="num">-</td><td></td><td class="num">-</td>'
|
||||||
|
rows.append(f"<tr><td>{e(name)}</td>{cov_cells}<td class='num'>{loc.get(name, 0):,}</td></tr>")
|
||||||
|
crate_table = ("<table><tr><th>Crate</th><th class=num>Line coverage</th><th></th>"
|
||||||
|
"<th class=num>Covered lines</th><th class=num>Lines of Rust</th></tr>"
|
||||||
|
+ "".join(rows) + "</table>")
|
||||||
|
|
||||||
|
files = sorted(quality.get("coverage_by_file", []),
|
||||||
|
key=lambda r: (r["lines"] - r["missed"]) / r["lines"] if r["lines"] else 1)
|
||||||
|
file_rows = "".join(
|
||||||
|
f"<tr><td><code>{e(r['file'])}</code></td>"
|
||||||
|
f"<td class='num {pct_class(100.0 * (r['lines'] - r['missed']) / r['lines'])}'>"
|
||||||
|
f"{100.0 * (r['lines'] - r['missed']) / r['lines']:.1f}%</td>"
|
||||||
|
f"<td class='num'>{r['missed']:,}</td><td class='num'>{r['lines']:,}</td></tr>"
|
||||||
|
for r in files if r["lines"])
|
||||||
|
file_table = ("<table><tr><th>File (least covered first)</th><th class=num>Coverage</th>"
|
||||||
|
"<th class=num>Uncovered lines</th><th class=num>Lines</th></tr>"
|
||||||
|
+ file_rows + "</table>") if file_rows else ""
|
||||||
|
|
||||||
|
measured = str(quality.get("sha", ""))[:10]
|
||||||
|
of_build = f" (this page: <code>{e(measured)}</code>)" if measured else ""
|
||||||
|
body = f"""<h1>Code quality</h1>
|
||||||
|
<p>Measured by main CI on every build{of_build}:
|
||||||
|
unit tests, line coverage (unit tests plus the headless UI self-test), Clippy with
|
||||||
|
warnings as errors, and rustfmt. Windows builds run the same tests under Wine and
|
||||||
|
on real Windows 11.</p>
|
||||||
|
<div class="cards">{cards}</div>
|
||||||
|
<h2 id="grade">How the grade is set</h2>{grade_rule}
|
||||||
|
<h2 id="coverage">Coverage by crate</h2>{crate_table}
|
||||||
|
<h2 id="files">Coverage by file</h2>{file_table}
|
||||||
|
<p>The dependency count is every package in <code>Cargo.lock</code>, direct and
|
||||||
|
transitive. Lines of Rust count every <code>.rs</code> line under <code>crates/</code>,
|
||||||
|
tests included.</p>"""
|
||||||
|
write(out, "quality/index.html", page("Code quality", body, 1, "quality/", sha))
|
||||||
|
|
||||||
|
|
||||||
|
# ---- benchmarks + overview -------------------------------------------------------
|
||||||
|
|
||||||
|
def build_bench(out: Path, bench: Path | None, sha: str) -> None:
|
||||||
|
if bench is None or not bench.is_file():
|
||||||
|
write(out, "bench/index.html", page(
|
||||||
|
"Benchmarks", "<h1>Benchmarks</h1><p>No benchmark history yet.</p>", 1, "bench/", sha))
|
||||||
|
return
|
||||||
|
rendered = bench.read_text(encoding="utf-8")
|
||||||
|
# The history renderer emits a complete document; keep its body (and its
|
||||||
|
# own styles) under the site's header.
|
||||||
|
styles = "".join(re.findall(r"<style[^>]*>.*?</style>", rendered, re.S | re.I))
|
||||||
|
m = re.search(r"<body[^>]*>(.*)</body>", rendered, re.S | re.I)
|
||||||
|
inner = m.group(1) if m else rendered
|
||||||
|
text = page("Benchmarks", inner, 1, "bench/", sha)
|
||||||
|
write(out, "bench/index.html", text.replace("</head>", styles + "</head>", 1))
|
||||||
|
|
||||||
|
|
||||||
|
def build_index(out: Path, quality: dict | None, sha: str) -> None:
|
||||||
|
grade = html.escape(str((quality or {}).get("grade", "pending")))
|
||||||
|
body = f"""<h1>Alkane Toolkit</h1>
|
||||||
|
<p>Desktop discovery and monitoring for ASIC miners on your network: find every
|
||||||
|
miner in your IP ranges, see hashrate, power, temperatures, fans and hashboard
|
||||||
|
health at a glance, and run the controls each firmware supports.</p>
|
||||||
|
<div class="buttons"><a class="primary" href="{RELEASES}">Download for Windows or Linux</a>
|
||||||
|
<a href="manual/">Read the manual</a><a href="quality/">Code quality: {grade}</a>
|
||||||
|
<a href="bench/">Benchmarks</a></div>
|
||||||
|
<h2>Platforms</h2>
|
||||||
|
<ul><li><b>Windows 10 and 11</b> (x86_64): one signed, self-contained <code>alkane-toolkit.exe</code>.</li>
|
||||||
|
<li><b>Linux</b> (x86_64, GTK 3): one binary.</li></ul>
|
||||||
|
<p>Every release is built, tested and signed by CI from the public source.</p>"""
|
||||||
|
write(out, "index.html", page("Overview", body, 0, "", sha))
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
ap = argparse.ArgumentParser(description=__doc__,
|
||||||
|
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||||
|
ap.add_argument("--out", required=True)
|
||||||
|
ap.add_argument("--manual", default="docs/manual")
|
||||||
|
ap.add_argument("--quality", default=None)
|
||||||
|
ap.add_argument("--bench", default=None)
|
||||||
|
ap.add_argument("--sha", default="")
|
||||||
|
args = ap.parse_args()
|
||||||
|
out = Path(args.out)
|
||||||
|
if out.exists():
|
||||||
|
shutil.rmtree(out)
|
||||||
|
out.mkdir(parents=True)
|
||||||
|
quality = None
|
||||||
|
if args.quality and Path(args.quality).is_file():
|
||||||
|
quality = json.loads(Path(args.quality).read_text())
|
||||||
|
if not isinstance(quality, dict) or quality.get("schema") != 1:
|
||||||
|
raise SystemExit("unsupported quality.json")
|
||||||
|
(out / "style.css").write_text(CSS.strip() + "\n", encoding="utf-8")
|
||||||
|
build_index(out, quality, args.sha)
|
||||||
|
build_manual(out, Path(args.manual), args.sha)
|
||||||
|
build_quality(out, quality, args.sha)
|
||||||
|
build_bench(out, Path(args.bench) if args.bench else None, args.sha)
|
||||||
|
print(f"built {sum(1 for _ in out.rglob('*.html'))} pages in {out}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -32,12 +32,12 @@ def main() -> int:
|
|||||||
print(f"{path.name}: {name} has a different runner image", file=sys.stderr)
|
print(f"{path.name}: {name} has a different runner image", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
pages = yaml.load(
|
pages = yaml.load(
|
||||||
(ROOT / ".gitea/workflows/bench-pages.yml").read_text(),
|
(ROOT / ".gitea/workflows/pages.yml").read_text(),
|
||||||
Loader=yaml.BaseLoader,
|
Loader=yaml.BaseLoader,
|
||||||
)
|
)
|
||||||
if (pages["on"]["workflow_run"]["workflows"] != ["build-test-release"]
|
if (pages["on"]["workflow_run"]["workflows"] != ["build-test-release"]
|
||||||
or pages["jobs"]["publish"].get("runs-on") != "alkane-verify"):
|
or pages["jobs"]["publish"].get("runs-on") != "alkane-verify"):
|
||||||
print("Benchmark Pages must follow main CI on the trusted verifier", file=sys.stderr)
|
print("Pages must follow main CI on the trusted verifier", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
release = yaml.load(
|
release = yaml.load(
|
||||||
(ROOT / ".gitea/workflows/release.yml").read_text(),
|
(ROOT / ".gitea/workflows/release.yml").read_text(),
|
||||||
@@ -46,7 +46,7 @@ def main() -> int:
|
|||||||
if release["jobs"]["release"].get("runs-on") != "alkane-ci":
|
if release["jobs"]["release"].get("runs-on") != "alkane-ci":
|
||||||
print("Main release must use the dedicated Alkane build pool", file=sys.stderr)
|
print("Main release must use the dedicated Alkane build pool", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
if any("ci/publish-bench-pages.py" in step.get("run", "")
|
if any("ci/publish-pages.py" in step.get("run", "")
|
||||||
for step in release["jobs"]["release"]["steps"]):
|
for step in release["jobs"]["release"]["steps"]):
|
||||||
print("Main release must not publish Pages from GARM", file=sys.stderr)
|
print("Main release must not publish Pages from GARM", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[1]
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
DIRECTORIES = ("target", "dist", "coverage", "bench-site")
|
DIRECTORIES = ("target", "dist", "coverage", "bench-site", "site")
|
||||||
FILES = ("bench-current.txt",)
|
FILES = ("bench-current.txt", "coverage-summary.txt", "quality.json")
|
||||||
BADGE_FILES = ("bench-baseline.json", "bench-context.json")
|
BADGE_FILES = ("bench-baseline.json", "bench-context.json", "quality.json")
|
||||||
|
|
||||||
|
|
||||||
def cleanup() -> None:
|
def cleanup() -> None:
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ vendor/*|thirdparty/asic-rs/*)
|
|||||||
# resources, embedded assets). ui.rs/fixtures.rs/bin
|
# resources, embedded assets). ui.rs/fixtures.rs/bin
|
||||||
# match the UI arm above first, so they still bump Z, not Y.
|
# match the UI arm above first, so they still bump Z, not Y.
|
||||||
backend=true ;;
|
backend=true ;;
|
||||||
*) : ;; # docs, HANDOFF, README, thirdparty/wxwidgets tree: no bump
|
*) : ;; # docs, README, thirdparty/wxwidgets tree: no bump
|
||||||
esac
|
esac
|
||||||
done <<< "$changed"
|
done <<< "$changed"
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,19 @@
|
|||||||
# Use the preinstalled CI image or install missing packages on older runners.
|
# Use the preinstalled CI image or install missing packages on older runners.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
mode="${1:?usage: ensure-build-deps.sh base|ui|all|ssh|windows}"
|
mode="${1:?usage: ensure-build-deps.sh base|ui|all|ssh|windows|pages}"
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
base) packages=(libssl-dev pkg-config ca-certificates) ;;
|
base) packages=(libssl-dev pkg-config ca-certificates) ;;
|
||||||
ui) packages=(xvfb xauth dbus-x11 fonts-dejavu-core) ;;
|
ui) packages=(xvfb xauth dbus-x11 fonts-dejavu-core) ;;
|
||||||
ssh) packages=(openssh-client) ;;
|
ssh) packages=(openssh-client) ;;
|
||||||
|
pages) packages=(python3-markdown) ;;
|
||||||
all) packages=(libssl-dev pkg-config ca-certificates openssh-client
|
all) packages=(libssl-dev pkg-config ca-certificates openssh-client
|
||||||
xvfb xauth dbus-x11 fonts-dejavu-core) ;;
|
xvfb xauth dbus-x11 fonts-dejavu-core) ;;
|
||||||
# Windows cross build (mingw-w64, posix threads) + Wine for its tests.
|
# Windows cross build (mingw-w64, posix threads) + Wine for its tests.
|
||||||
windows) packages=(libssl-dev pkg-config ca-certificates
|
windows) packages=(libssl-dev pkg-config ca-certificates
|
||||||
gcc-mingw-w64-x86-64-posix g++-mingw-w64-x86-64-posix
|
gcc-mingw-w64-x86-64-posix g++-mingw-w64-x86-64-posix
|
||||||
binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev wine wine64 xvfb xauth) ;;
|
binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev wine wine64 xvfb xauth
|
||||||
|
openjdk-21-jre-headless) ;;
|
||||||
*) echo "unknown dependency set: $mode" >&2; exit 2 ;;
|
*) echo "unknown dependency set: $mode" >&2; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
Executable
+41
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
"""Download the measured quality record (badges/quality.json on ci-badges).
|
||||||
|
|
||||||
|
fetch-quality.py OUT.json
|
||||||
|
|
||||||
|
Writes nothing (and exits 0) when main CI has not published one yet, so the
|
||||||
|
Pages build shows a "not measured yet" dashboard instead of failing.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import base64
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import sys
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
from urllib.request import Request, urlopen
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
out = Path(sys.argv[1])
|
||||||
|
api = os.environ["GITHUB_API_URL"].rstrip("/")
|
||||||
|
repo = os.environ["GITHUB_REPOSITORY"]
|
||||||
|
url = f"{api}/repos/{repo}/contents/badges/quality.json?ref=ci-badges"
|
||||||
|
request = Request(url, headers={"Authorization": f"token {os.environ['GITEA_TOKEN']}"})
|
||||||
|
try:
|
||||||
|
with urlopen(request, timeout=20) as response:
|
||||||
|
content = base64.b64decode(json.load(response)["content"])
|
||||||
|
except HTTPError as error:
|
||||||
|
if error.code == 404:
|
||||||
|
print("No quality record published yet")
|
||||||
|
return
|
||||||
|
raise
|
||||||
|
if not isinstance(json.loads(content), dict):
|
||||||
|
sys.exit("invalid quality record")
|
||||||
|
out.write_bytes(content)
|
||||||
|
print(f"Fetched quality record ({len(content)} bytes)")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
+103
-8
@@ -135,10 +135,72 @@ def cov_color(pct: float) -> str:
|
|||||||
return "red"
|
return "red"
|
||||||
|
|
||||||
|
|
||||||
def quality_grade(clippy: str | None) -> str:
|
# Code-quality grade (shown on the badge and explained on the Pages quality
|
||||||
if clippy is None:
|
# dashboard). Lint failures fail the grade outright; otherwise the grade is the
|
||||||
|
# measured line-coverage band, using the same bands as the coverage badge
|
||||||
|
# colour, so the two badges can never disagree.
|
||||||
|
GRADE_BANDS = ((80.0, "A"), (60.0, "B"), (40.0, "C"), (20.0, "D"))
|
||||||
|
GRADE_COLORS = {"A": "brightgreen", "B": "yellowgreen", "C": "yellow",
|
||||||
|
"D": "orange", "F": "red", "pending": "lightgrey"}
|
||||||
|
|
||||||
|
|
||||||
|
def quality_grade(clippy: str | None, coverage: float | None = None) -> str:
|
||||||
|
if clippy is None or (clippy == "clean" and coverage is None):
|
||||||
return "pending"
|
return "pending"
|
||||||
return "A" if clippy == "clean" else "F"
|
if clippy != "clean":
|
||||||
|
return "F"
|
||||||
|
for floor, grade in GRADE_BANDS:
|
||||||
|
if coverage >= floor:
|
||||||
|
return grade
|
||||||
|
return "F"
|
||||||
|
|
||||||
|
|
||||||
|
def coverage_by_file(summary_path: str | None, root: str) -> list[dict]:
|
||||||
|
"""Per-file line coverage from a `cargo llvm-cov --summary-only` table.
|
||||||
|
|
||||||
|
Columns: Filename, Regions, Missed Regions, Cover, Functions, Missed
|
||||||
|
Functions, Executed, Lines, Missed Lines, Cover, ...
|
||||||
|
"""
|
||||||
|
if not summary_path:
|
||||||
|
return []
|
||||||
|
rows = []
|
||||||
|
root_abs = os.path.abspath(root).rstrip("/") + "/"
|
||||||
|
for line in Path(summary_path).read_text(errors="replace").splitlines():
|
||||||
|
cols = line.split()
|
||||||
|
if len(cols) < 10 or cols[0] in ("Filename", "TOTAL") or not cols[0].endswith(".rs"):
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
lines, missed = int(cols[7]), int(cols[8])
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
|
name = cols[0][len(root_abs):] if cols[0].startswith(root_abs) else cols[0]
|
||||||
|
# llvm-cov drops the prefix every file shares, so when only workspace
|
||||||
|
# crates are measured "crates/alkane-gui/src/x.rs" is printed as
|
||||||
|
# "alkane-gui/src/x.rs". Put the prefix back.
|
||||||
|
first = Path(name).parts[0] if Path(name).parts else ""
|
||||||
|
if not name.startswith("crates/") and (Path(root) / "crates" / first).is_dir():
|
||||||
|
name = f"crates/{name}"
|
||||||
|
rows.append({"file": name, "lines": lines, "missed": missed})
|
||||||
|
return rows
|
||||||
|
|
||||||
|
|
||||||
|
def crate_of(path: str) -> str:
|
||||||
|
parts = Path(path).parts
|
||||||
|
if "crates" in parts and parts.index("crates") + 1 < len(parts):
|
||||||
|
return parts[parts.index("crates") + 1]
|
||||||
|
if "wx-rs-0.2.0-patched" in parts:
|
||||||
|
return "wx-rs (bridge)"
|
||||||
|
return "other"
|
||||||
|
|
||||||
|
|
||||||
|
def loc_by_crate(root: str) -> dict[str, int]:
|
||||||
|
out: dict[str, int] = {}
|
||||||
|
crates = Path(root) / "crates"
|
||||||
|
for path in sorted(crates.glob("*/**/*.rs")):
|
||||||
|
crate = path.relative_to(crates).parts[0]
|
||||||
|
with open(path, encoding="utf-8", errors="ignore") as fh:
|
||||||
|
out[crate] = out.get(crate, 0) + sum(1 for _ in fh)
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
def human(n: int) -> str:
|
def human(n: int) -> str:
|
||||||
@@ -169,6 +231,9 @@ def main() -> int:
|
|||||||
# percentage string, or "NEW" when there is no baseline.
|
# percentage string, or "NEW" when there is no baseline.
|
||||||
ap.add_argument("--bench-delta", default=None)
|
ap.add_argument("--bench-delta", default=None)
|
||||||
ap.add_argument("--clippy", choices=("clean", "failed"))
|
ap.add_argument("--clippy", choices=("clean", "failed"))
|
||||||
|
# The full `cargo llvm-cov --summary-only` table, for the per-crate and
|
||||||
|
# per-file breakdown in quality.json (the Pages quality dashboard).
|
||||||
|
ap.add_argument("--coverage-summary", default=None)
|
||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
for value in (args.coverage, args.bench_coverage):
|
for value in (args.coverage, args.bench_coverage):
|
||||||
if value is not None and (not math.isfinite(value) or not 0 <= value <= 100):
|
if value is not None and (not math.isfinite(value) or not 0 <= value <= 100):
|
||||||
@@ -189,11 +254,9 @@ def main() -> int:
|
|||||||
write("loc", "lines of code", human(loc), loc_color(loc))
|
write("loc", "lines of code", human(loc), loc_color(loc))
|
||||||
write("license", "license", lic, "blue")
|
write("license", "license", lic, "blue")
|
||||||
write("dependencies", "dependencies", str(deps), "blue")
|
write("dependencies", "dependencies", str(deps), "blue")
|
||||||
grade = quality_grade(args.clippy)
|
grade = quality_grade(args.clippy, args.coverage)
|
||||||
write("quality", "code quality", grade,
|
write("quality", "code quality", grade, GRADE_COLORS[grade],
|
||||||
{"A": "brightgreen", "B": "yellowgreen", "C": "yellow",
|
f"code quality: {grade} (Clippy, rustfmt and line coverage)")
|
||||||
"D": "orange", "F": "red", "pending": "lightgrey"}[grade],
|
|
||||||
f"code quality: {grade} (GUI Clippy and first-party rustfmt)")
|
|
||||||
if args.tests is not None:
|
if args.tests is not None:
|
||||||
write("tests", "tests", f"{args.tests} passing", "brightgreen")
|
write("tests", "tests", f"{args.tests} passing", "brightgreen")
|
||||||
if args.coverage is not None:
|
if args.coverage is not None:
|
||||||
@@ -228,6 +291,38 @@ def main() -> int:
|
|||||||
write("bench", "bench", "baseline set", "blue")
|
write("bench", "bench", "baseline set", "blue")
|
||||||
elif args.bench is not None:
|
elif args.bench is not None:
|
||||||
write("bench", "bench", args.bench, "blue")
|
write("bench", "bench", args.bench, "blue")
|
||||||
|
|
||||||
|
# Everything above, plus the per-crate breakdowns, for the Pages quality
|
||||||
|
# dashboard (ci/build-pages.py).
|
||||||
|
files = coverage_by_file(args.coverage_summary, args.root)
|
||||||
|
crates: dict[str, dict] = {}
|
||||||
|
for row in files:
|
||||||
|
c = crates.setdefault(crate_of(row["file"]), {"lines": 0, "missed": 0})
|
||||||
|
c["lines"] += row["lines"]
|
||||||
|
c["missed"] += row["missed"]
|
||||||
|
quality = {
|
||||||
|
"schema": 1,
|
||||||
|
"sha": os.environ.get("GITHUB_SHA", ""),
|
||||||
|
"grade": grade,
|
||||||
|
"grade_bands": [[floor, letter] for floor, letter in GRADE_BANDS],
|
||||||
|
"clippy": args.clippy,
|
||||||
|
"rustfmt": "clean" if args.clippy is not None else None,
|
||||||
|
"tests_passed": args.tests,
|
||||||
|
"coverage_pct": args.coverage,
|
||||||
|
"bench_coverage_pct": args.bench_coverage,
|
||||||
|
"bench_delta_pct": delta,
|
||||||
|
"bench_same_inputs": same_inputs,
|
||||||
|
"loc": loc,
|
||||||
|
"loc_by_crate": loc_by_crate(args.root),
|
||||||
|
"dependencies": deps,
|
||||||
|
"license": lic,
|
||||||
|
"coverage_by_crate": crates,
|
||||||
|
"coverage_by_file": files,
|
||||||
|
}
|
||||||
|
path = os.path.join(args.root, args.out, "quality.json")
|
||||||
|
with open(path, "w", encoding="utf-8") as fh:
|
||||||
|
json.dump(quality, fh, indent=1, sort_keys=True)
|
||||||
|
print(f"wrote {path}")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
# scripts/build-wx-windows.sh and stamped with the source digest the same
|
# scripts/build-wx-windows.sh and stamped with the source digest the same
|
||||||
# way as the wxGTK prefix (ci/ensure-wx-prefix.sh rebuilds on a mismatch)
|
# way as the wxGTK prefix (ci/ensure-wx-prefix.sh rebuilds on a mismatch)
|
||||||
# - Wine with an initialised prefix, to run the Windows tests and self-test
|
# - Wine with an initialised prefix, to run the Windows tests and self-test
|
||||||
|
# - a Java runtime and jsign (checksum-pinned), to Authenticode-sign the .exe
|
||||||
|
# through Azure Artifact Signing (ci/sign-windows.sh)
|
||||||
#
|
#
|
||||||
# Build and push from the workstation with ci/images/build-image.sh.
|
# Build and push from the workstation with ci/images/build-image.sh.
|
||||||
ARG BASE=gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948
|
ARG BASE=gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948
|
||||||
@@ -18,9 +20,18 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq \
|
|||||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
|
&& DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
|
||||||
gcc-mingw-w64-x86-64-posix g++-mingw-w64-x86-64-posix \
|
gcc-mingw-w64-x86-64-posix g++-mingw-w64-x86-64-posix \
|
||||||
binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev \
|
binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev \
|
||||||
wine wine64 xvfb xauth \
|
wine wine64 xvfb xauth openjdk-21-jre-headless \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# jsign (Maven Central net.jsign:jsign; keep in step with ci/windows-ci.sh).
|
||||||
|
ARG JSIGN_VERSION=7.6
|
||||||
|
ARG JSIGN_SHA256=6cf58aa080e7ff82656f320cff8d4a3bff30408df8766806dcba3740dd839fa5
|
||||||
|
RUN mkdir -p /opt/jsign \
|
||||||
|
&& curl -sSfL -o /opt/jsign/jsign.jar \
|
||||||
|
"https://repo1.maven.org/maven2/net/jsign/jsign/${JSIGN_VERSION}/jsign-${JSIGN_VERSION}.jar" \
|
||||||
|
&& echo "${JSIGN_SHA256} /opt/jsign/jsign.jar" | sha256sum -c - \
|
||||||
|
&& java -jar /opt/jsign/jsign.jar --help >/dev/null
|
||||||
|
|
||||||
RUN rustup target add x86_64-pc-windows-gnu
|
RUN rustup target add x86_64-pc-windows-gnu
|
||||||
|
|
||||||
# The build context is the repository root, filtered by
|
# The build context is the repository root, filtered by
|
||||||
@@ -44,4 +55,5 @@ RUN test -s /root/.cache/wx-3.3.3-mingw/lib/libwx_mswu-3.3-x86_64-w64-mingw32.a
|
|||||||
&& test -s /root/.cache/wx-3.3.3-linux/lib/libwx_gtk3u-3.3.a \
|
&& test -s /root/.cache/wx-3.3.3-linux/lib/libwx_gtk3u-3.3.a \
|
||||||
&& x86_64-w64-mingw32-g++-posix --version >/dev/null \
|
&& x86_64-w64-mingw32-g++-posix --version >/dev/null \
|
||||||
&& wine --version \
|
&& wine --version \
|
||||||
|
&& test -s /opt/jsign/jsign.jar \
|
||||||
&& rustup target list --installed | grep -qx x86_64-pc-windows-gnu
|
&& rustup target list --installed | grep -qx x86_64-pc-windows-gnu
|
||||||
|
|||||||
Executable
+109
@@ -0,0 +1,109 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
"""Package the universal macOS build as an app bundle, for release.
|
||||||
|
|
||||||
|
package-macos.py VERSION BINARY OUT_DIR
|
||||||
|
|
||||||
|
BINARY is the universal (arm64 + x86_64) alkane-toolkit executable made by
|
||||||
|
scripts/build-gui-macos.sh. Writes
|
||||||
|
dist/alkane-toolkit-vVERSION-macos-universal.zip holding "Alkane Toolkit.app",
|
||||||
|
LICENSE and README.txt, and prints its path. Runs on macOS (lipo, codesign,
|
||||||
|
ditto).
|
||||||
|
|
||||||
|
The bundle is ad-hoc signed only (Apple Silicon refuses to run unsigned
|
||||||
|
code); it is not signed with a Developer ID or notarized, so Gatekeeper asks
|
||||||
|
the user to confirm the first launch. README.txt says how.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import pathlib
|
||||||
|
import plistlib
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||||
|
APP = "Alkane Toolkit.app"
|
||||||
|
BUNDLE_ID = "re.bluefla.alkane-toolkit"
|
||||||
|
MIN_MACOS = "11.0"
|
||||||
|
|
||||||
|
|
||||||
|
def run(*args: str) -> str:
|
||||||
|
return subprocess.run(args, check=True, capture_output=True, text=True).stdout
|
||||||
|
|
||||||
|
|
||||||
|
def build_app(version: str, binary: pathlib.Path, dest: pathlib.Path) -> pathlib.Path:
|
||||||
|
archs = run("lipo", "-archs", str(binary)).split()
|
||||||
|
if sorted(archs) != ["arm64", "x86_64"]:
|
||||||
|
sys.exit(f"{binary} is not a universal arm64 + x86_64 binary: {archs}")
|
||||||
|
app = dest / APP
|
||||||
|
macos = app / "Contents" / "MacOS"
|
||||||
|
resources = app / "Contents" / "Resources"
|
||||||
|
macos.mkdir(parents=True)
|
||||||
|
resources.mkdir()
|
||||||
|
shutil.copy2(binary, macos / "alkane-toolkit")
|
||||||
|
shutil.copy2(ROOT / "crates/alkane-gui/macos/alkane-toolkit.icns", resources)
|
||||||
|
info = {
|
||||||
|
"CFBundleName": "Alkane Toolkit",
|
||||||
|
"CFBundleDisplayName": "Alkane Toolkit",
|
||||||
|
"CFBundleIdentifier": BUNDLE_ID,
|
||||||
|
"CFBundleExecutable": "alkane-toolkit",
|
||||||
|
"CFBundleIconFile": "alkane-toolkit",
|
||||||
|
"CFBundlePackageType": "APPL",
|
||||||
|
"CFBundleShortVersionString": version,
|
||||||
|
"CFBundleVersion": version,
|
||||||
|
"CFBundleInfoDictionaryVersion": "6.0",
|
||||||
|
"LSMinimumSystemVersion": MIN_MACOS,
|
||||||
|
"NSHighResolutionCapable": True,
|
||||||
|
"NSPrincipalClass": "NSApplication",
|
||||||
|
# The scanner talks to miners on the local network.
|
||||||
|
"NSLocalNetworkUsageDescription":
|
||||||
|
"Alkane Toolkit scans your local network to find and manage miners.",
|
||||||
|
"NSHumanReadableCopyright":
|
||||||
|
"Copyright (c) 2026 BlueFlare Energy Solutions Inc. (MIT License)",
|
||||||
|
}
|
||||||
|
with open(app / "Contents" / "Info.plist", "wb") as fh:
|
||||||
|
plistlib.dump(info, fh)
|
||||||
|
(app / "Contents" / "PkgInfo").write_text("APPL????")
|
||||||
|
# Ad-hoc signature over the whole bundle (the linker's per-slice
|
||||||
|
# signatures do not cover Info.plist or the resources).
|
||||||
|
run("codesign", "--force", "--sign", "-", "--timestamp=none", str(app))
|
||||||
|
run("codesign", "--verify", "--strict", str(app))
|
||||||
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
def release(version: str, binary: str, out_dir: str) -> None:
|
||||||
|
name = f"alkane-toolkit-v{version}-macos-universal"
|
||||||
|
out = pathlib.Path(out_dir).resolve() / f"{name}.zip"
|
||||||
|
out.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
readme = (
|
||||||
|
f"alkane-toolkit v{version} (macOS, Apple Silicon and Intel)\n"
|
||||||
|
"\n"
|
||||||
|
f"Runs on macOS {MIN_MACOS} (Big Sur) or later. Drag \"Alkane Toolkit\"\n"
|
||||||
|
"to Applications, then open it.\n"
|
||||||
|
"\n"
|
||||||
|
"The app is not notarized by Apple, so the first launch is blocked\n"
|
||||||
|
"with a warning. To allow it once:\n"
|
||||||
|
" - macOS 15 or later: try to open it, then System Settings >\n"
|
||||||
|
" Privacy & Security > \"Open Anyway\" for Alkane Toolkit.\n"
|
||||||
|
" - macOS 11 to 14: Control-click the app, choose Open, then Open.\n"
|
||||||
|
"Or, in Terminal: xattr -dr com.apple.quarantine \"/Applications/Alkane Toolkit.app\"\n"
|
||||||
|
"\n"
|
||||||
|
"Settings are stored in ~/.config/alkane-toolkit/.\n"
|
||||||
|
"Manual: https://blueflare.gitea.bluefla.re/alkane-toolkit/manual/\n"
|
||||||
|
)
|
||||||
|
with tempfile.TemporaryDirectory(prefix="alkane-macos-") as tmp:
|
||||||
|
folder = pathlib.Path(tmp) / name
|
||||||
|
folder.mkdir()
|
||||||
|
build_app(version, pathlib.Path(binary), folder)
|
||||||
|
shutil.copy2(ROOT / "LICENSE", folder / "LICENSE")
|
||||||
|
(folder / "README.txt").write_text(readme)
|
||||||
|
out.unlink(missing_ok=True)
|
||||||
|
run("ditto", "-c", "-k", "--keepParent", str(folder), str(out))
|
||||||
|
print(out)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) != 4:
|
||||||
|
sys.exit(__doc__)
|
||||||
|
release(*sys.argv[1:])
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import struct
|
||||||
import sys
|
import sys
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ def release(version: str, exe: str, out_dir: str) -> None:
|
|||||||
exe_path = pathlib.Path(exe)
|
exe_path = pathlib.Path(exe)
|
||||||
if exe_path.suffix != ".exe" or not exe_path.is_file():
|
if exe_path.suffix != ".exe" or not exe_path.is_file():
|
||||||
sys.exit(f"not a Windows executable: {exe}")
|
sys.exit(f"not a Windows executable: {exe}")
|
||||||
|
signed = _has_authenticode_signature(exe_path)
|
||||||
name = f"alkane-toolkit-v{version}-windows-x86_64"
|
name = f"alkane-toolkit-v{version}-windows-x86_64"
|
||||||
out = pathlib.Path(out_dir) / f"{name}.zip"
|
out = pathlib.Path(out_dir) / f"{name}.zip"
|
||||||
out.parent.mkdir(parents=True, exist_ok=True)
|
out.parent.mkdir(parents=True, exist_ok=True)
|
||||||
@@ -35,6 +37,14 @@ def release(version: str, exe: str, out_dir: str) -> None:
|
|||||||
"Run alkane-toolkit.exe. No installer and no extra runtime are needed:\r\n"
|
"Run alkane-toolkit.exe. No installer and no extra runtime are needed:\r\n"
|
||||||
"the executable is self-contained and runs on Windows 10 and 11.\r\n"
|
"the executable is self-contained and runs on Windows 10 and 11.\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
|
+ (
|
||||||
|
"The executable is signed by BlueFlare Energy Solutions Inc. (Azure Artifact Signing). To check:\r\n"
|
||||||
|
"right-click alkane-toolkit.exe > Properties > Digital Signatures.\r\n"
|
||||||
|
if signed else
|
||||||
|
"This build is not code-signed, so Windows SmartScreen may warn on first\r\n"
|
||||||
|
"run: choose More info > Run anyway.\r\n"
|
||||||
|
)
|
||||||
|
+ "\r\n"
|
||||||
"Settings are kept in %APPDATA%\\alkane-toolkit.\r\n"
|
"Settings are kept in %APPDATA%\\alkane-toolkit.\r\n"
|
||||||
"SSH-based actions use the OpenSSH client built into Windows (ssh.exe);\r\n"
|
"SSH-based actions use the OpenSSH client built into Windows (ssh.exe);\r\n"
|
||||||
"HTTP actions use curl.exe, also built in.\r\n"
|
"HTTP actions use curl.exe, also built in.\r\n"
|
||||||
@@ -49,6 +59,15 @@ def release(version: str, exe: str, out_dir: str) -> None:
|
|||||||
print(out)
|
print(out)
|
||||||
|
|
||||||
|
|
||||||
|
def _has_authenticode_signature(exe: pathlib.Path) -> bool:
|
||||||
|
"""True if the PE file carries a certificate table (an Authenticode signature)."""
|
||||||
|
data = exe.read_bytes()
|
||||||
|
pe = struct.unpack_from("<I", data, 0x3C)[0]
|
||||||
|
magic = struct.unpack_from("<H", data, pe + 24)[0]
|
||||||
|
dirs = pe + 24 + (96 if magic == 0x10B else 112)
|
||||||
|
return struct.unpack_from("<II", data, dirs + 4 * 8)[1] > 0
|
||||||
|
|
||||||
|
|
||||||
def tests(cargo_json: str, out_zip: str) -> None:
|
def tests(cargo_json: str, out_zip: str) -> None:
|
||||||
executables = []
|
executables = []
|
||||||
for line in pathlib.Path(cargo_json).read_text().splitlines():
|
for line in pathlib.Path(cargo_json).read_text().splitlines():
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
"""Publish a measured benchmark page to the public, data-only Pages repo."""
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
import shlex
|
|
||||||
import subprocess
|
|
||||||
import tempfile
|
|
||||||
from urllib.request import Request, urlopen
|
|
||||||
|
|
||||||
PAGES_REPO = "ssh://git@gitea.bluefla.re:2222/blueflare/alkane-benchmarks.git"
|
|
||||||
GUARD_REPO = "https://gitea.bluefla.re/blueflare/alkane-benchmarks.git"
|
|
||||||
GUARD_COMMIT = "ea160545c49bc419a245692deda8dd7db7a611eb"
|
|
||||||
PAGES_HOST = "gitea.bluefla.re"
|
|
||||||
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,
|
|
||||||
cwd: Path | None = None) -> subprocess.CompletedProcess[str]:
|
|
||||||
return subprocess.run(args, env=env, cwd=cwd, text=True,
|
|
||||||
capture_output=True, check=True)
|
|
||||||
|
|
||||||
|
|
||||||
def current_main_sha() -> str:
|
|
||||||
api = os.environ["GITHUB_API_URL"].rstrip("/")
|
|
||||||
repo = os.environ["GITHUB_REPOSITORY"]
|
|
||||||
token = os.environ["GITEA_TOKEN"]
|
|
||||||
request = Request(f"{api}/repos/{repo}/branches/main",
|
|
||||||
headers={"Authorization": f"token {token}"})
|
|
||||||
with urlopen(request, timeout=20) as response:
|
|
||||||
branch = json.load(response)
|
|
||||||
return branch["commit"]["id"]
|
|
||||||
|
|
||||||
|
|
||||||
def publish(site: str) -> None:
|
|
||||||
if os.environ.get("GITHUB_REF") != "refs/heads/main":
|
|
||||||
raise ValueError("benchmark Pages publication requires main")
|
|
||||||
sha = os.environ["GITHUB_SHA"]
|
|
||||||
if current_main_sha() != sha:
|
|
||||||
print("Skipping benchmark page from a superseded main commit")
|
|
||||||
return
|
|
||||||
page = Path("bench-site/index.html").read_bytes()
|
|
||||||
if not page.startswith(b"<!doctype html>") or len(page) > 1_048_576:
|
|
||||||
raise ValueError("invalid benchmark page")
|
|
||||||
with tempfile.TemporaryDirectory(prefix="alkane-pages-") as directory:
|
|
||||||
temporary = Path(directory)
|
|
||||||
guard_checkout = temporary / "guard"
|
|
||||||
run("git", "clone", "--quiet", "--single-branch", "--branch", "next",
|
|
||||||
GUARD_REPO, str(guard_checkout))
|
|
||||||
guard_source = run("git", "show", f"{GUARD_COMMIT}:ci/validate_site.py",
|
|
||||||
cwd=guard_checkout).stdout
|
|
||||||
guard_script = temporary / "validate_site.py"
|
|
||||||
guard_script.write_text(guard_source)
|
|
||||||
run("python3", str(guard_script), "--page", site,
|
|
||||||
str(Path("bench-site/index.html").resolve()))
|
|
||||||
key = os.environ["BENCH_PAGES_DEPLOY_KEY"]
|
|
||||||
if not key.startswith("-----BEGIN OPENSSH PRIVATE KEY-----"):
|
|
||||||
raise ValueError("missing benchmark Pages deploy key")
|
|
||||||
key_path = temporary / "deploy_key"
|
|
||||||
key_path.write_text(key.rstrip("\n") + "\n")
|
|
||||||
key_path.chmod(0o600)
|
|
||||||
known_hosts = temporary / "known_hosts"
|
|
||||||
known_hosts.write_text(PAGES_HOST_KEY + "\n")
|
|
||||||
fingerprint = run("ssh-keygen", "-lf", str(known_hosts)).stdout.split()[1]
|
|
||||||
if fingerprint != PAGES_HOST_FINGERPRINT:
|
|
||||||
raise ValueError("benchmark Pages SSH host key changed")
|
|
||||||
git_env = os.environ.copy()
|
|
||||||
ssh_command = (f"ssh -i {shlex.quote(str(key_path))} -o IdentitiesOnly=yes "
|
|
||||||
f"-o UserKnownHostsFile={shlex.quote(str(known_hosts))} "
|
|
||||||
"-o StrictHostKeyChecking=yes -o ConnectTimeout=10")
|
|
||||||
git_env["GIT_SSH_COMMAND"] = ssh_command
|
|
||||||
git_env["GIT_TERMINAL_PROMPT"] = "0"
|
|
||||||
checkout = temporary / "site"
|
|
||||||
run("git", "clone", "--quiet", "--single-branch", "--branch", "gh-pages",
|
|
||||||
PAGES_REPO, str(checkout), env=git_env)
|
|
||||||
run("git", "config", "user.name", "Alkane CI", cwd=checkout)
|
|
||||||
run("git", "config", "user.email", "ci@bluefla.re", cwd=checkout)
|
|
||||||
for attempt in range(3):
|
|
||||||
if current_main_sha() != sha:
|
|
||||||
print("Skipping benchmark page from a superseded main commit")
|
|
||||||
return
|
|
||||||
run("git", "fetch", "--quiet", "origin", "gh-pages", env=git_env,
|
|
||||||
cwd=checkout)
|
|
||||||
run("git", "checkout", "-q", "-B", "bench-publish", "origin/gh-pages",
|
|
||||||
cwd=checkout)
|
|
||||||
destination = checkout / site / "index.html"
|
|
||||||
destination.parent.mkdir(exist_ok=True)
|
|
||||||
destination.write_bytes(page)
|
|
||||||
run("git", "add", f"{site}/index.html", cwd=checkout)
|
|
||||||
changed = subprocess.run(("git", "diff", "--cached", "--quiet"),
|
|
||||||
cwd=checkout, check=False)
|
|
||||||
if changed.returncode == 0:
|
|
||||||
print(f"{site} benchmark page is already current")
|
|
||||||
return
|
|
||||||
if changed.returncode != 1:
|
|
||||||
raise RuntimeError("cannot compare benchmark page")
|
|
||||||
run("git", "commit", "-q", "-m",
|
|
||||||
f"Update {site} benchmarks for {sha[:10]} [skip ci]", cwd=checkout)
|
|
||||||
pushed = subprocess.run(("git", "push", "--quiet", "origin",
|
|
||||||
"HEAD:gh-pages"), env=git_env, cwd=checkout,
|
|
||||||
text=True, capture_output=True, check=False)
|
|
||||||
if pushed.returncode == 0:
|
|
||||||
print(f"Published {site} benchmark page for {sha[:10]}")
|
|
||||||
return
|
|
||||||
if attempt == 2:
|
|
||||||
raise RuntimeError(f"benchmark Pages push failed: {pushed.stderr.strip()}")
|
|
||||||
raise RuntimeError("benchmark Pages publication did not complete")
|
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("site", choices=("sdk", "os", "toolkit"))
|
|
||||||
publish(parser.parse_args().site)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
"""Publish measured toolkit badges to the private Gitea badge branch."""
|
"""Publish measured toolkit badges to the private Gitea badge branch."""
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -22,7 +23,14 @@ def main() -> None:
|
|||||||
raise ValueError(f"invalid {name} SVG")
|
raise ValueError(f"invalid {name} SVG")
|
||||||
publish_file(api, repo, f"badges/{name}.svg", data, token,
|
publish_file(api, repo, f"badges/{name}.svg", data, token,
|
||||||
f"Update measured {name} badge")
|
f"Update measured {name} badge")
|
||||||
print(f"Published {len(NAMES)} measured badge SVGs")
|
# The full measurement record behind the badges, read by the Pages
|
||||||
|
# quality dashboard (ci/build-pages.py).
|
||||||
|
data = (ROOT / "badges" / "quality.json").read_bytes()
|
||||||
|
if not isinstance(json.loads(data), dict):
|
||||||
|
raise ValueError("invalid quality.json")
|
||||||
|
publish_file(api, repo, "badges/quality.json", data, token,
|
||||||
|
"Update measured quality record", max_bytes=262_144)
|
||||||
|
print(f"Published {len(NAMES)} measured badge SVGs and quality.json")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Executable
+79
@@ -0,0 +1,79 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
"""Publish the built Pages site to this repository's gh-pages branch.
|
||||||
|
|
||||||
|
publish-pages.py SITE_DIR
|
||||||
|
|
||||||
|
Served at https://blueflare.gitea.bluefla.re/alkane-toolkit/ by the Pages
|
||||||
|
server, which serves the gh-pages branch of public repositories. Each publish
|
||||||
|
is one orphan commit (force-pushed), so the branch never accumulates history.
|
||||||
|
Only main may publish, and a run for a superseded main commit skips.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
from urllib.request import Request, urlopen
|
||||||
|
|
||||||
|
BRANCH = "gh-pages"
|
||||||
|
MAX_BYTES = 20 * 1024 * 1024
|
||||||
|
|
||||||
|
|
||||||
|
def current_main_sha(api: str, repo: str, token: str) -> str:
|
||||||
|
request = Request(f"{api}/repos/{repo}/branches/main",
|
||||||
|
headers={"Authorization": f"token {token}"})
|
||||||
|
with urlopen(request, timeout=20) as response:
|
||||||
|
return json.load(response)["commit"]["id"]
|
||||||
|
|
||||||
|
|
||||||
|
def git(*args: str, cwd: Path, env: dict | None = None) -> None:
|
||||||
|
subprocess.run(("git", *args), cwd=cwd, env=env, check=True)
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
sys.exit(__doc__)
|
||||||
|
site = Path(sys.argv[1])
|
||||||
|
if not (site / "index.html").is_file():
|
||||||
|
sys.exit(f"{site} has no index.html")
|
||||||
|
size = sum(p.stat().st_size for p in site.rglob("*") if p.is_file())
|
||||||
|
if size > MAX_BYTES:
|
||||||
|
sys.exit(f"site is {size} bytes, over the {MAX_BYTES} byte limit")
|
||||||
|
for path in site.rglob("*"):
|
||||||
|
if path.is_file() and path.suffix not in {".html", ".css", ".svg", ".png", ".json"}:
|
||||||
|
sys.exit(f"unexpected file type on the site: {path}")
|
||||||
|
|
||||||
|
api = os.environ["GITHUB_API_URL"].rstrip("/")
|
||||||
|
repo = os.environ["GITHUB_REPOSITORY"]
|
||||||
|
sha = os.environ["GITHUB_SHA"]
|
||||||
|
token = os.environ["GITEA_TOKEN"]
|
||||||
|
if os.environ.get("GITHUB_REF") != "refs/heads/main":
|
||||||
|
sys.exit("Pages publication requires main")
|
||||||
|
if current_main_sha(api, repo, token) != sha:
|
||||||
|
print("Skipping Pages for a superseded main commit")
|
||||||
|
return
|
||||||
|
|
||||||
|
server = api.removesuffix("/api/v1")
|
||||||
|
with tempfile.TemporaryDirectory(prefix="alkane-pages-") as directory:
|
||||||
|
work = Path(directory)
|
||||||
|
shutil.copytree(site, work, dirs_exist_ok=True)
|
||||||
|
env = dict(os.environ, GIT_TERMINAL_PROMPT="0")
|
||||||
|
git("init", "-q", "-b", BRANCH, cwd=work)
|
||||||
|
git("-c", "user.name=Alkane CI", "-c", "user.email=ci@noreply.gitea.bluefla.re",
|
||||||
|
"add", "-A", cwd=work)
|
||||||
|
git("-c", "user.name=Alkane CI", "-c", "user.email=ci@noreply.gitea.bluefla.re",
|
||||||
|
"commit", "-q", "-m", f"Publish site for {sha[:10]} [skip ci]", cwd=work)
|
||||||
|
# The token is read from the environment by the credential helper at
|
||||||
|
# push time; it never appears on a command line or in the remote URL.
|
||||||
|
helper = '!f() { echo username=alkane-ci; echo "password=$GITEA_TOKEN"; }; f'
|
||||||
|
git("-c", f"credential.helper={helper}", "push", "-q", "--force",
|
||||||
|
f"{server}/{repo}.git", f"HEAD:refs/heads/{BRANCH}", cwd=work, env=env)
|
||||||
|
print(f"Published Pages for {sha[:10]} to {BRANCH}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041
|
gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||||
|
|||||||
Executable
+88
@@ -0,0 +1,88 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
# Authenticode-sign Windows executables with Azure Artifact Signing (formerly
|
||||||
|
# Trusted Signing), from Linux, with jsign. Every signature is RFC 3161
|
||||||
|
# timestamped: the signing certificates live only a few days, the timestamp is
|
||||||
|
# what keeps a signature valid after that.
|
||||||
|
#
|
||||||
|
# ci/sign-windows.sh FILE.exe [FILE.exe ...]
|
||||||
|
#
|
||||||
|
# Configuration (environment):
|
||||||
|
# AZURE_SIGNING_PROFILE certificate profile name; EMPTY = signing not set
|
||||||
|
# up yet: the files are left unsigned (exit 0)
|
||||||
|
# AZURE_SIGNING_ACCOUNT signing account (default blueflaresigning)
|
||||||
|
# AZURE_SIGNING_ENDPOINT account endpoint (default https://wus2.codesigning.azure.net)
|
||||||
|
# Credentials, one of:
|
||||||
|
# AZURE_SIGNING_TENANT_ID + AZURE_SIGNING_CLIENT_ID + AZURE_SIGNING_CLIENT_SECRET
|
||||||
|
# (the CI service principal alkane-toolkit-ci-signer, role
|
||||||
|
# "Artifact Signing Certificate Profile Signer" on the account only)
|
||||||
|
# AZURE_SIGNING_TOKEN an access token for https://codesigning.azure.net,
|
||||||
|
# e.g. from `az account get-access-token --resource https://codesigning.azure.net`
|
||||||
|
# ALKANE_JSIGN_JAR jsign jar (default /opt/jsign/jsign.jar, from the CI image)
|
||||||
|
#
|
||||||
|
# Once a profile is configured, any failure fails the job: a release is never
|
||||||
|
# shipped half-signed or silently unsigned.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
[ "$#" -gt 0 ] || { sed -n '3,25p' "$0" >&2; exit 2; }
|
||||||
|
profile="${AZURE_SIGNING_PROFILE:-}"
|
||||||
|
if [ -z "$profile" ]; then
|
||||||
|
echo "Windows code signing is not enabled (AZURE_SIGNING_PROFILE unset); leaving $* unsigned"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
account="${AZURE_SIGNING_ACCOUNT:-blueflaresigning}"
|
||||||
|
endpoint="${AZURE_SIGNING_ENDPOINT:-https://wus2.codesigning.azure.net}"
|
||||||
|
jar="${ALKANE_JSIGN_JAR:-/opt/jsign/jsign.jar}"
|
||||||
|
[ -f "$jar" ] || { echo "jsign not found at $jar" >&2; exit 1; }
|
||||||
|
|
||||||
|
if [ -z "${AZURE_SIGNING_TOKEN:-}" ]; then
|
||||||
|
: "${AZURE_SIGNING_TENANT_ID:?signing credentials missing}"
|
||||||
|
: "${AZURE_SIGNING_CLIENT_ID:?signing credentials missing}"
|
||||||
|
: "${AZURE_SIGNING_CLIENT_SECRET:?signing credentials missing}"
|
||||||
|
# Client-credentials token for the signing service. The secret and token
|
||||||
|
# stay in this process's environment, never on a command line.
|
||||||
|
AZURE_SIGNING_TOKEN="$(python3 - <<'PY'
|
||||||
|
import json, os, sys, urllib.parse, urllib.request
|
||||||
|
body = urllib.parse.urlencode({
|
||||||
|
"grant_type": "client_credentials",
|
||||||
|
"client_id": os.environ["AZURE_SIGNING_CLIENT_ID"],
|
||||||
|
"client_secret": os.environ["AZURE_SIGNING_CLIENT_SECRET"],
|
||||||
|
"scope": "https://codesigning.azure.net/.default",
|
||||||
|
}).encode()
|
||||||
|
url = f"https://login.microsoftonline.com/{os.environ['AZURE_SIGNING_TENANT_ID']}/oauth2/v2.0/token"
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(url, body, timeout=60) as r:
|
||||||
|
print(json.load(r)["access_token"])
|
||||||
|
except Exception as e:
|
||||||
|
sys.exit(f"could not get a signing token: {e}")
|
||||||
|
PY
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
export AZURE_SIGNING_TOKEN
|
||||||
|
|
||||||
|
for file in "$@"; do
|
||||||
|
java -jar "$jar" \
|
||||||
|
--storetype TRUSTEDSIGNING \
|
||||||
|
--keystore "${endpoint#https://}" \
|
||||||
|
--storepass env:AZURE_SIGNING_TOKEN \
|
||||||
|
--alias "$account/$profile" \
|
||||||
|
--alg SHA-256 \
|
||||||
|
--tsaurl http://timestamp.acs.microsoft.com --tsmode RFC3161 \
|
||||||
|
--tsretries 3 --tsretrywait 10 \
|
||||||
|
--name "Alkane Toolkit" \
|
||||||
|
--url https://gitea.bluefla.re/blueflare/alkane-toolkit \
|
||||||
|
"$file"
|
||||||
|
# jsign fails on any error; also make sure a signature actually landed in
|
||||||
|
# the PE certificate table before the file goes anywhere.
|
||||||
|
python3 - "$file" <<'PY'
|
||||||
|
import struct, sys
|
||||||
|
data = open(sys.argv[1], "rb").read()
|
||||||
|
pe = struct.unpack_from("<I", data, 0x3C)[0]
|
||||||
|
magic = struct.unpack_from("<H", data, pe + 24)[0]
|
||||||
|
dirs = pe + 24 + (96 if magic == 0x10B else 112)
|
||||||
|
offset, size = struct.unpack_from("<II", data, dirs + 4 * 8) # IMAGE_DIRECTORY_ENTRY_SECURITY
|
||||||
|
if size == 0:
|
||||||
|
sys.exit(f"{sys.argv[1]}: no Authenticode signature after signing")
|
||||||
|
print(f"{sys.argv[1]}: signed ({size} byte certificate table)")
|
||||||
|
PY
|
||||||
|
done
|
||||||
+41
-10
@@ -5,6 +5,7 @@
|
|||||||
import importlib.util
|
import importlib.util
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
@@ -50,16 +51,46 @@ class BenchBadgeTests(unittest.TestCase):
|
|||||||
self.assertEqual(gen_badges.bench_color(30.0), "brightgreen")
|
self.assertEqual(gen_badges.bench_color(30.0), "brightgreen")
|
||||||
self.assertEqual(gen_badges.bench_color(-55.5555556), "orange")
|
self.assertEqual(gen_badges.bench_color(-55.5555556), "orange")
|
||||||
|
|
||||||
def test_quality_grade_is_only_the_clippy_result(self):
|
def test_quality_grade_follows_lint_and_coverage(self):
|
||||||
self.assertEqual(gen_badges.quality_grade("clean"), "A")
|
# A lint failure fails the grade; otherwise it is the coverage band,
|
||||||
self.assertEqual(gen_badges.quality_grade("failed"), "F")
|
# with the same floors as the coverage badge colour.
|
||||||
self.assertEqual(gen_badges.quality_grade(None), "pending")
|
self.assertEqual(gen_badges.quality_grade("failed", 95.0), "F")
|
||||||
svg = gen_badges.badge_svg(
|
self.assertEqual(gen_badges.quality_grade("clean", 85.0), "A")
|
||||||
"code quality", "A", "brightgreen",
|
self.assertEqual(gen_badges.quality_grade("clean", 65.6), "B")
|
||||||
"code quality: A (GUI Clippy and first-party rustfmt)",
|
self.assertEqual(gen_badges.quality_grade("clean", 48.0), "C")
|
||||||
)
|
self.assertEqual(gen_badges.quality_grade("clean", 25.0), "D")
|
||||||
self.assertIn('aria-label="code quality: A (GUI Clippy and first-party rustfmt)"', svg)
|
self.assertEqual(gen_badges.quality_grade("clean", 5.0), "F")
|
||||||
self.assertIn('>A</text>', svg)
|
self.assertEqual(gen_badges.quality_grade("clean"), "pending")
|
||||||
|
self.assertEqual(gen_badges.quality_grade(None, 90.0), "pending")
|
||||||
|
for pct in (85.0, 65.6, 48.0, 25.0):
|
||||||
|
grade = gen_badges.quality_grade("clean", pct)
|
||||||
|
self.assertEqual(gen_badges.GRADE_COLORS[grade], gen_badges.cov_color(pct))
|
||||||
|
|
||||||
|
def test_coverage_table_is_split_by_crate(self):
|
||||||
|
with tempfile.TemporaryDirectory(prefix="alkane-cov-") as directory:
|
||||||
|
summary = Path(directory) / "summary.txt"
|
||||||
|
summary.write_text(
|
||||||
|
"Filename Regions Missed Regions Cover Functions Missed Functions "
|
||||||
|
"Executed Lines Missed Lines Cover\n"
|
||||||
|
"crates/alkane-gui/src/ui.rs 10 5 50.00% 4 2 50.00% 100 60 40.00%\n"
|
||||||
|
"crates/alkane-core/src/platform.rs 4 0 100.00% 2 0 100.00% 50 5 90.00%\n"
|
||||||
|
"TOTAL 14 5 64.29% 6 2 66.67% 150 65 56.67%\n")
|
||||||
|
rows = gen_badges.coverage_by_file(str(summary), directory)
|
||||||
|
self.assertEqual([r["file"] for r in rows],
|
||||||
|
["crates/alkane-gui/src/ui.rs", "crates/alkane-core/src/platform.rs"])
|
||||||
|
self.assertEqual(rows[0]["missed"], 60)
|
||||||
|
self.assertEqual(gen_badges.crate_of(rows[1]["file"]), "alkane-core")
|
||||||
|
|
||||||
|
def test_coverage_table_restores_the_stripped_crates_prefix(self):
|
||||||
|
with tempfile.TemporaryDirectory(prefix="alkane-cov-") as directory:
|
||||||
|
(Path(directory) / "crates" / "alkane-cli").mkdir(parents=True)
|
||||||
|
summary = Path(directory) / "summary.txt"
|
||||||
|
summary.write_text(
|
||||||
|
"alkane-cli/src/main.rs 4 4 0.00% 1 1 0.00% 23 23 0.00%\n")
|
||||||
|
rows = gen_badges.coverage_by_file(str(summary), directory)
|
||||||
|
self.assertEqual(rows[0], {"file": "crates/alkane-cli/src/main.rs",
|
||||||
|
"lines": 23, "missed": 23})
|
||||||
|
self.assertEqual(gen_badges.crate_of(rows[0]["file"]), "alkane-cli")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ def check_workflow_contract() -> None:
|
|||||||
"Clippy (Windows target, warnings are errors)", "Build release (Windows)",
|
"Clippy (Windows target, warnings are errors)", "Build release (Windows)",
|
||||||
"Unit tests (Windows build, under Wine)",
|
"Unit tests (Windows build, under Wine)",
|
||||||
"Headless UI self-test (Windows build, under Wine)",
|
"Headless UI self-test (Windows build, under Wine)",
|
||||||
|
"Sign Windows executable (Azure Artifact Signing)",
|
||||||
"Package Windows artifact", "Clean generated Toolkit build",
|
"Package Windows artifact", "Clean generated Toolkit build",
|
||||||
)),
|
)),
|
||||||
("next.yml", "next", "candidate", (
|
("next.yml", "next", "candidate", (
|
||||||
@@ -50,7 +51,8 @@ def check_workflow_contract() -> None:
|
|||||||
"Create private prerelease", "Clean generated Toolkit build",
|
"Create private prerelease", "Clean generated Toolkit build",
|
||||||
)),
|
)),
|
||||||
("next.yml", "next", "windows", (
|
("next.yml", "next", "windows", (
|
||||||
"Build Windows candidate", "Package Windows candidate",
|
"Build Windows candidate", "Sign Windows candidate (Azure Artifact Signing)",
|
||||||
|
"Package Windows candidate",
|
||||||
"Clean generated Toolkit build",
|
"Clean generated Toolkit build",
|
||||||
)),
|
)),
|
||||||
("verify.yml", "main", "verify", (
|
("verify.yml", "main", "verify", (
|
||||||
@@ -83,7 +85,8 @@ def check_workflow_contract() -> None:
|
|||||||
condition = steps[position].get("if")
|
condition = steps[position].get("if")
|
||||||
if gate in {"Create Gitea release + upload artifact",
|
if gate in {"Create Gitea release + upload artifact",
|
||||||
"Create private prerelease", "Package Windows artifact",
|
"Create private prerelease", "Package Windows artifact",
|
||||||
"Build Windows candidate", "Package Windows candidate"}:
|
"Build Windows candidate", "Package Windows candidate",
|
||||||
|
"Sign Windows candidate (Azure Artifact Signing)"}:
|
||||||
assert condition is not None and "release == 'true'" in condition, path
|
assert condition is not None and "release == 'true'" in condition, path
|
||||||
elif filename == "verify.yml" and gate in {
|
elif filename == "verify.yml" and gate in {
|
||||||
"Build", "Unit tests", "Microbenchmarks",
|
"Build", "Unit tests", "Microbenchmarks",
|
||||||
|
|||||||
+16
-1
@@ -8,6 +8,9 @@
|
|||||||
# windows-ci.sh build release alkane-toolkit.exe
|
# windows-ci.sh build release alkane-toolkit.exe
|
||||||
# windows-ci.sh test all unit tests, run under Wine
|
# windows-ci.sh test all unit tests, run under Wine
|
||||||
# windows-ci.sh selftest headless UI self-test under Wine + Xvfb
|
# windows-ci.sh selftest headless UI self-test under Wine + Xvfb
|
||||||
|
# windows-ci.sh sign Authenticode-sign alkane-toolkit.exe through
|
||||||
|
# Azure Artifact Signing (ci/sign-windows.sh;
|
||||||
|
# a no-op until AZURE_SIGNING_PROFILE is set)
|
||||||
# windows-ci.sh package VERSION dist/alkane-toolkit-vVERSION-windows-x86_64.zip
|
# windows-ci.sh package VERSION dist/alkane-toolkit-vVERSION-windows-x86_64.zip
|
||||||
# windows-ci.sh test-bundle dist/alkane-toolkit-windows-tests.zip (for
|
# windows-ci.sh test-bundle dist/alkane-toolkit-windows-tests.zip (for
|
||||||
# the native Windows job)
|
# the native Windows job)
|
||||||
@@ -30,6 +33,15 @@ case "${1:-}" in
|
|||||||
toolchain)
|
toolchain)
|
||||||
bash ci/ensure-build-deps.sh windows
|
bash ci/ensure-build-deps.sh windows
|
||||||
rustup target list --installed | grep -qx "$target" || rustup target add "$target"
|
rustup target list --installed | grep -qx "$target" || rustup target add "$target"
|
||||||
|
# jsign ships in the CI image; fetch the same pinned jar on older images.
|
||||||
|
jsign_version=7.6
|
||||||
|
jsign_sha256=6cf58aa080e7ff82656f320cff8d4a3bff30408df8766806dcba3740dd839fa5
|
||||||
|
if [ ! -s /opt/jsign/jsign.jar ]; then
|
||||||
|
mkdir -p /opt/jsign
|
||||||
|
curl -sSfL -o /opt/jsign/jsign.jar \
|
||||||
|
"https://repo1.maven.org/maven2/net/jsign/jsign/$jsign_version/jsign-$jsign_version.jar"
|
||||||
|
echo "$jsign_sha256 /opt/jsign/jsign.jar" | sha256sum -c -
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
clippy)
|
clippy)
|
||||||
rustup component add clippy >/dev/null 2>&1 || true
|
rustup component add clippy >/dev/null 2>&1 || true
|
||||||
@@ -53,6 +65,9 @@ case "${1:-}" in
|
|||||||
selftest)
|
selftest)
|
||||||
bash scripts/ui-selftest-windows.sh "$exe"
|
bash scripts/ui-selftest-windows.sh "$exe"
|
||||||
;;
|
;;
|
||||||
|
sign)
|
||||||
|
bash ci/sign-windows.sh "$exe"
|
||||||
|
;;
|
||||||
package)
|
package)
|
||||||
python3 ci/package-windows.py release "${2:?usage: windows-ci.sh package VERSION}" "$exe" dist
|
python3 ci/package-windows.py release "${2:?usage: windows-ci.sh package VERSION}" "$exe" dist
|
||||||
;;
|
;;
|
||||||
@@ -64,7 +79,7 @@ case "${1:-}" in
|
|||||||
dist/alkane-toolkit-windows-tests.zip
|
dist/alkane-toolkit-windows-tests.zip
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
sed -n '3,16p' "$0" >&2
|
sed -n '3,19p' "$0" >&2
|
||||||
exit 2
|
exit 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Binary file not shown.
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Regenerate alkane-toolkit.icns (the macOS app icon) from the in-repo
|
||||||
|
# microchip glyph: the same white chip on a rounded amber tile as the Windows
|
||||||
|
# icon, at the sizes macOS asks for (16-1024 px). Needs rsvg-convert,
|
||||||
|
# ImageMagick and python3; the .icns is committed, so a build never runs this.
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
GLYPH=../assets/icons/microchip-solid-full.svg
|
||||||
|
TMP=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$TMP"' 0
|
||||||
|
sed 's/currentColor/#ffffff/g; s/<svg /<svg fill="#ffffff" /' "$GLYPH" > "$TMP/glyph.svg"
|
||||||
|
for s in 16 32 64 128 256 512 1024; do
|
||||||
|
# Apple's grid: the tile fills ~80% of the canvas, centred.
|
||||||
|
t=$((s * 80 / 100)); m=$(((s - t) / 2)); r=$((t * 22 / 100))
|
||||||
|
g=$((t * 60 / 100)); o=$(((s - g) / 2))
|
||||||
|
rsvg-convert -w "$g" -h "$g" "$TMP/glyph.svg" -o "$TMP/g$s.png"
|
||||||
|
convert -size "${s}x${s}" xc:none -fill '#d9822b' \
|
||||||
|
-draw "roundrectangle $m,$m $((m + t - 1)),$((m + t - 1)) $r,$r" \
|
||||||
|
"$TMP/g$s.png" -geometry "+$o+$o" -composite "PNG32:$TMP/i$s.png"
|
||||||
|
done
|
||||||
|
python3 - "$TMP" alkane-toolkit.icns <<'PY'
|
||||||
|
import pathlib, struct, sys
|
||||||
|
tmp, out = pathlib.Path(sys.argv[1]), sys.argv[2]
|
||||||
|
# ICNS element types that hold PNG data, by pixel size.
|
||||||
|
types = [("icp4", 16), ("icp5", 32), ("icp6", 64), ("ic07", 128), ("ic08", 256),
|
||||||
|
("ic09", 512), ("ic10", 1024), ("ic11", 32), ("ic12", 64), ("ic13", 256),
|
||||||
|
("ic14", 512)]
|
||||||
|
body = b""
|
||||||
|
for kind, size in types:
|
||||||
|
data = (tmp / f"i{size}.png").read_bytes()
|
||||||
|
body += kind.encode() + struct.pack(">I", len(data) + 8) + data
|
||||||
|
pathlib.Path(out).write_bytes(b"icns" + struct.pack(">I", len(body) + 8) + body)
|
||||||
|
PY
|
||||||
|
echo "wrote $(pwd)/alkane-toolkit.icns"
|
||||||
@@ -69,13 +69,26 @@ pub fn load_ssh_credentials() -> Option<(String, String)> {
|
|||||||
load_creds_file(SSH_CREDENTIALS_FILE)
|
load_creds_file(SSH_CREDENTIALS_FILE)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save the SSH username/password (0600). Retained for a future SSH-login dialog
|
/// Save the SSH username/password (0600), from the Credentials dialog.
|
||||||
/// now that the SSH PIC probe that used to save it has been removed (round 14 #5).
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn save_ssh_credentials(user: &str, pass: &str) -> std::io::Result<()> {
|
pub fn save_ssh_credentials(user: &str, pass: &str) -> std::io::Result<()> {
|
||||||
save_creds_file(SSH_CREDENTIALS_FILE, user, pass)
|
save_creds_file(SSH_CREDENTIALS_FILE, user, pass)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove the saved SSH login, if any. Not an error if none was saved.
|
||||||
|
pub fn clear_ssh_credentials() -> std::io::Result<()> {
|
||||||
|
clear_creds_file(SSH_CREDENTIALS_FILE)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The SSH username to use: the saved one, or `root` (the control-board login
|
||||||
|
/// on every firmware the restore flow drives over SSH) when none was entered.
|
||||||
|
pub fn ssh_user_or_default(user: &str) -> String {
|
||||||
|
if user.trim().is_empty() {
|
||||||
|
"root".to_string()
|
||||||
|
} else {
|
||||||
|
user.trim().to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Remove the saved web/API credentials, if any. Not an error if none were saved.
|
/// Remove the saved web/API credentials, if any. Not an error if none were saved.
|
||||||
pub fn clear_credentials() -> std::io::Result<()> {
|
pub fn clear_credentials() -> std::io::Result<()> {
|
||||||
match clear_creds_file(CREDENTIALS_FILE) {
|
match clear_creds_file(CREDENTIALS_FILE) {
|
||||||
@@ -272,6 +285,28 @@ mod tests {
|
|||||||
assert_eq!(load_credentials(), None, "cleared -> None");
|
assert_eq!(load_credentials(), None, "cleared -> None");
|
||||||
clear_credentials().unwrap(); // idempotent: clearing an already-clear store is not an error
|
clear_credentials().unwrap(); // idempotent: clearing an already-clear store is not an error
|
||||||
|
|
||||||
|
// SSH login: separate file, same 0600 rule, clear is idempotent.
|
||||||
|
assert_eq!(load_ssh_credentials(), None, "no SSH file -> None");
|
||||||
|
save_ssh_credentials("root", "ssh-pass").unwrap();
|
||||||
|
assert_owner_only(
|
||||||
|
&config_path(SSH_CREDENTIALS_FILE),
|
||||||
|
"SSH creds file must be 0600",
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
load_ssh_credentials(),
|
||||||
|
Some(("root".to_string(), "ssh-pass".to_string()))
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
load_credentials(),
|
||||||
|
None,
|
||||||
|
"SSH save leaves the web login alone"
|
||||||
|
);
|
||||||
|
clear_ssh_credentials().unwrap();
|
||||||
|
assert_eq!(load_ssh_credentials(), None, "cleared -> None");
|
||||||
|
clear_ssh_credentials().unwrap();
|
||||||
|
assert_eq!(ssh_user_or_default(""), "root");
|
||||||
|
assert_eq!(ssh_user_or_default(" admin "), "admin");
|
||||||
|
|
||||||
// Per-firmware overrides (round 12 #13). Kept in this same test because
|
// Per-firmware overrides (round 12 #13). Kept in this same test because
|
||||||
// HOME is process-global: a second #[test] mutating it would race under
|
// HOME is process-global: a second #[test] mutating it would race under
|
||||||
// cargo's default parallel runner.
|
// cargo's default parallel runner.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! Bench-fleet fixtures: the expected hardware output of the 9 boards on
|
//! Fixture fleet: the expected hardware output of nine representative miners
|
||||||
//! 10.255.1.0/24 (see ../../../HANDOFF.md section 7 and the parent project's
|
//! (one per control-board family / firmware). These are the reference values
|
||||||
//! [removed]). These are the reference values the workflow tests compare
|
//! the workflow tests compare
|
||||||
//! the application's actual output against, and the rows the offline
|
//! the application's actual output against, and the rows the offline
|
||||||
//! `ALKANE_FAKE_SCAN` demo mode renders. Only miners that respond become rows,
|
//! `ALKANE_FAKE_SCAN` demo mode renders. Only miners that respond become rows,
|
||||||
//! so there is no synthetic "offline" fixture.
|
//! so there is no synthetic "offline" fixture.
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ fn restore_braiins(ip: &str, user: &str, pass: &str) -> (bool, String) {
|
|||||||
if pass.is_empty() {
|
if pass.is_empty() {
|
||||||
return (
|
return (
|
||||||
false,
|
false,
|
||||||
"Braiins restore needs an SSH password (set the SSH login)".into(),
|
"Braiins restore needs an SSH password (Credentials > SSH)".into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let target = format!("{user}@{ip}");
|
let target = format!("{user}@{ip}");
|
||||||
|
|||||||
@@ -86,7 +86,9 @@ pub fn save_scan_concurrency(n: usize) -> std::io::Result<()> {
|
|||||||
.to_string(),
|
.to_string(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
pub const DEFAULT_RANGE: &str = "10.255.1.0/24";
|
/// The usual home/site router subnet. Host bits are masked off, so this scans
|
||||||
|
/// 192.168.1.0/24.
|
||||||
|
pub const DEFAULT_RANGE: &str = "192.168.1.1/24";
|
||||||
/// Default seconds between automatic rescans.
|
/// Default seconds between automatic rescans.
|
||||||
pub const DEFAULT_AUTO_SECS: u64 = 300;
|
pub const DEFAULT_AUTO_SECS: u64 = 300;
|
||||||
|
|
||||||
@@ -2267,6 +2269,13 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn default_range_covers_the_whole_192_168_1_subnet() {
|
||||||
|
let ips = parse_line(DEFAULT_RANGE).unwrap();
|
||||||
|
let cidrs = targets_to_cidrs(&ips);
|
||||||
|
assert_eq!(cidrs, vec![(Ipv4Addr::new(192, 168, 1, 0), 24)]);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cidr_aggregation_round_trips() {
|
fn cidr_aggregation_round_trips() {
|
||||||
// a /24 must aggregate back to exactly one /24 block
|
// a /24 must aggregate back to exactly one /24 block
|
||||||
|
|||||||
@@ -770,6 +770,8 @@ pub struct App {
|
|||||||
// Credentials dialog (round 13 #2). Empty when no global credential is set.
|
// Credentials dialog (round 13 #2). Empty when no global credential is set.
|
||||||
creds_user_input: Widget,
|
creds_user_input: Widget,
|
||||||
creds_pass_input: Widget,
|
creds_pass_input: Widget,
|
||||||
|
ssh_user_input: Widget,
|
||||||
|
ssh_pass_input: Widget,
|
||||||
// The Credentials dialog (round 13 #2): the global login above plus one
|
// The Credentials dialog (round 13 #2): the global login above plus one
|
||||||
// (firmware name, user field, pass field) row per registry firmware.
|
// (firmware name, user field, pass field) row per registry firmware.
|
||||||
fwcreds_dialog: Widget,
|
fwcreds_dialog: Widget,
|
||||||
@@ -1138,6 +1140,8 @@ pub fn build(frame: Widget) -> App {
|
|||||||
header_menu_col: None,
|
header_menu_col: None,
|
||||||
creds_user_input: frame,
|
creds_user_input: frame,
|
||||||
creds_pass_input: frame,
|
creds_pass_input: frame,
|
||||||
|
ssh_user_input: frame,
|
||||||
|
ssh_pass_input: frame,
|
||||||
fwcreds_dialog: frame,
|
fwcreds_dialog: frame,
|
||||||
fwcreds_rows: Vec::new(),
|
fwcreds_rows: Vec::new(),
|
||||||
access_probe: None,
|
access_probe: None,
|
||||||
@@ -2355,6 +2359,7 @@ impl App {
|
|||||||
vnish_pass
|
vnish_pass
|
||||||
};
|
};
|
||||||
let (ssh_user, ssh_pass) = credentials::load_ssh_credentials().unwrap_or_default();
|
let (ssh_user, ssh_pass) = credentials::load_ssh_credentials().unwrap_or_default();
|
||||||
|
let ssh_user = credentials::ssh_user_or_default(&ssh_user);
|
||||||
let ips: Vec<String> = targets.iter().map(|t| t.ip.clone()).collect();
|
let ips: Vec<String> = targets.iter().map(|t| t.ip.clone()).collect();
|
||||||
self.restore_dialog.close(1);
|
self.restore_dialog.close(1);
|
||||||
crate::logs::log(format!("restore {} miner(s) to stock", ips.len()));
|
crate::logs::log(format!("restore {} miner(s) to stock", ips.len()));
|
||||||
@@ -3112,6 +3117,52 @@ impl App {
|
|||||||
);
|
);
|
||||||
self.creds_user_input = user_input;
|
self.creds_user_input = user_input;
|
||||||
self.creds_pass_input = pass_input;
|
self.creds_pass_input = pass_input;
|
||||||
|
// SSH login for the control board (Braiins restore-to-stock). Same rule
|
||||||
|
// as the global login: the password is never shown, blank keeps it.
|
||||||
|
let (ssh_user, ssh_pass) = credentials::load_ssh_credentials().unwrap_or_default();
|
||||||
|
let s_hint = if ssh_pass.is_empty() {
|
||||||
|
"SSH (restore)"
|
||||||
|
} else {
|
||||||
|
"SSH (password saved; blank keeps it)"
|
||||||
|
};
|
||||||
|
let srow = Widget::box_sizer(false);
|
||||||
|
let slabel = Widget::static_text(dlg, s_hint);
|
||||||
|
slabel.set_min_size(150, -1);
|
||||||
|
srow.add(
|
||||||
|
slabel,
|
||||||
|
0,
|
||||||
|
sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT,
|
||||||
|
6,
|
||||||
|
);
|
||||||
|
let ssh_user_input = Widget::text_ctrl(dlg, false);
|
||||||
|
ssh_user_input.set_min_size(150, -1);
|
||||||
|
ssh_user_input.set_value(if ssh_user.is_empty() {
|
||||||
|
"root"
|
||||||
|
} else {
|
||||||
|
&ssh_user
|
||||||
|
});
|
||||||
|
srow.add(
|
||||||
|
ssh_user_input,
|
||||||
|
0,
|
||||||
|
sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT,
|
||||||
|
6,
|
||||||
|
);
|
||||||
|
let ssh_pass_input = Widget::password_ctrl(dlg);
|
||||||
|
ssh_pass_input.set_min_size(150, -1);
|
||||||
|
srow.add(
|
||||||
|
ssh_pass_input,
|
||||||
|
1,
|
||||||
|
sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT,
|
||||||
|
6,
|
||||||
|
);
|
||||||
|
root.add_sizer(
|
||||||
|
srow,
|
||||||
|
0,
|
||||||
|
sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP,
|
||||||
|
6,
|
||||||
|
);
|
||||||
|
self.ssh_user_input = ssh_user_input;
|
||||||
|
self.ssh_pass_input = ssh_pass_input;
|
||||||
// Column headers.
|
// Column headers.
|
||||||
let head = Widget::box_sizer(false);
|
let head = Widget::box_sizer(false);
|
||||||
let h_fw = Widget::static_text(dlg, "Firmware");
|
let h_fw = Widget::static_text(dlg, "Firmware");
|
||||||
@@ -3223,6 +3274,21 @@ impl App {
|
|||||||
wx_rs::set_status_text(&format!("failed to save global login: {e}"));
|
wx_rs::set_status_text(&format!("failed to save global login: {e}"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// SSH login: a blank password keeps the saved one; with nothing saved
|
||||||
|
// and no password entered there is nothing to store.
|
||||||
|
let s_user = credentials::ssh_user_or_default(&self.ssh_user_input.get_value());
|
||||||
|
let s_pass = self.ssh_pass_input.get_value();
|
||||||
|
let ssh_result = if !s_pass.is_empty() {
|
||||||
|
credentials::save_ssh_credentials(&s_user, &s_pass)
|
||||||
|
} else if let Some((_, saved)) = credentials::load_ssh_credentials() {
|
||||||
|
credentials::save_ssh_credentials(&s_user, &saved)
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
};
|
||||||
|
if let Err(e) = ssh_result {
|
||||||
|
wx_rs::set_status_text(&format!("failed to save SSH login: {e}"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Per-firmware overrides.
|
// Per-firmware overrides.
|
||||||
let mut map: std::collections::HashMap<String, (String, String)> =
|
let mut map: std::collections::HashMap<String, (String, String)> =
|
||||||
std::collections::HashMap::new();
|
std::collections::HashMap::new();
|
||||||
@@ -3259,6 +3325,8 @@ impl App {
|
|||||||
fn apply_firmware_creds_reset(&mut self) {
|
fn apply_firmware_creds_reset(&mut self) {
|
||||||
self.creds_user_input.set_value("");
|
self.creds_user_input.set_value("");
|
||||||
self.creds_pass_input.set_value("");
|
self.creds_pass_input.set_value("");
|
||||||
|
self.ssh_user_input.set_value("root");
|
||||||
|
self.ssh_pass_input.set_value("");
|
||||||
for (name, user_ctrl, pass_ctrl) in &self.fwcreds_rows {
|
for (name, user_ctrl, pass_ctrl) in &self.fwcreds_rows {
|
||||||
let (user, pass) = credentials::firmware_default_for(name);
|
let (user, pass) = credentials::firmware_default_for(name);
|
||||||
user_ctrl.set_value(&user);
|
user_ctrl.set_value(&user);
|
||||||
@@ -3266,7 +3334,8 @@ impl App {
|
|||||||
}
|
}
|
||||||
let per_fw = credentials::clear_firmware_credentials();
|
let per_fw = credentials::clear_firmware_credentials();
|
||||||
let global = credentials::clear_credentials();
|
let global = credentials::clear_credentials();
|
||||||
match per_fw.and(global) {
|
let ssh = credentials::clear_ssh_credentials();
|
||||||
|
match per_fw.and(global).and(ssh) {
|
||||||
Ok(()) => wx_rs::set_status_text("credentials reset to defaults"),
|
Ok(()) => wx_rs::set_status_text("credentials reset to defaults"),
|
||||||
Err(e) => wx_rs::set_status_text(&format!("failed to reset credentials: {e}")),
|
Err(e) => wx_rs::set_status_text(&format!("failed to reset credentials: {e}")),
|
||||||
}
|
}
|
||||||
@@ -3878,7 +3947,7 @@ impl App {
|
|||||||
let edit = Widget::text_ctrl(dlg, true);
|
let edit = Widget::text_ctrl(dlg, true);
|
||||||
edit.set_value(&scan::load_ranges().join("\n"));
|
edit.set_value(&scan::load_ranges().join("\n"));
|
||||||
edit.set_tool_tip(
|
edit.set_tool_tip(
|
||||||
"One range per line:\n CIDR 10.255.1.0/24\n range 10.253.1.3-10.253.1.234\n single 10.253.1.5",
|
"One range per line:\n CIDR 192.168.1.0/24\n range 192.168.1.3-192.168.1.234\n single 192.168.1.5",
|
||||||
);
|
);
|
||||||
root.add(edit, 1, sf::EXPAND | sf::BORDER_ALL, 6);
|
root.add(edit, 1, sf::EXPAND | sf::BORDER_ALL, 6);
|
||||||
// Auto-rescan interval (seconds; 0 = off) and per-miner scan timeout.
|
// Auto-rescan interval (seconds; 0 = off) and per-miner scan timeout.
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "040904B0"
|
BLOCK "040904B0"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "Blueflare"
|
VALUE "CompanyName", "BlueFlare Energy Solutions Inc."
|
||||||
VALUE "FileDescription", "Alkane Toolkit"
|
VALUE "FileDescription", "Alkane Toolkit"
|
||||||
VALUE "FileVersion", ALKANE_VER_STR
|
VALUE "FileVersion", ALKANE_VER_STR
|
||||||
VALUE "InternalName", "alkane-toolkit"
|
VALUE "InternalName", "alkane-toolkit"
|
||||||
VALUE "LegalCopyright", "Copyright (c) 2026 Blueflare (MIT License)"
|
VALUE "LegalCopyright", "Copyright (c) 2026 BlueFlare Energy Solutions Inc. (MIT License)"
|
||||||
VALUE "OriginalFilename", "alkane-toolkit.exe"
|
VALUE "OriginalFilename", "alkane-toolkit.exe"
|
||||||
VALUE "ProductName", "Alkane Toolkit"
|
VALUE "ProductName", "Alkane Toolkit"
|
||||||
VALUE "ProductVersion", ALKANE_VER_STR
|
VALUE "ProductVersion", ALKANE_VER_STR
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
# macOS
|
||||||
|
|
||||||
|
The macOS build is one universal app, `Alkane Toolkit.app`, that runs natively
|
||||||
|
on Apple Silicon and Intel Macs with macOS 11 (Big Sur) or later. It ships as
|
||||||
|
`alkane-toolkit-vX.Y.Z-macos-universal.zip`, holding the app, `LICENSE` and a
|
||||||
|
`README.txt`.
|
||||||
|
|
||||||
|
## Using it
|
||||||
|
|
||||||
|
- Settings live in `~/.config/alkane-toolkit`, the same files as on Linux.
|
||||||
|
- SSH actions use the system `ssh`; HTTP actions use the system `curl`.
|
||||||
|
- The app is ad-hoc signed but not notarized, so macOS blocks the first launch.
|
||||||
|
On macOS 15 or later, try to open it, then choose **Open Anyway** in
|
||||||
|
System Settings > Privacy & Security. On macOS 11 to 14, Control-click the
|
||||||
|
app and choose **Open**. Or clear the quarantine flag once:
|
||||||
|
`xattr -dr com.apple.quarantine "/Applications/Alkane Toolkit.app"`.
|
||||||
|
- The first scan asks for permission to find devices on the local network
|
||||||
|
(macOS 15 and later). Scanning needs it.
|
||||||
|
- Offline demo: `ALKANE_FAKE_SCAN=1 "/Applications/Alkane Toolkit.app/Contents/MacOS/alkane-toolkit"`.
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
macOS builds only on a Mac. It needs the Xcode Command Line Tools
|
||||||
|
(`xcode-select --install`) and rustup with both Apple targets:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
rustup target add aarch64-apple-darwin x86_64-apple-darwin
|
||||||
|
scripts/build-wx-macos.sh # once: universal static wxOSX 3.3.3 in ~/.cache/wx-3.3.3-macos
|
||||||
|
scripts/build-gui-macos.sh # both slices, merged with lipo
|
||||||
|
python3 ci/package-macos.py X.Y.Z target/universal-apple-darwin/release/alkane-toolkit dist
|
||||||
|
```
|
||||||
|
|
||||||
|
`build-wx-macos.sh` builds wxWidgets once for arm64 and x86_64 together, with
|
||||||
|
wx's bundled image, zlib, regex and expat libraries, so the app links only
|
||||||
|
against system frameworks. `build-gui-macos.sh` builds each Rust target
|
||||||
|
against that prefix and merges them. `package-macos.py` writes the bundle
|
||||||
|
(Info.plist, icon), ad-hoc signs it and zips it with `ditto`.
|
||||||
|
|
||||||
|
To test on the Mac:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ALKANE_SELFTEST=1 target/universal-apple-darwin/release/alkane-toolkit # headless UI self-test
|
||||||
|
cargo test --release --offline --target aarch64-apple-darwin --workspace --exclude wx-rs
|
||||||
|
```
|
||||||
|
|
||||||
|
The self-test opens a window briefly, so it needs a logged-in desktop
|
||||||
|
session. Running the x86_64 slice on Apple Silicon needs Rosetta 2.
|
||||||
|
|
||||||
|
## Why macOS 11
|
||||||
|
|
||||||
|
Current Xcode SDKs ship a libc++ that supports macOS 11 and later only;
|
||||||
|
building for an older target compiles, but the app could fail at run time on
|
||||||
|
the older system. macOS 11 is also the first release for Apple Silicon. Older
|
||||||
|
Intel Macs would need a build with an older SDK.
|
||||||
|
|
||||||
|
## Notes for the bridge
|
||||||
|
|
||||||
|
wxOSX reports logical (point) sizes, like the GTK and MSW bridges; the
|
||||||
|
bridge never scales to physical pixels. wxOSX's Objective-C uses
|
||||||
|
`@available`, so `build.rs` links clang's compiler runtime
|
||||||
|
(`libclang_rt.osx.a`), which rustc's link does not include by itself. Both
|
||||||
|
are wx-rs patch `0009`.
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
# Getting started
|
||||||
|
|
||||||
|
Alkane Toolkit finds the ASIC miners on your network and shows them in one
|
||||||
|
table: model, firmware, hashrate, power, temperatures, fans and the health of
|
||||||
|
every hashboard. From the same table you can run the controls each miner's
|
||||||
|
firmware supports, such as pausing, restarting or changing pools.
|
||||||
|
|
||||||
|
## Download
|
||||||
|
|
||||||
|
Get the latest release from the
|
||||||
|
[downloads page](https://gitea.bluefla.re/blueflare/alkane-toolkit/releases).
|
||||||
|
|
||||||
|
| Platform | File | Notes |
|
||||||
|
|---|---|---|
|
||||||
|
| Windows 10 and 11 (x86_64) | `alkane-toolkit-vX.Y.Z-windows-x86_64.zip` | One signed `alkane-toolkit.exe`; nothing to install |
|
||||||
|
| Linux (x86_64) | `alkane-toolkit-vX.Y.Z-linux-x86_64.tar.gz` | One binary; needs GTK 3 (`sudo apt install libgtk-3-0`) |
|
||||||
|
| macOS 11 or later (Apple Silicon and Intel) | `alkane-toolkit-vX.Y.Z-macos-universal.zip` | One app; not notarized, so confirm the first launch |
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
1. Download the zip, right-click it, choose **Properties**, tick **Unblock** if
|
||||||
|
it is shown, then extract it.
|
||||||
|
2. Run `alkane-toolkit.exe`. Windows shows *BlueFlare Energy Solutions Inc.* as
|
||||||
|
the verified publisher. To check the signature yourself, right-click the exe,
|
||||||
|
choose **Properties** and open **Digital Signatures**.
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
|
||||||
|
1. Download the zip and open it; drag **Alkane Toolkit** to Applications.
|
||||||
|
2. Open it. The app is not notarized, so macOS blocks the first launch:
|
||||||
|
- macOS 15 or later: open **System Settings > Privacy & Security** and
|
||||||
|
choose **Open Anyway** for Alkane Toolkit.
|
||||||
|
- macOS 11 to 14: Control-click the app, choose **Open**, then **Open**.
|
||||||
|
3. When asked, allow it to find devices on your local network. Scanning
|
||||||
|
needs this.
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
```sh
|
||||||
|
tar xzf alkane-toolkit-vX.Y.Z-linux-x86_64.tar.gz
|
||||||
|
./alkane-toolkit-vX.Y.Z-linux-x86_64/alkane-toolkit
|
||||||
|
```
|
||||||
|
|
||||||
|
## First run
|
||||||
|
|
||||||
|
The toolkit starts a scan as soon as it opens. Set your own ranges first with
|
||||||
|
**Scan ranges** (see [Scanning](02-scanning.md)); until you do, it scans
|
||||||
|
192.168.1.0/24, the usual router subnet.
|
||||||
|
|
||||||
|
To look around without touching any miner, start it in demo mode. It shows a
|
||||||
|
built-in sample fleet and simulates every action:
|
||||||
|
|
||||||
|
| Platform | Command |
|
||||||
|
|---|---|
|
||||||
|
| Windows (Command Prompt) | `set ALKANE_FAKE_SCAN=1 && alkane-toolkit.exe` |
|
||||||
|
| Linux | `ALKANE_FAKE_SCAN=1 ./alkane-toolkit` |
|
||||||
|
|
||||||
|
## Where settings are kept
|
||||||
|
|
||||||
|
| Platform | Folder |
|
||||||
|
|---|---|
|
||||||
|
| Windows | `%APPDATA%\alkane-toolkit` |
|
||||||
|
| Linux | `~/.config/alkane-toolkit` |
|
||||||
|
|
||||||
|
See [Settings and credentials](06-settings.md) for the files in that folder.
|
||||||
|
Deleting the folder resets the toolkit to its defaults.
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# Scanning
|
||||||
|
|
||||||
|
Discovery is read-only: a scan asks each address what it is and records what
|
||||||
|
it reports. It never changes a miner.
|
||||||
|
|
||||||
|
## Scan ranges
|
||||||
|
|
||||||
|
Click **Scan ranges** to edit the addresses to scan. Put one entry per line;
|
||||||
|
blank lines and lines starting with `#` are ignored.
|
||||||
|
|
||||||
|
| Form | Example | Scans |
|
||||||
|
|---|---|---|
|
||||||
|
| Single address | `192.168.1.50` | that address |
|
||||||
|
| CIDR block | `192.168.1.0/24` | the whole block |
|
||||||
|
| Full range | `192.168.1.10-192.168.2.40` | every address between the two, inclusive |
|
||||||
|
| Short range | `192.168.1.10-90` | `.10` to `.90` within the same /24 |
|
||||||
|
| Per-octet ranges | `10.1-4.0-1.1-255` | every combination (10.1.0.1 ... 10.4.1.255) |
|
||||||
|
|
||||||
|
Commas or spaces between several entries on one line are not accepted; use one
|
||||||
|
line each. Duplicates are removed automatically. One line, and all lines
|
||||||
|
together, may cover at most 1,000,000 addresses.
|
||||||
|
|
||||||
|
**Apply** saves the ranges and starts a scan. A mistake keeps the dialog open
|
||||||
|
and the status bar explains it, for example `invalid range: bad octet range`.
|
||||||
|
|
||||||
|
The same dialog has three numbers:
|
||||||
|
|
||||||
|
| Field | Meaning | Default |
|
||||||
|
|---|---|---|
|
||||||
|
| Rescan (s) | seconds between automatic rescans; `0` turns auto-rescan off | 300 |
|
||||||
|
| Timeout (s) | how long to wait for one miner (scans, refreshes, actions and log fetches) | 10 |
|
||||||
|
| Concurrency | how many addresses are probed at once (8 to 256); higher is faster but slow miners may report fewer values | 128 |
|
||||||
|
|
||||||
|
When the ranges change, miners outside the new ranges leave the table at the
|
||||||
|
next scan.
|
||||||
|
|
||||||
|
## Running, pausing and stopping
|
||||||
|
|
||||||
|
The three buttons next to **Scan ranges** control scanning:
|
||||||
|
|
||||||
|
- **Play** (green) turns auto-rescan on and starts a scan now if none is running.
|
||||||
|
- **Pause** (amber) turns auto-rescan off and lets the current scan finish.
|
||||||
|
- **Stop** (red) turns auto-rescan off and cancels the current scan.
|
||||||
|
|
||||||
|
While a scan runs, a progress bar spans the top of the table and the status bar
|
||||||
|
shows progress such as `1935/4590 - scanning 192.168.1.86 (92 found)`. Afterwards
|
||||||
|
it shows the count and the time to the next scan, for example
|
||||||
|
`245 miners - next scan in 4m 12s`.
|
||||||
|
|
||||||
|
Actions that change miners wait for the scan to finish; see
|
||||||
|
[Actions](05-actions.md).
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
# The table and header
|
||||||
|
|
||||||
|
## Summary cards
|
||||||
|
|
||||||
|
The cards at the top count the miners **currently shown** (after any filter).
|
||||||
|
Each miner is in exactly one status: slow, paused, hashing or not hashing.
|
||||||
|
|
||||||
|
| Card | Counts | Click |
|
||||||
|
|---|---|---|
|
||||||
|
| Total | rows in the view | - |
|
||||||
|
| Hashing (green rabbit) | mining at 80% of expected hashrate or more | show only these; click again to clear |
|
||||||
|
| Slow (amber turtle) | mining below 80% of expected hashrate | show only these |
|
||||||
|
| Not hashing (red glass) | answering but not mining | show only these |
|
||||||
|
| Paused (blue otter) | stopped on purpose (paused, stopped, suspended) | show only these |
|
||||||
|
| SHA-256 Hashrate | total hashrate, per algorithm | switch algorithm when the fleet runs more than one |
|
||||||
|
| Est. power | total reported power draw | - |
|
||||||
|
|
||||||
|
On a narrow window the hashrate and power cards are hidden.
|
||||||
|
|
||||||
|
## Columns
|
||||||
|
|
||||||
|
IP is always the first column. The default view shows Model, Health,
|
||||||
|
Hashrate, Power, Chip temp, Firmware, CPU, Access and Light. More than seventy
|
||||||
|
other columns are available, grouped as Identity, Firmware and board, Health
|
||||||
|
and status, Performance, Temperature, Cooling, Hardware and Pools.
|
||||||
|
|
||||||
|
- **Columns** opens a checklist: tick to show, drag to reorder, or sort the list
|
||||||
|
alphabetically or by category. *Hide columns with no scanned values* hides
|
||||||
|
columns that are empty for every miner (it resets when the app restarts).
|
||||||
|
- Drag a column header to move it.
|
||||||
|
- Right-click a header to sort by it, auto-size one or all columns, hide it, or
|
||||||
|
open the column chooser.
|
||||||
|
|
||||||
|
Some values worth knowing:
|
||||||
|
|
||||||
|
| Column | Shows |
|
||||||
|
|---|---|
|
||||||
|
| Hashrate | actual/expected, for example `95.0T/96.0T`; the actual part is red at 50% of expected or less, amber around 75%, green at 100% |
|
||||||
|
| Chip temp | hottest chip on each hashboard, for example `77 / 64 / 74`; blue when cool, red at 90 C and above |
|
||||||
|
| Firmware | the firmware family, coloured (Braiins purple, LuxOS gold, VNish green, ePIC light blue, Hiveon orange, Bixbit pink); stock firmware uses the normal text colour |
|
||||||
|
| Pool account / Worker | the pool user split at the first dot |
|
||||||
|
| Board HR / V / freq | per-hashboard hashrate, voltage and frequency |
|
||||||
|
|
||||||
|
A blank cell means the miner did not report that value.
|
||||||
|
|
||||||
|
## Sorting
|
||||||
|
|
||||||
|
Click a header to sort ascending, again for descending, again to clear.
|
||||||
|
|
||||||
|
- **Hashrate** also sorts by *relative* hashrate (actual as a share of
|
||||||
|
expected), shown as `%^` and `%v` in the header.
|
||||||
|
- **Health** sorts by overall health, then by power (`Pwr`), fans (`Fan`) and
|
||||||
|
hashboards (`Brd`). Ascending puts the most broken miners first.
|
||||||
|
|
||||||
|
## Selecting miners
|
||||||
|
|
||||||
|
Click a row to select it; Ctrl-click and Shift-click add to the selection, and
|
||||||
|
you can drag across rows to select a block. The selection follows miners by IP,
|
||||||
|
so it survives rescans. Double-click a row (or press Enter) to open the miner's
|
||||||
|
web page in your browser. Right-click the selection for [actions](05-actions.md).
|
||||||
|
|
||||||
|
## Filters and presets
|
||||||
|
|
||||||
|
**Filter** keeps only the rows that match. Pick a column, then:
|
||||||
|
|
||||||
|
- for numbers: between, =, !=, >, >=, < or <= (blank cells never match);
|
||||||
|
- for text: *is any of* (tick values; `(blank)` matches empty cells), contains,
|
||||||
|
does not contain, begins with, ends with or equals (case does not matter).
|
||||||
|
|
||||||
|
Filters on different columns must all match. **Reset** clears them. Clicking a
|
||||||
|
status card is a quick filter of its own.
|
||||||
|
|
||||||
|
**Presets** saves and loads whole views: column order and visibility, sort and
|
||||||
|
filters. *Default* is built in and cannot be deleted; saving under an existing
|
||||||
|
name replaces it.
|
||||||
|
|
||||||
|
## Zoom and theme
|
||||||
|
|
||||||
|
The slider in the bottom-right corner zooms the table: text, icons and column
|
||||||
|
widths scale together. The window follows the system light or dark theme.
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# Health, access and light
|
||||||
|
|
||||||
|
## The Health column
|
||||||
|
|
||||||
|
Each miner gets a row of icons, always in the same order, so problems line up
|
||||||
|
across the table:
|
||||||
|
|
||||||
|
1. **Bolt**: the power supply
|
||||||
|
2. **Brain**: the control board
|
||||||
|
3. **Fan**: one icon per fan
|
||||||
|
4. **Chip**: one icon per hashboard
|
||||||
|
|
||||||
|
Hover over any icon to see its details: PSU voltage and current, the fan speed,
|
||||||
|
or a hashboard's actual and expected hashrate, frequency and voltage, and any
|
||||||
|
fault message with its code.
|
||||||
|
|
||||||
|
| Colour | Meaning |
|
||||||
|
|---|---|
|
||||||
|
| Green | healthy |
|
||||||
|
| Amber | working but below par (a slow board, a fan well below the others, a PSU fault while still mining) |
|
||||||
|
| Red | detected but down (a faulted board, a stopped fan, a PSU that is not delivering) |
|
||||||
|
| Grey | expected but not detected or not reachable |
|
||||||
|
| Blue | the miner is paused, so its boards and stopped fans are idle on purpose |
|
||||||
|
|
||||||
|
How each part is judged:
|
||||||
|
|
||||||
|
- **Power** is green when the miner draws power, its PSU fan turns or it is
|
||||||
|
mining; a reported PSU fault makes it amber (still mining) or red.
|
||||||
|
- **Control board** is red for a control-board fault and amber for a
|
||||||
|
miner-wide warning such as a high ambient temperature.
|
||||||
|
- **Fans** are red at 0 rpm and amber below half the speed of the fastest fan.
|
||||||
|
- **Hashboards** follow the status the miner reports for each board. When the
|
||||||
|
firmware names the failing boards, only those turn red. A board the miner
|
||||||
|
cannot see is grey.
|
||||||
|
|
||||||
|
While an action runs on a miner, its Health cell shows progress such as
|
||||||
|
`restarting...` or `refreshing...`.
|
||||||
|
|
||||||
|
## Access
|
||||||
|
|
||||||
|
The padlock shows whether the toolkit can change the miner:
|
||||||
|
|
||||||
|
- **green, open**: changes are possible with the saved credentials;
|
||||||
|
- **red, closed**: view only;
|
||||||
|
- **blank**: not known yet.
|
||||||
|
|
||||||
|
After a scan the padlock is an estimate from what the firmware offers. Use
|
||||||
|
**Check access (auth)** in the right-click menu for a real, read-only login
|
||||||
|
test.
|
||||||
|
|
||||||
|
## Light
|
||||||
|
|
||||||
|
A flashing green-over-red dot means the miner's locate light is on. Turn it on
|
||||||
|
or off with **Flash lights** / **Stop flashing lights**.
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# Actions
|
||||||
|
|
||||||
|
Right-click one or more selected miners for the actions menu. With several
|
||||||
|
miners selected, labels show the count, for example *Restart (12)*. An action
|
||||||
|
appears only when **every** selected miner's firmware supports it, so the menu
|
||||||
|
changes with the selection.
|
||||||
|
|
||||||
|
| Action | What it does | Changes the miner |
|
||||||
|
|---|---|---|
|
||||||
|
| Open in browser | opens each miner's web page | no |
|
||||||
|
| Refresh | re-reads just these miners | no |
|
||||||
|
| Check access (auth) | tests whether the saved login is accepted | no |
|
||||||
|
| View log (API)... | shows the first selected miner's log (WhatsMiner: its active fault codes) | no |
|
||||||
|
| Restore to stock firmware... | removes aftermarket firmware; see [Restore to stock](07-restore.md) | yes, reboots |
|
||||||
|
| Flash lights / Stop flashing lights | locate light on or off | yes, harmless |
|
||||||
|
| Pause mining / Resume mining | stop or start hashing | yes |
|
||||||
|
| Set tuning %... | tuning level, 0 to 100 | yes |
|
||||||
|
| Set power target... | power target in watts; the prompt shows the current value and the allowed range | yes |
|
||||||
|
| Set hashrate target... | hashrate target in TH/s, for firmware that tunes by hashrate | yes |
|
||||||
|
| Set profile... | pick a firmware profile or preset (only profiles every selected miner has are listed) | yes |
|
||||||
|
| Restart | reboot | yes |
|
||||||
|
| Configure pools... | set up to three pools | yes |
|
||||||
|
| Set timezone... | IANA time zone, for example `America/Edmonton` | yes |
|
||||||
|
| Change password... | new web/API password | yes |
|
||||||
|
| Factory reset... | wipes pools, tuning and network settings and reboots; the miner may come back on a new DHCP address | yes, destructive |
|
||||||
|
|
||||||
|
## Safety
|
||||||
|
|
||||||
|
- Pause, Resume, Restart and Factory reset ask for confirmation. Value prompts
|
||||||
|
(tuning, targets, timezone, password) apply when you confirm the value.
|
||||||
|
- Actions that change miners do not start while a scan is running, including an
|
||||||
|
automatic rescan. Wait for it to finish or press **Pause**. Scans in turn wait
|
||||||
|
for running actions.
|
||||||
|
- Each changed miner is re-read automatically when the action finishes. Results
|
||||||
|
and failures appear in the bottom-right corner of the status bar and in
|
||||||
|
**Settings > Logs**.
|
||||||
|
- If **Change password** succeeds on every selected miner, the saved global
|
||||||
|
login is updated to the new password. If only some succeed, the saved login
|
||||||
|
is left alone and the log says so.
|
||||||
|
|
||||||
|
## Configuring pools
|
||||||
|
|
||||||
|
The pool dialog has three rows: Address, Account, Worker and Password. A row is
|
||||||
|
used only when it has an address and an account. A blank password becomes `x`.
|
||||||
|
The miner's username becomes `account.worker`.
|
||||||
|
|
||||||
|
Each field has a **+** menu with common pool addresses and the values you saved
|
||||||
|
before (**Add new...** edits that list). Worker names can use placeholders that
|
||||||
|
are filled in per miner:
|
||||||
|
|
||||||
|
| Placeholder | Becomes |
|
||||||
|
|---|---|
|
||||||
|
| `{ip1}` to `{ip4}` | one octet of the miner's IP |
|
||||||
|
| `{serial}`, `{mac}` | serial number; MAC without colons |
|
||||||
|
| `{hostname}` | the miner's hostname |
|
||||||
|
| `{brand}`, `{model}`, `{submodel}` | make and model |
|
||||||
|
| `{firmware}`, `{cpu}`, `{cb}` | firmware family, control-board CPU and board |
|
||||||
|
| `{nameplate-hr}` | the model's rated hashrate |
|
||||||
|
|
||||||
|
For example, `rack3-{ip3}-{ip4}` gives `rack3-1-50` for `10.0.1.50`.
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
# Settings and credentials
|
||||||
|
|
||||||
|
**Settings** opens a menu with Credentials, Language and Logs.
|
||||||
|
|
||||||
|
## Credentials
|
||||||
|
|
||||||
|
Miners need a login for anything beyond basic discovery: for some details, and
|
||||||
|
for every action. The Credentials dialog has three parts:
|
||||||
|
|
||||||
|
- **All firmwares** at the top: one username and password tried on every miner.
|
||||||
|
The saved password is never shown; leave the field blank to keep it. Blank
|
||||||
|
username and password clear it.
|
||||||
|
- **SSH (restore)**: the control-board SSH login used to restore Braiins OS to
|
||||||
|
stock (see [SSH login](#ssh-login)).
|
||||||
|
- **One row per firmware**, pre-filled with that firmware's factory default.
|
||||||
|
Change a row to override the login for that firmware only.
|
||||||
|
|
||||||
|
The toolkit tries, in order, the firmware's own row, then the global login,
|
||||||
|
then the firmware's built-in default.
|
||||||
|
|
||||||
|
| Firmware | Factory default (user / password) |
|
||||||
|
|---|---|
|
||||||
|
| AntMiner Stock | root / root |
|
||||||
|
| WhatsMiner Stock | admin / admin |
|
||||||
|
| Braiins | root / root |
|
||||||
|
| VNish | (none) / admin |
|
||||||
|
| LuxOS | root / root |
|
||||||
|
| UMC OS | (none) / letmein |
|
||||||
|
| Marathon | root / root |
|
||||||
|
| VolcMiner Stock | root / ltc@dog |
|
||||||
|
| Elphapex Stock | root / root |
|
||||||
|
| FutureBit Stock | futurebit / futurebit123 |
|
||||||
|
| SealMiner Stock | seal / seal |
|
||||||
|
| Auradine Stock | admin / admin |
|
||||||
|
|
||||||
|
**Reset to defaults** clears every override, the global login and the SSH
|
||||||
|
login at once.
|
||||||
|
|
||||||
|
Logins are stored as plain text in the settings folder, readable only by your
|
||||||
|
user account (Linux file mode 0600; on Windows, your profile folder's
|
||||||
|
permissions).
|
||||||
|
|
||||||
|
### SSH login
|
||||||
|
|
||||||
|
Restoring Braiins to stock runs a command over SSH, using the system `ssh`
|
||||||
|
client (built into Windows 10/11). Set its login in the **SSH (restore)** row
|
||||||
|
of the Credentials dialog. The username defaults to `root`. As with the global
|
||||||
|
login, the saved password is never shown and a blank password keeps it.
|
||||||
|
|
||||||
|
## Language
|
||||||
|
|
||||||
|
English, Chinese, Russian, French, Spanish and Portuguese. The toolbar, cards
|
||||||
|
and column headers switch immediately; menus and dialogs not yet translated
|
||||||
|
stay in English.
|
||||||
|
|
||||||
|
## Logs
|
||||||
|
|
||||||
|
An activity log of scans, actions, errors and exports, newest last, kept for
|
||||||
|
the current session (the last 2000 lines). Times are shown in UTC.
|
||||||
|
|
||||||
|
## Files in the settings folder
|
||||||
|
|
||||||
|
| File | Holds |
|
||||||
|
|---|---|
|
||||||
|
| `scan-ranges.txt` | scan ranges, one per line |
|
||||||
|
| `auto-rescan-secs.txt`, `scan-timeout-secs.txt`, `scan-concurrency.txt` | the three scan numbers |
|
||||||
|
| `scan-credentials.txt` | global login |
|
||||||
|
| `firmware-credentials.txt` | per-firmware logins |
|
||||||
|
| `ssh-credentials.txt` | SSH login |
|
||||||
|
| `presets.json` | saved views |
|
||||||
|
| `language.txt` | UI language |
|
||||||
|
| `pool-addresses.txt`, `pool-accounts.txt`, `pool-workers.txt`, `pool-passwords.txt` | saved pool values |
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Restore to stock firmware
|
||||||
|
|
||||||
|
**Restore to stock firmware...** removes aftermarket firmware and returns the
|
||||||
|
miner to the manufacturer's firmware it keeps on board. Nothing is uploaded.
|
||||||
|
The miner reboots, and some firmwares come back on a new address.
|
||||||
|
|
||||||
|
It is offered when the selection includes a supported firmware, and asks for
|
||||||
|
confirmation with the list of miners first.
|
||||||
|
|
||||||
|
| Firmware | How it is removed | Login used |
|
||||||
|
|---|---|---|
|
||||||
|
| VNish (and builds based on it) | web API: unlock, then remove firmware; reboots in seconds | the VNish row in Credentials, else `admin` |
|
||||||
|
| LuxOS | miner API: log on, then uninstall | none |
|
||||||
|
| Braiins OS | SSH: runs the firmware's own `uninstall.sh` | the SSH row in Credentials (see [Settings](06-settings.md#ssh-login)) |
|
||||||
|
|
||||||
|
Miners are restored one at a time. A dropped connection after the command is
|
||||||
|
sent counts as success, because that is the reboot. A refused login counts as
|
||||||
|
a failure and leaves the miner unchanged.
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Export
|
||||||
|
|
||||||
|
**Export** saves the scan as a CSV file for spreadsheets or other tools.
|
||||||
|
|
||||||
|
1. Choose the fields to include (all are ticked by default; **All** and
|
||||||
|
**None** help).
|
||||||
|
2. Pick where to save. The suggested name is `alkane-export-YYYYMMDD-HHMMSS.csv`.
|
||||||
|
|
||||||
|
The export contains **every scanned miner**, not just the rows the current
|
||||||
|
filter shows. Per-board temperatures, fan speeds, board status and pools
|
||||||
|
become numbered columns (`board_temp_1_c`, `fan_2_rpm`, `pool_1_url`, ...).
|
||||||
|
|
||||||
|
Values that start with `=`, `+`, `-` or `@` are prefixed with `'` so a
|
||||||
|
spreadsheet treats them as text, not formulas.
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Command line and environment
|
||||||
|
|
||||||
|
## Environment variables
|
||||||
|
|
||||||
|
| Variable | Effect |
|
||||||
|
|---|---|
|
||||||
|
| `ALKANE_FAKE_SCAN=1` | demo mode: a built-in sample fleet, no network traffic, simulated actions |
|
||||||
|
| `ALKANE_APPEARANCE=light` or `dark` | force the light or dark theme |
|
||||||
|
| `ALKANE_SELFTEST=1` | run the built-in UI self-test on the sample fleet and exit (prints `SELFTEST PASS` or `FAIL`) |
|
||||||
|
| `ALKANE_ACCESS_PROBE="<ip> <make>"` | print whether the saved login can change that miner, then exit |
|
||||||
|
| `ALKANE_LOG_SCAN="<ip> <brand>"` | fetch that miner's log through its API, print the size, then exit |
|
||||||
|
|
||||||
|
On Windows these one-shot modes print to the Command Prompt they are started
|
||||||
|
from.
|
||||||
|
|
||||||
|
## miner_probe
|
||||||
|
|
||||||
|
`miner_probe` is a command-line companion for scripting and diagnosis. These
|
||||||
|
commands only read:
|
||||||
|
|
||||||
|
| Command | Prints |
|
||||||
|
|---|---|
|
||||||
|
| `miner_probe scan <cidr> [<cidr>...]` | discovered miners and their telemetry, as tab-separated values |
|
||||||
|
| `miner_probe hashrate <cidr>...` | raw hashrate and algorithm |
|
||||||
|
| `miner_probe msgs <ip>` | fault messages and per-board data |
|
||||||
|
| `miner_probe tune <ip>` | tuning support and limits |
|
||||||
|
| `miner_probe presets <ip>` | available firmware profiles |
|
||||||
|
| `miner_probe timezone <ip>` | the current time zone |
|
||||||
|
|
||||||
|
Its other commands change miners. It uses the global login from the settings
|
||||||
|
folder, or `ALKANE_PROBE_USER` and `ALKANE_PROBE_PASS`, and
|
||||||
|
`ALKANE_PROBE_CONCURRENCY` (default 128).
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Troubleshooting
|
||||||
|
|
||||||
|
**Windows says "Windows protected your PC".** SmartScreen warns about new
|
||||||
|
downloads until a certificate has built up reputation. The publisher shown
|
||||||
|
should be *BlueFlare Energy Solutions Inc.*; click **More info**, then **Run
|
||||||
|
anyway**. If no publisher is shown, do not run the file and download it again
|
||||||
|
from the releases page.
|
||||||
|
|
||||||
|
**A miner is missing.** Check that its address is inside the scan ranges and
|
||||||
|
that it answers on its web page from this computer. On busy or slow networks,
|
||||||
|
raise **Timeout** or lower **Concurrency** in the Scan ranges dialog.
|
||||||
|
|
||||||
|
**An action is missing from the right-click menu.** Actions appear only when
|
||||||
|
every selected miner supports them. Select fewer miners, or only miners with
|
||||||
|
the same firmware.
|
||||||
|
|
||||||
|
**An action does nothing and the status says a scan is in progress.** Changes
|
||||||
|
wait for scans. Press **Pause**, let the scan finish, then try again.
|
||||||
|
|
||||||
|
**Check access says locked.** The saved login is not accepted. Set the right
|
||||||
|
password in **Settings > Credentials**, either for all firmwares or for that
|
||||||
|
firmware's row.
|
||||||
|
|
||||||
|
**Values are blank.** The firmware did not report them, or it needs a login to
|
||||||
|
report them. Try **Check access** and the Credentials dialog.
|
||||||
|
|
||||||
|
**The window is too small or too large.** It opens at most as large as your
|
||||||
|
screen's work area. Use the zoom slider in the status bar to scale the table.
|
||||||
+38
-2
@@ -59,11 +59,47 @@ target and a prebuilt wxMSW prefix to the Linux image. Rebuild it with
|
|||||||
`ci/images/build-image.sh TAG` from the workstation that holds the registry
|
`ci/images/build-image.sh TAG` from the workstation that holds the registry
|
||||||
credential; the script pins the new digest everywhere.
|
credential; the script pins the new digest everywhere.
|
||||||
|
|
||||||
|
## Code signing
|
||||||
|
|
||||||
|
Release and `-rc` executables are Authenticode-signed with Azure Artifact
|
||||||
|
Signing (formerly Trusted Signing), so Windows and SmartScreen show
|
||||||
|
"BlueFlare Energy Solutions Inc." as the verified publisher instead of "Unknown publisher".
|
||||||
|
|
||||||
|
| Piece | Where |
|
||||||
|
|-------|-------|
|
||||||
|
| Signing account | `blueflaresigning` (Basic), resource group `rg-blueflare-signing`, West US 2, endpoint `https://wus2.codesigning.azure.net` |
|
||||||
|
| CI identity | service principal `alkane-toolkit-ci-signer`, role "Artifact Signing Certificate Profile Signer" on the certificate profile only; Gitea secrets `AZURE_SIGNING_TENANT_ID`, `AZURE_SIGNING_CLIENT_ID`, `AZURE_SIGNING_CLIENT_SECRET` (secret expires 2027-11-03) |
|
||||||
|
| Switch | Gitea repository variable `AZURE_SIGNING_PROFILE` (certificate profile name); unset = builds stay unsigned |
|
||||||
|
| Signer | `ci/sign-windows.sh` (jsign from the CI image, RFC 3161 timestamp from `timestamp.acs.microsoft.com`) |
|
||||||
|
| Check | `windows-native.yml` requires `Get-AuthenticodeSignature` = Valid on real Windows once signing is on |
|
||||||
|
|
||||||
|
Signing is on since 2026-11-03 (identity validation approved, certificate
|
||||||
|
profile `alkane-toolkit`, PublicTrust). The zip's README.txt states whether its
|
||||||
|
executable is signed. To set it up again, e.g. for a new profile, after an
|
||||||
|
identity validation is approved (portal: signing account > Identity
|
||||||
|
validations):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
scripts/enable-windows-signing.sh <identity-validation-id>
|
||||||
|
```
|
||||||
|
|
||||||
|
It creates the PublicTrust certificate profile, narrows the CI identity to it,
|
||||||
|
and sets `AZURE_SIGNING_PROFILE`. From then on a signing failure fails the
|
||||||
|
release. Rotate the CI secret before it expires with
|
||||||
|
`az ad sp credential reset --id <appId> --years 1` and update the Gitea secret.
|
||||||
|
|
||||||
|
Sign by hand (any machine with Java, `az login` and the Signer role):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
AZURE_SIGNING_PROFILE=alkane-toolkit ALKANE_JSIGN_JAR=jsign.jar \
|
||||||
|
AZURE_SIGNING_TOKEN=$(az account get-access-token --resource https://codesigning.azure.net --query accessToken -o tsv) \
|
||||||
|
ci/sign-windows.sh alkane-toolkit.exe
|
||||||
|
```
|
||||||
|
|
||||||
## Native Windows runner
|
## Native Windows runner
|
||||||
|
|
||||||
`windows-native.yml` runs on the self-hosted runner `win11-test-vm`
|
`windows-native.yml` runs on the self-hosted runner `win11-test-vm`
|
||||||
(label `alkane-windows`, host mode) inside the Windows 11 test VM
|
(label `alkane-windows`, host mode) inside a Windows 11 test VM. It downloads the
|
||||||
(a local test VM). It downloads the
|
|
||||||
`alkane-toolkit-windows-tests` artifact of the triggering main run, runs every
|
`alkane-toolkit-windows-tests` artifact of the triggering main run, runs every
|
||||||
test executable and the UI self-test natively, and never blocks a release:
|
test executable and the UI self-test natively, and never blocks a release:
|
||||||
while the VM is off, the job waits for the runner.
|
while the VM is off, the job waits for the runner.
|
||||||
|
|||||||
@@ -1,9 +1,28 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Build the alkane-toolkit GUI on macOS.
|
# Build the alkane-toolkit GUI on macOS as one universal binary.
|
||||||
# wx-rs upstream supports macOS: its build.rs clones/builds wx 3.2.2.1 into
|
#
|
||||||
# ./dist (osx-release-build) on first build. Requires Xcode Command Line
|
# scripts/build-gui-macos.sh [extra cargo build args]
|
||||||
# Tools. Run this ON a Mac - macOS cannot be linked from Linux.
|
# -> target/universal-apple-darwin/release/alkane-toolkit (arm64 + x86_64)
|
||||||
|
#
|
||||||
|
# Needs the Xcode Command Line Tools, rustup with the aarch64-apple-darwin and
|
||||||
|
# x86_64-apple-darwin targets, and the universal static wx prefix from
|
||||||
|
# scripts/build-wx-macos.sh (WX_MACOS_PREFIX, default ~/.cache/wx-3.3.3-macos).
|
||||||
|
# Each target is built separately against that prefix, then the two slices
|
||||||
|
# are merged with lipo. MACOSX_DEPLOYMENT_TARGET matches the wx build.
|
||||||
set -e
|
set -e
|
||||||
cd "$(dirname -- "$0")/.."
|
cd "$(dirname -- "$0")/.."
|
||||||
cargo build --release -p alkane-gui
|
PREFIX="${WX_MACOS_PREFIX:-$HOME/.cache/wx-3.3.3-macos}"
|
||||||
echo "binary: target/release/alkane-toolkit (app bundle packaging is follow-up)"
|
[ -x "$PREFIX/bin/wx-config" ] || {
|
||||||
|
echo "no wx prefix at $PREFIX; run scripts/build-wx-macos.sh first" >&2; exit 1; }
|
||||||
|
export WX_RS_WXCONFIG="$PREFIX/bin/wx-config"
|
||||||
|
export MACOSX_DEPLOYMENT_TARGET="${MACOSX_MIN:-11.0}"
|
||||||
|
for target in aarch64-apple-darwin x86_64-apple-darwin; do
|
||||||
|
cargo build --release --offline -p alkane-gui --target "$target" "$@"
|
||||||
|
done
|
||||||
|
out=target/universal-apple-darwin/release
|
||||||
|
mkdir -p "$out"
|
||||||
|
lipo -create -output "$out/alkane-toolkit" \
|
||||||
|
target/aarch64-apple-darwin/release/alkane-toolkit \
|
||||||
|
target/x86_64-apple-darwin/release/alkane-toolkit
|
||||||
|
lipo -info "$out/alkane-toolkit"
|
||||||
|
echo "binary: $out/alkane-toolkit"
|
||||||
|
|||||||
Executable
+43
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Build the vendored wxWidgets 3.3.3 for macOS: wxOSX/Cocoa, static,
|
||||||
|
# monolithic, and universal (arm64 + x86_64) so one prefix serves both Rust
|
||||||
|
# targets. Run on a Mac with the Xcode Command Line Tools.
|
||||||
|
#
|
||||||
|
# scripts/build-wx-macos.sh -> ~/.cache/wx-3.3.3-macos
|
||||||
|
#
|
||||||
|
# Dependency tracking is off: its bootstrap fails with several -arch flags.
|
||||||
|
# MACOSX_MIN (default 11.0) is the oldest macOS the app runs on, for both
|
||||||
|
# slices: the libc++ in current SDKs supports nothing older, and macOS 11 is
|
||||||
|
# also where Apple Silicon starts. Image/zlib/regex/expat libraries are
|
||||||
|
# wx's bundled copies, so the app links only against system frameworks.
|
||||||
|
# The repo's vendor tree stays pristine; the build lives in ~/.cache/wxbuild.
|
||||||
|
set -e
|
||||||
|
REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||||
|
SRC="$REPO/thirdparty/wxwidgets/wxWidgets-3.3.3"
|
||||||
|
BUILD="$HOME/.cache/wxbuild/wxWidgets-3.3.3-macos"
|
||||||
|
PREFIX="${WX_MACOS_PREFIX:-$HOME/.cache/wx-3.3.3-macos}"
|
||||||
|
MACOSX_MIN="${MACOSX_MIN:-11.0}"
|
||||||
|
JOBS="${JOBS:-$(sysctl -n hw.ncpu)}"
|
||||||
|
[ -d "$SRC" ] || { echo "thirdparty wxWidgets tree missing: $SRC" >&2; exit 1; }
|
||||||
|
rm -rf "$BUILD"
|
||||||
|
mkdir -p "$HOME/.cache/wxbuild"
|
||||||
|
cp -R "$SRC" "$BUILD"
|
||||||
|
trap 'rm -rf "$BUILD"' 0
|
||||||
|
chmod +x "$BUILD/configure" "$BUILD/config.guess" "$BUILD/config.sub" "$BUILD/install-sh" 2>/dev/null || true
|
||||||
|
mkdir -p "$BUILD/build-macos"
|
||||||
|
cd "$BUILD/build-macos"
|
||||||
|
sh ../configure --prefix="$PREFIX" --with-osx_cocoa \
|
||||||
|
--disable-shared --enable-monolithic \
|
||||||
|
--enable-universal_binary=arm64,x86_64 \
|
||||||
|
--with-macosx-version-min="$MACOSX_MIN" \
|
||||||
|
--disable-dependency-tracking \
|
||||||
|
--with-libpng=builtin --with-libjpeg=builtin --without-libtiff \
|
||||||
|
--with-zlib=builtin --with-expat=builtin --with-regex=builtin \
|
||||||
|
--without-liblzma --without-libcurl \
|
||||||
|
--with-opengl=no --disable-stc --disable-webview --disable-mediactrl \
|
||||||
|
--disable-tests
|
||||||
|
make -j"$JOBS"
|
||||||
|
make install
|
||||||
|
lib=$(ls "$PREFIX"/lib/libwx_osx_cocoau-3.3*.a | head -1)
|
||||||
|
lipo -info "$lib"
|
||||||
|
echo "installed: $PREFIX ($lib)"
|
||||||
Executable
+58
@@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Turn on Authenticode signing of the Windows build, once Microsoft has
|
||||||
|
# approved the publisher identity validation for the Artifact Signing account.
|
||||||
|
#
|
||||||
|
# scripts/enable-windows-signing.sh IDENTITY_VALIDATION_ID [PROFILE]
|
||||||
|
#
|
||||||
|
# IDENTITY_VALIDATION_ID is shown in the Azure portal: signing account
|
||||||
|
# "blueflaresigning" > Objects > Identity validations > (approved entry).
|
||||||
|
# The script
|
||||||
|
# 1. creates the PublicTrust certificate profile PROFILE (default
|
||||||
|
# alkane-toolkit) bound to that identity,
|
||||||
|
# 2. narrows the CI signer's role from the whole account to that profile,
|
||||||
|
# 3. sets the Gitea repository variable AZURE_SIGNING_PROFILE, which makes
|
||||||
|
# ci/sign-windows.sh sign every release and candidate from then on.
|
||||||
|
#
|
||||||
|
# Run on the workstation: it needs `az login` as an account owner and the
|
||||||
|
# Gitea admin token (~/.config/gitea/token), neither of which CI ever sees.
|
||||||
|
# Re-running is safe.
|
||||||
|
set -eu
|
||||||
|
IVID=${1:?usage: enable-windows-signing.sh IDENTITY_VALIDATION_ID [PROFILE]}
|
||||||
|
PROFILE=${2:-alkane-toolkit}
|
||||||
|
RG=rg-blueflare-signing
|
||||||
|
ACCOUNT=blueflaresigning
|
||||||
|
SIGNER=alkane-toolkit-ci-signer
|
||||||
|
REPO=blueflare/alkane-toolkit
|
||||||
|
TOKEN_FILE=${GITEA_TOKEN_FILE:-$HOME/.config/gitea/token}
|
||||||
|
|
||||||
|
if ! az trustedsigning certificate-profile show -g "$RG" --account-name "$ACCOUNT" \
|
||||||
|
-n "$PROFILE" --only-show-errors -o none 2>/dev/null; then
|
||||||
|
az trustedsigning certificate-profile create -g "$RG" --account-name "$ACCOUNT" \
|
||||||
|
-n "$PROFILE" --profile-type PublicTrust --identity-validation-id "$IVID" \
|
||||||
|
--only-show-errors -o none
|
||||||
|
fi
|
||||||
|
az trustedsigning certificate-profile show -g "$RG" --account-name "$ACCOUNT" -n "$PROFILE" \
|
||||||
|
--only-show-errors --query "{profile:name, state:provisioningState, status:status}" -o table
|
||||||
|
|
||||||
|
# Least privilege: the CI identity may sign with this profile and nothing else.
|
||||||
|
profile_id=$(az trustedsigning certificate-profile show -g "$RG" --account-name "$ACCOUNT" \
|
||||||
|
-n "$PROFILE" --only-show-errors --query id -o tsv)
|
||||||
|
account_id=${profile_id%/certificateProfiles/*}
|
||||||
|
sp=$(az ad sp list --display-name "$SIGNER" --query "[0].id" -o tsv)
|
||||||
|
role="Artifact Signing Certificate Profile Signer"
|
||||||
|
az role assignment create --assignee-object-id "$sp" --assignee-principal-type ServicePrincipal \
|
||||||
|
--role "$role" --scope "$profile_id" -o none
|
||||||
|
az role assignment delete --assignee "$sp" --role "$role" --scope "$account_id" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Switch signing on for CI (repository variable, not a secret).
|
||||||
|
api=https://gitea.bluefla.re/api/v1/repos/$REPO/actions/variables/AZURE_SIGNING_PROFILE
|
||||||
|
body=$(printf '{"value":"%s"}' "$PROFILE")
|
||||||
|
auth() { printf 'header = "Authorization: token %s"\n' "$(cat "$TOKEN_FILE")"; }
|
||||||
|
code=$(auth | curl -sS --config - -X PUT -H 'Content-Type: application/json' -d "$body" \
|
||||||
|
-o /dev/null -w '%{http_code}' "$api")
|
||||||
|
[ "$code" = 204 ] || [ "$code" = 201 ] || {
|
||||||
|
code=$(auth | curl -sS --config - -X POST -H 'Content-Type: application/json' -d "$body" \
|
||||||
|
-o /dev/null -w '%{http_code}' "$api")
|
||||||
|
}
|
||||||
|
case "$code" in 201|204) echo "Gitea AZURE_SIGNING_PROFILE=$PROFILE: signing is on" ;;
|
||||||
|
*) echo "setting the Gitea variable failed (HTTP $code)" >&2; exit 1 ;; esac
|
||||||
+308
@@ -0,0 +1,308 @@
|
|||||||
|
Subject: [PATCH 0034] vnish: keep the reported boards and infer the algorithm for unknown models
|
||||||
|
|
||||||
|
Field report 2026-11-03: VNish Antminer S19 (88) units showed no hashboard
|
||||||
|
icons while hashing. VNish reports the model as "Antminer S19 (88)", which is
|
||||||
|
not in asic-rs' alias table, so it parses to AntMinerModel::Unknown with no
|
||||||
|
hardware table. parse_hashboards sized the board list from that table
|
||||||
|
(board_count() = None -> 0 boards) and dropped all three live chains the
|
||||||
|
miner reports in /summary. The same Unknown model also got
|
||||||
|
HashAlgorithm::Unknown, so its hashrate was bucketed as "Unknown Hashrate".
|
||||||
|
|
||||||
|
- VNish v1.2.x and v1.3.x parse_hashboards: when the model has no hardware
|
||||||
|
table, size the boards from the highest 1-based chain id the miner reports
|
||||||
|
(a dead middle board keeps its slot). Known models are unchanged.
|
||||||
|
- infer_antminer_algo (family letter: S/T -> SHA-256, L -> Scrypt,
|
||||||
|
Z -> Equihash, ambiguous -> Unknown) moves from the stock v2020 backend
|
||||||
|
into asic-rs-makes-antminer as a public function; the stock backend and
|
||||||
|
both VNish backends now use it for models the table cannot place.
|
||||||
|
|
||||||
|
Tests: unknown_model_keeps_the_reported_chains (both VNish backends, chain
|
||||||
|
data from the live 10.4.0.179 unit); the existing
|
||||||
|
unknown_models_infer_algo_from_family_letter still passes against the moved
|
||||||
|
helper. Live-verified read-only on all 13 fleet S19 (88) units (10.4.x,
|
||||||
|
10.7.1.190): three hashboard icons each, per-board state intact (e.g. one red
|
||||||
|
board on 10.4.1.111), and the KPI reads "SHA-256 Hashrate".
|
||||||
|
|
||||||
|
diff --git a/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs b/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs
|
||||||
|
index 71195737..872bd1de 100644
|
||||||
|
--- a/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs
|
||||||
|
+++ b/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs
|
||||||
|
@@ -202,27 +202,7 @@ fn miner_conf_with_fan_config(miner_conf: &Value, config: FanConfig) -> Value {
|
||||||
|
Value::Object(payload)
|
||||||
|
}
|
||||||
|
|
||||||
|
-/// Infer an Antminer's hash algorithm from its model-family letter, for models
|
||||||
|
-/// asic-rs' alias table doesn't recognise (round 13 #5). Only the families whose
|
||||||
|
-/// entire product line shares one algorithm are inferred; anything ambiguous
|
||||||
|
-/// (the K-series spans Kadena/KHeavyHash/Eaglesong, DR is Blake256 while D is
|
||||||
|
-/// X11) is left Unknown rather than guessed wrong.
|
||||||
|
-fn infer_antminer_algo(model: &str) -> HashAlgorithm {
|
||||||
|
- let upper = model.to_ascii_uppercase();
|
||||||
|
- let name = upper
|
||||||
|
- .strip_prefix("ANTMINER ")
|
||||||
|
- .unwrap_or(&upper)
|
||||||
|
- .trim_start();
|
||||||
|
- match name.chars().next() {
|
||||||
|
- // Z9 / Z11 / Z15 / Z15 Pro / Z15J -- the whole Z line is Equihash.
|
||||||
|
- Some('Z') => HashAlgorithm::Equihash,
|
||||||
|
- // L3+ / L7 / L9 / L11 -- the whole L line is Scrypt.
|
||||||
|
- Some('L') => HashAlgorithm::Scrypt,
|
||||||
|
- // S9..S21 and T9..T21 (and future revisions) are all SHA-256.
|
||||||
|
- Some('S') | Some('T') => HashAlgorithm::SHA256,
|
||||||
|
- _ => HashAlgorithm::Unknown,
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
+use asic_rs_makes_antminer::models::infer_antminer_algo;
|
||||||
|
|
||||||
|
impl AntMinerV2020 {
|
||||||
|
pub fn new(ip: IpAddr, model: impl MinerModel) -> Self {
|
||||||
|
diff --git a/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs b/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs
|
||||||
|
index 2c14f217..3c8e1bee 100644
|
||||||
|
--- a/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs
|
||||||
|
+++ b/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
use std::{collections::HashMap, net::IpAddr, str::FromStr, time::Duration};
|
||||||
|
|
||||||
|
+use asic_rs_makes_antminer::models::infer_antminer_algo;
|
||||||
|
use anyhow;
|
||||||
|
use asic_rs_core::{
|
||||||
|
config::{
|
||||||
|
@@ -17,7 +18,7 @@ use asic_rs_core::{
|
||||||
|
DataCollector, DataExtensions, DataExtractor, DataField, DataLocation, get_by_pointer,
|
||||||
|
},
|
||||||
|
command::MinerCommand,
|
||||||
|
- device::DeviceInfo,
|
||||||
|
+ device::{DeviceInfo, HashAlgorithm},
|
||||||
|
fan::FanData,
|
||||||
|
hashrate::{HashRate, HashRateUnit},
|
||||||
|
message::{MessageSeverity, MinerComponent, MinerMessage},
|
||||||
|
@@ -52,7 +53,14 @@ pub struct VnishV120 {
|
||||||
|
impl VnishV120 {
|
||||||
|
pub fn new(ip: IpAddr, model: impl MinerModel) -> Self {
|
||||||
|
let auth = Self::default_auth();
|
||||||
|
- let algo = model.hash_algorithm();
|
||||||
|
+ // A model outside asic-rs' alias table (VNish's "Antminer S19 (88)")
|
||||||
|
+ // resolves to HashAlgorithm::Unknown, which left its hashrate bucketed
|
||||||
|
+ // as "Unknown Hashrate". Infer it from the Antminer family letter, as
|
||||||
|
+ // the stock backend does.
|
||||||
|
+ let algo = match model.hash_algorithm() {
|
||||||
|
+ HashAlgorithm::Unknown => infer_antminer_algo(&model.to_string()),
|
||||||
|
+ known => known,
|
||||||
|
+ };
|
||||||
|
VnishV120 {
|
||||||
|
ip,
|
||||||
|
web: VnishWebAPI::new(ip, 80, auth),
|
||||||
|
@@ -509,8 +517,24 @@ impl GetHashboards for VnishV120 {
|
||||||
|
.and_then(|v| v.pointer("/factory"))
|
||||||
|
.and_then(|v| v.as_array());
|
||||||
|
|
||||||
|
- let mut hashboards: Vec<BoardData> =
|
||||||
|
- (0..self.device_info.hardware.board_count().unwrap_or(0) as usize)
|
||||||
|
+ // The model's hardware table gives the board count. For a model asic-rs
|
||||||
|
+ // does not know (e.g. VNish "Antminer S19 (88)") there is no table, and
|
||||||
|
+ // sizing from it dropped every live chain -- the boards then vanished
|
||||||
|
+ // from the data although the miner reports them. Fall back to what the
|
||||||
|
+ // miner reports: the highest 1-based chain id, so a dead middle board
|
||||||
|
+ // still keeps its slot.
|
||||||
|
+ let reported_boards = all_chains
|
||||||
|
+ .iter()
|
||||||
|
+ .filter_map(|c| c.pointer("/id").and_then(|v| v.as_u64()))
|
||||||
|
+ .max()
|
||||||
|
+ .unwrap_or(0) as usize;
|
||||||
|
+ let board_count = self
|
||||||
|
+ .device_info
|
||||||
|
+ .hardware
|
||||||
|
+ .board_count()
|
||||||
|
+ .map(|n| n as usize)
|
||||||
|
+ .unwrap_or(reported_boards);
|
||||||
|
+ let mut hashboards: Vec<BoardData> = (0..board_count)
|
||||||
|
.map(|idx| {
|
||||||
|
BoardData::new(idx as u8, self.device_info.hardware.chips_for_board(idx))
|
||||||
|
})
|
||||||
|
@@ -1524,4 +1548,42 @@ mod tests {
|
||||||
|
assert!(config.available.contains(&Tz::Etc__GMT));
|
||||||
|
assert_eq!(config.available.last(), Some(&Tz::Etc__GMTMinus14));
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ /// Same as the 1.3.x backend: a model with no hardware table (VNish's
|
||||||
|
+ /// "Antminer S19 (88)") must keep the chains the miner reports instead of
|
||||||
|
+ /// sizing the board list to zero. Live 1.2.7 units (e.g. 10.4.1.111) run it.
|
||||||
|
+ #[tokio::test]
|
||||||
|
+ async fn unknown_model_keeps_the_reported_chains() {
|
||||||
|
+ let miner = VnishV120::new(
|
||||||
|
+ IpAddr::from([127, 0, 0, 1]),
|
||||||
|
+ AntMinerModel::Unknown("ANTMINER S19 (88)".to_string()),
|
||||||
|
+ );
|
||||||
|
+ let mut results = HashMap::new();
|
||||||
|
+ results.insert(
|
||||||
|
+ MinerCommand::WebAPI {
|
||||||
|
+ command: "info",
|
||||||
|
+ parameters: None,
|
||||||
|
+ },
|
||||||
|
+ json!({ "miner": "Antminer S19 (88)", "hr_measure": "GH/s", "fw_version": "1.2.7" }),
|
||||||
|
+ );
|
||||||
|
+ results.insert(
|
||||||
|
+ MinerCommand::WebAPI {
|
||||||
|
+ command: "summary",
|
||||||
|
+ parameters: None,
|
||||||
|
+ },
|
||||||
|
+ json!({ "miner": { "hr_realtime": 82600.0, "chains": [
|
||||||
|
+ { "id": 1, "hashrate_rt": 27537.83 },
|
||||||
|
+ { "id": 2, "hashrate_rt": 27511.20 },
|
||||||
|
+ { "id": 3, "hashrate_rt": 27601.04 }
|
||||||
|
+ ] } }),
|
||||||
|
+ );
|
||||||
|
+ let mock_api = MockAPIClient::new(results);
|
||||||
|
+ let mut collector = DataCollector::new_with_client(&miner, &mock_api);
|
||||||
|
+ let miner_data = miner.parse_data(collector.collect_all().await);
|
||||||
|
+
|
||||||
|
+ assert_eq!(miner_data.hashboards.len(), 3, "one board per reported chain");
|
||||||
|
+ // ...and its hashrate is SHA-256 (family letter S), not "Unknown".
|
||||||
|
+ assert_eq!(miner_data.hashrate.expect("hashrate").algo, HashAlgorithm::SHA256);
|
||||||
|
+ assert!(miner_data.hashboards.iter().all(|b| b.hashrate.is_some()));
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
diff --git a/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs b/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs
|
||||||
|
index e6247923..0e009f1c 100644
|
||||||
|
--- a/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs
|
||||||
|
+++ b/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
use std::{collections::HashMap, net::IpAddr, str::FromStr, time::Duration};
|
||||||
|
|
||||||
|
+use asic_rs_makes_antminer::models::infer_antminer_algo;
|
||||||
|
use anyhow;
|
||||||
|
use asic_rs_core::{
|
||||||
|
config::{
|
||||||
|
@@ -17,7 +18,7 @@ use asic_rs_core::{
|
||||||
|
DataCollector, DataExtensions, DataExtractor, DataField, DataLocation, get_by_pointer,
|
||||||
|
},
|
||||||
|
command::MinerCommand,
|
||||||
|
- device::DeviceInfo,
|
||||||
|
+ device::{DeviceInfo, HashAlgorithm},
|
||||||
|
fan::FanData,
|
||||||
|
hashrate::{HashRate, HashRateUnit},
|
||||||
|
message::{MessageSeverity, MinerComponent, MinerMessage},
|
||||||
|
@@ -52,7 +53,14 @@ pub struct VnishV130 {
|
||||||
|
impl VnishV130 {
|
||||||
|
pub fn new(ip: IpAddr, model: impl MinerModel) -> Self {
|
||||||
|
let auth = Self::default_auth();
|
||||||
|
- let algo = model.hash_algorithm();
|
||||||
|
+ // A model outside asic-rs' alias table (VNish's "Antminer S19 (88)")
|
||||||
|
+ // resolves to HashAlgorithm::Unknown, which left its hashrate bucketed
|
||||||
|
+ // as "Unknown Hashrate". Infer it from the Antminer family letter, as
|
||||||
|
+ // the stock backend does.
|
||||||
|
+ let algo = match model.hash_algorithm() {
|
||||||
|
+ HashAlgorithm::Unknown => infer_antminer_algo(&model.to_string()),
|
||||||
|
+ known => known,
|
||||||
|
+ };
|
||||||
|
VnishV130 {
|
||||||
|
ip,
|
||||||
|
web: VnishWebAPI::new(ip, 80, auth),
|
||||||
|
@@ -516,8 +524,24 @@ impl GetHashboards for VnishV130 {
|
||||||
|
.and_then(|v| v.pointer("/factory"))
|
||||||
|
.and_then(|v| v.as_array());
|
||||||
|
|
||||||
|
- let mut hashboards: Vec<BoardData> =
|
||||||
|
- (0..self.device_info.hardware.board_count().unwrap_or(0) as usize)
|
||||||
|
+ // The model's hardware table gives the board count. For a model asic-rs
|
||||||
|
+ // does not know (e.g. VNish "Antminer S19 (88)") there is no table, and
|
||||||
|
+ // sizing from it dropped every live chain -- the boards then vanished
|
||||||
|
+ // from the data although the miner reports them. Fall back to what the
|
||||||
|
+ // miner reports: the highest 1-based chain id, so a dead middle board
|
||||||
|
+ // still keeps its slot.
|
||||||
|
+ let reported_boards = all_chains
|
||||||
|
+ .iter()
|
||||||
|
+ .filter_map(|c| c.pointer("/id").and_then(|v| v.as_u64()))
|
||||||
|
+ .max()
|
||||||
|
+ .unwrap_or(0) as usize;
|
||||||
|
+ let board_count = self
|
||||||
|
+ .device_info
|
||||||
|
+ .hardware
|
||||||
|
+ .board_count()
|
||||||
|
+ .map(|n| n as usize)
|
||||||
|
+ .unwrap_or(reported_boards);
|
||||||
|
+ let mut hashboards: Vec<BoardData> = (0..board_count)
|
||||||
|
.map(|idx| {
|
||||||
|
BoardData::new(idx as u8, self.device_info.hardware.chips_for_board(idx))
|
||||||
|
})
|
||||||
|
@@ -1661,4 +1685,46 @@ mod tests {
|
||||||
|
assert!(config.available.contains(&Tz::Etc__GMT));
|
||||||
|
assert_eq!(config.available.last(), Some(&Tz::Etc__GMTMinus14));
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ /// A model asic-rs has no hardware table for -- VNish reports the 88-chip
|
||||||
|
+ /// S19 as "Antminer S19 (88)" -- must still surface the boards the miner
|
||||||
|
+ /// reports. Sizing the board list from the (absent) table dropped all
|
||||||
|
+ /// three live chains, so the GUI drew no hashboard icons for a hashing
|
||||||
|
+ /// miner. Chain values match the live 10.4.0.179 unit.
|
||||||
|
+ #[tokio::test]
|
||||||
|
+ async fn unknown_model_keeps_the_reported_chains() {
|
||||||
|
+ let miner = VnishV130::new(
|
||||||
|
+ IpAddr::from([127, 0, 0, 1]),
|
||||||
|
+ AntMinerModel::Unknown("ANTMINER S19 (88)".to_string()),
|
||||||
|
+ );
|
||||||
|
+ let mut results = HashMap::new();
|
||||||
|
+ results.insert(
|
||||||
|
+ web("info"),
|
||||||
|
+ json!({ "miner": "Antminer S19 (88)", "model": "s19-88", "hr_measure": "GH/s" }),
|
||||||
|
+ );
|
||||||
|
+ results.insert(
|
||||||
|
+ web("summary"),
|
||||||
|
+ json!({
|
||||||
|
+ "miner": {
|
||||||
|
+ "hr_realtime": 82600.0,
|
||||||
|
+ "chains": [
|
||||||
|
+ { "id": 1, "hashrate_rt": 27537.83, "chip_statuses": { "grey": 88 } },
|
||||||
|
+ { "id": 2, "hashrate_rt": 27511.20, "chip_statuses": { "grey": 88 } },
|
||||||
|
+ { "id": 3, "hashrate_rt": 27601.04, "chip_statuses": { "grey": 88 } }
|
||||||
|
+ ]
|
||||||
|
+ }
|
||||||
|
+ }),
|
||||||
|
+ );
|
||||||
|
+ let mock_api = MockAPIClient::new(results);
|
||||||
|
+ let mut collector = DataCollector::new_with_client(&miner, &mock_api);
|
||||||
|
+ let miner_data = miner.parse_data(collector.collect_all().await);
|
||||||
|
+
|
||||||
|
+ assert_eq!(miner_data.hashboards.len(), 3, "one board per reported chain");
|
||||||
|
+ // ...and its hashrate is SHA-256 (family letter S), not "Unknown".
|
||||||
|
+ assert_eq!(miner_data.hashrate.expect("hashrate").algo, HashAlgorithm::SHA256);
|
||||||
|
+ for (i, board) in miner_data.hashboards.iter().enumerate() {
|
||||||
|
+ assert_eq!(board.position as usize, i);
|
||||||
|
+ assert!(board.hashrate.is_some(), "board {i} keeps its live hashrate");
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
diff --git a/vendor/asic-rs-makes-antminer/src/models.rs b/vendor/asic-rs-makes-antminer/src/models.rs
|
||||||
|
index f52639fe..e3185089 100644
|
||||||
|
--- a/vendor/asic-rs-makes-antminer/src/models.rs
|
||||||
|
+++ b/vendor/asic-rs-makes-antminer/src/models.rs
|
||||||
|
@@ -201,6 +201,29 @@ pub enum AntMinerModel {
|
||||||
|
Unknown(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
+/// Infer an Antminer's hash algorithm from its model-family letter, for models
|
||||||
|
+/// asic-rs' alias table doesn't recognise (round 13 #5). Only the families whose
|
||||||
|
+/// entire product line shares one algorithm are inferred; anything ambiguous
|
||||||
|
+/// (the K-series spans Kadena/KHeavyHash/Eaglesong, DR is Blake256 while D is
|
||||||
|
+/// X11) is left Unknown rather than guessed wrong. Shared by every firmware
|
||||||
|
+/// backend that runs on Antminer hardware (stock, VNish).
|
||||||
|
+pub fn infer_antminer_algo(model: &str) -> HashAlgorithm {
|
||||||
|
+ let upper = model.to_ascii_uppercase();
|
||||||
|
+ let name = upper
|
||||||
|
+ .strip_prefix("ANTMINER ")
|
||||||
|
+ .unwrap_or(&upper)
|
||||||
|
+ .trim_start();
|
||||||
|
+ match name.chars().next() {
|
||||||
|
+ // Z9 / Z11 / Z15 / Z15 Pro / Z15J -- the whole Z line is Equihash.
|
||||||
|
+ Some('Z') => HashAlgorithm::Equihash,
|
||||||
|
+ // L3+ / L7 / L9 / L11 -- the whole L line is Scrypt.
|
||||||
|
+ Some('L') => HashAlgorithm::Scrypt,
|
||||||
|
+ // S9..S21 and T9..T21 (and future revisions) are all SHA-256.
|
||||||
|
+ Some('S') | Some('T') => HashAlgorithm::SHA256,
|
||||||
|
+ _ => HashAlgorithm::Unknown,
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
impl FromStr for AntMinerModel {
|
||||||
|
type Err = ModelSelectionError;
|
||||||
|
|
||||||
+140
@@ -0,0 +1,140 @@
|
|||||||
|
Subject: [PATCH 0009] macOS: wxOSX through wx-config, logical sizes, clang runtime
|
||||||
|
|
||||||
|
--- a/build.rs
|
||||||
|
+++ b/build.rs
|
||||||
|
@@ -42,12 +42,12 @@
|
||||||
|
target_os() == "linux"
|
||||||
|
}
|
||||||
|
|
||||||
|
-// alkane-toolkit patch: Linux (wxGTK) and Windows/GNU (wxMSW built with
|
||||||
|
-// mingw-w64, natively or cross from Linux) both build against a wx prefix
|
||||||
|
-// described by its wx-config script, so they share one code path. Upstream's
|
||||||
|
-// MSVC/nmake and macOS download-and-build paths are left as they were.
|
||||||
|
+// alkane-toolkit patch: Linux (wxGTK), macOS (wxOSX/Cocoa, universal static
|
||||||
|
+// build) and Windows/GNU (wxMSW built with mingw-w64, natively or cross from
|
||||||
|
+// Linux) all build against a wx prefix described by its wx-config script, so
|
||||||
|
+// they share one code path. Upstream's MSVC/nmake path is left as it was.
|
||||||
|
fn uses_wx_config() -> bool {
|
||||||
|
- is_linux() || (is_windows() && !is_msvc())
|
||||||
|
+ is_linux() || is_osx() || (is_windows() && !is_msvc())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_stub() -> bool {
|
||||||
|
@@ -278,7 +278,14 @@
|
||||||
|
build.cpp(true)
|
||||||
|
.file("cpp_src/wxbridge.cpp")
|
||||||
|
.file("cpp_src/widgets_bridge.cpp");
|
||||||
|
- for f in cxxflags.split_whitespace() {
|
||||||
|
+ let mut flags = cxxflags.split_whitespace();
|
||||||
|
+ while let Some(f) = flags.next() {
|
||||||
|
+ // A universal wx prefix reports `-arch arm64 -arch x86_64`; cargo builds
|
||||||
|
+ // one target at a time and cc adds that target's own -arch.
|
||||||
|
+ if is_osx() && f == "-arch" {
|
||||||
|
+ flags.next();
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
build.flag(f);
|
||||||
|
}
|
||||||
|
if is_linux() {
|
||||||
|
@@ -308,7 +315,53 @@
|
||||||
|
}
|
||||||
|
build.compile("wxbridge");
|
||||||
|
|
||||||
|
- for flag in libs.split_whitespace() {
|
||||||
|
+ if is_osx() {
|
||||||
|
+ // wxOSX's Objective-C uses @available, which calls
|
||||||
|
+ // ___isPlatformVersionAtLeast from clang's compiler runtime. clang
|
||||||
|
+ // links that runtime itself, but rustc drives the link without it.
|
||||||
|
+ let resource_dir = Command::new("clang")
|
||||||
|
+ .arg("-print-resource-dir")
|
||||||
|
+ .output()
|
||||||
|
+ .ok()
|
||||||
|
+ .filter(|o| o.status.success())
|
||||||
|
+ .and_then(|o| String::from_utf8(o.stdout).ok())
|
||||||
|
+ .map(|s| s.trim().to_string())
|
||||||
|
+ .ok_or("wx-rs: cannot ask clang for its resource directory")?;
|
||||||
|
+ let rt = Path::new(&resource_dir).join("lib").join("darwin");
|
||||||
|
+ if !rt.join("libclang_rt.osx.a").exists() {
|
||||||
|
+ return Err(format!("wx-rs: no libclang_rt.osx.a in {}", rt.display()).into());
|
||||||
|
+ }
|
||||||
|
+ println!("cargo:rustc-link-search=native={}", rt.display());
|
||||||
|
+ println!("cargo:rustc-link-lib=static=clang_rt.osx");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ let mut lib_flags = libs.split_whitespace();
|
||||||
|
+ while let Some(flag) = lib_flags.next() {
|
||||||
|
+ if is_osx() {
|
||||||
|
+ match flag {
|
||||||
|
+ "-arch" => {
|
||||||
|
+ lib_flags.next();
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ "-framework" => {
|
||||||
|
+ if let Some(name) = lib_flags.next() {
|
||||||
|
+ println!("cargo:rustc-link-lib=framework={}", name);
|
||||||
|
+ }
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ "-weak_framework" => {
|
||||||
|
+ if let Some(name) = lib_flags.next() {
|
||||||
|
+ println!("cargo:rustc-link-arg=-Wl,-weak_framework,{}", name);
|
||||||
|
+ }
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ _ if flag.starts_with("-Wl,") => {
|
||||||
|
+ println!("cargo:rustc-link-arg={}", flag);
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ _ => {}
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
if flag.ends_with(".a") && Path::new(flag).is_absolute() {
|
||||||
|
// static wx builds: wx-config emits the archive as a full path
|
||||||
|
let file = Path::new(flag).file_name().and_then(|f| f.to_str()).unwrap_or(flag);
|
||||||
|
--- a/cpp_src/wxbridge.cpp
|
||||||
|
+++ b/cpp_src/wxbridge.cpp
|
||||||
|
@@ -492,21 +492,12 @@
|
||||||
|
|
||||||
|
// The logical window size
|
||||||
|
Size get_client_size() {
|
||||||
|
-#ifdef __APPLE__
|
||||||
|
- int status_bar_height;
|
||||||
|
- if (wxGetApp().frame->GetStatusBar()) {
|
||||||
|
- status_bar_height = wxGetApp().frame->GetStatusBar()->GetRect().height;
|
||||||
|
- } else {
|
||||||
|
- status_bar_height = 0;
|
||||||
|
- }
|
||||||
|
- float scale_factor = wxGetApp().frame->GetDPIScaleFactor();
|
||||||
|
- wxSize s = wxGetApp().frame->GetClientSize();
|
||||||
|
- struct Size sz = {s.x * scale_factor, (s.y + status_bar_height) * scale_factor};
|
||||||
|
- return sz;
|
||||||
|
-#elif defined(__linux__)
|
||||||
|
- // alkane-toolkit patch: wxGTK3 path (upstream only knew Apple vs Windows)
|
||||||
|
+#if defined(__linux__) || defined(__APPLE__)
|
||||||
|
+ // alkane-toolkit patch: wxGTK3 and wxOSX both report logical (DIP) sizes,
|
||||||
|
+ // like every other bridge size. Upstream's Apple branch scaled to physical
|
||||||
|
+ // pixels through a float -> int narrowing current clang rejects.
|
||||||
|
wxSize s = wxGetApp().frame->GetClientSize();
|
||||||
|
- return Size {(unsigned int)s.x, (unsigned int)s.y};
|
||||||
|
+ return Size {s.x, s.y};
|
||||||
|
#else
|
||||||
|
HWND hwnd = (HWND) wxGetApp().frame->GetHandle();
|
||||||
|
RECT rect;
|
||||||
|
@@ -559,15 +550,10 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
Size get_mouse_position(wxMouseEvent &event) {
|
||||||
|
-#ifdef __APPLE__
|
||||||
|
- wxPoint p = event.GetPosition();
|
||||||
|
- float scale_factor = wxGetApp().frame->GetDPIScaleFactor();
|
||||||
|
- struct Size s = {p.x * scale_factor, p.y * scale_factor};
|
||||||
|
- return s;
|
||||||
|
-#else
|
||||||
|
+ // alkane-toolkit patch: logical (DIP) coordinates on every platform,
|
||||||
|
+ // matching get_client_size (upstream scaled them on Apple).
|
||||||
|
wxPoint p = event.GetPosition();
|
||||||
|
return Size {p.x, p.y};
|
||||||
|
-#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_mouse_wheel_rotation(wxMouseEvent &event) {
|
||||||
Vendored
+1
@@ -27,6 +27,7 @@ later changes go in new patches.
|
|||||||
| 0006 | Build: platform from the target, not the host; Windows/GNU via `wx-config` |
|
| 0006 | Build: platform from the target, not the host; Windows/GNU via `wx-config` |
|
||||||
| 0007 | `wxbridge.cpp` on wxMSW: no input-swallowing overlay, appearance before the first window, work-area sizing, executable icon, UTF-8 menu fix |
|
| 0007 | `wxbridge.cpp` on wxMSW: no input-swallowing overlay, appearance before the first window, work-area sizing, executable icon, UTF-8 menu fix |
|
||||||
| 0008 | Widget bridge on wxMSW: generic data-view input and tooltips, DIP boundary, anti-aliased shapes, themed selection colours |
|
| 0008 | Widget bridge on wxMSW: generic data-view input and tooltips, DIP boundary, anti-aliased shapes, themed selection colours |
|
||||||
|
| 0009 | macOS: wxOSX (universal static) through `wx-config`, logical sizes on Apple, clang compiler runtime for `@available` |
|
||||||
|
|
||||||
History: the round 19 health-tooltip fix (GTK tip area converted from
|
History: the round 19 health-tooltip fix (GTK tip area converted from
|
||||||
bin-window to widget coordinates) used to be a separate patch on top of an
|
bin-window to widget coordinates) used to be a separate patch on top of an
|
||||||
|
|||||||
+60
-7
@@ -42,12 +42,12 @@ fn is_linux() -> bool {
|
|||||||
target_os() == "linux"
|
target_os() == "linux"
|
||||||
}
|
}
|
||||||
|
|
||||||
// alkane-toolkit patch: Linux (wxGTK) and Windows/GNU (wxMSW built with
|
// alkane-toolkit patch: Linux (wxGTK), macOS (wxOSX/Cocoa, universal static
|
||||||
// mingw-w64, natively or cross from Linux) both build against a wx prefix
|
// build) and Windows/GNU (wxMSW built with mingw-w64, natively or cross from
|
||||||
// described by its wx-config script, so they share one code path. Upstream's
|
// Linux) all build against a wx prefix described by its wx-config script, so
|
||||||
// MSVC/nmake and macOS download-and-build paths are left as they were.
|
// they share one code path. Upstream's MSVC/nmake path is left as it was.
|
||||||
fn uses_wx_config() -> bool {
|
fn uses_wx_config() -> bool {
|
||||||
is_linux() || (is_windows() && !is_msvc())
|
is_linux() || is_osx() || (is_windows() && !is_msvc())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_stub() -> bool {
|
fn is_stub() -> bool {
|
||||||
@@ -278,7 +278,14 @@ fn build_with_wx_config() -> Result<(), Box<dyn Error>> {
|
|||||||
build.cpp(true)
|
build.cpp(true)
|
||||||
.file("cpp_src/wxbridge.cpp")
|
.file("cpp_src/wxbridge.cpp")
|
||||||
.file("cpp_src/widgets_bridge.cpp");
|
.file("cpp_src/widgets_bridge.cpp");
|
||||||
for f in cxxflags.split_whitespace() {
|
let mut flags = cxxflags.split_whitespace();
|
||||||
|
while let Some(f) = flags.next() {
|
||||||
|
// A universal wx prefix reports `-arch arm64 -arch x86_64`; cargo builds
|
||||||
|
// one target at a time and cc adds that target's own -arch.
|
||||||
|
if is_osx() && f == "-arch" {
|
||||||
|
flags.next();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
build.flag(f);
|
build.flag(f);
|
||||||
}
|
}
|
||||||
if is_linux() {
|
if is_linux() {
|
||||||
@@ -308,7 +315,53 @@ fn build_with_wx_config() -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
build.compile("wxbridge");
|
build.compile("wxbridge");
|
||||||
|
|
||||||
for flag in libs.split_whitespace() {
|
if is_osx() {
|
||||||
|
// wxOSX's Objective-C uses @available, which calls
|
||||||
|
// ___isPlatformVersionAtLeast from clang's compiler runtime. clang
|
||||||
|
// links that runtime itself, but rustc drives the link without it.
|
||||||
|
let resource_dir = Command::new("clang")
|
||||||
|
.arg("-print-resource-dir")
|
||||||
|
.output()
|
||||||
|
.ok()
|
||||||
|
.filter(|o| o.status.success())
|
||||||
|
.and_then(|o| String::from_utf8(o.stdout).ok())
|
||||||
|
.map(|s| s.trim().to_string())
|
||||||
|
.ok_or("wx-rs: cannot ask clang for its resource directory")?;
|
||||||
|
let rt = Path::new(&resource_dir).join("lib").join("darwin");
|
||||||
|
if !rt.join("libclang_rt.osx.a").exists() {
|
||||||
|
return Err(format!("wx-rs: no libclang_rt.osx.a in {}", rt.display()).into());
|
||||||
|
}
|
||||||
|
println!("cargo:rustc-link-search=native={}", rt.display());
|
||||||
|
println!("cargo:rustc-link-lib=static=clang_rt.osx");
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut lib_flags = libs.split_whitespace();
|
||||||
|
while let Some(flag) = lib_flags.next() {
|
||||||
|
if is_osx() {
|
||||||
|
match flag {
|
||||||
|
"-arch" => {
|
||||||
|
lib_flags.next();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
"-framework" => {
|
||||||
|
if let Some(name) = lib_flags.next() {
|
||||||
|
println!("cargo:rustc-link-lib=framework={}", name);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
"-weak_framework" => {
|
||||||
|
if let Some(name) = lib_flags.next() {
|
||||||
|
println!("cargo:rustc-link-arg=-Wl,-weak_framework,{}", name);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_ if flag.starts_with("-Wl,") => {
|
||||||
|
println!("cargo:rustc-link-arg={}", flag);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
if flag.ends_with(".a") && Path::new(flag).is_absolute() {
|
if flag.ends_with(".a") && Path::new(flag).is_absolute() {
|
||||||
// static wx builds: wx-config emits the archive as a full path
|
// static wx builds: wx-config emits the archive as a full path
|
||||||
let file = Path::new(flag).file_name().and_then(|f| f.to_str()).unwrap_or(flag);
|
let file = Path::new(flag).file_name().and_then(|f| f.to_str()).unwrap_or(flag);
|
||||||
|
|||||||
+7
-21
@@ -492,21 +492,12 @@ extern "C" {
|
|||||||
|
|
||||||
// The logical window size
|
// The logical window size
|
||||||
Size get_client_size() {
|
Size get_client_size() {
|
||||||
#ifdef __APPLE__
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
int status_bar_height;
|
// alkane-toolkit patch: wxGTK3 and wxOSX both report logical (DIP) sizes,
|
||||||
if (wxGetApp().frame->GetStatusBar()) {
|
// like every other bridge size. Upstream's Apple branch scaled to physical
|
||||||
status_bar_height = wxGetApp().frame->GetStatusBar()->GetRect().height;
|
// pixels through a float -> int narrowing current clang rejects.
|
||||||
} else {
|
|
||||||
status_bar_height = 0;
|
|
||||||
}
|
|
||||||
float scale_factor = wxGetApp().frame->GetDPIScaleFactor();
|
|
||||||
wxSize s = wxGetApp().frame->GetClientSize();
|
|
||||||
struct Size sz = {s.x * scale_factor, (s.y + status_bar_height) * scale_factor};
|
|
||||||
return sz;
|
|
||||||
#elif defined(__linux__)
|
|
||||||
// alkane-toolkit patch: wxGTK3 path (upstream only knew Apple vs Windows)
|
|
||||||
wxSize s = wxGetApp().frame->GetClientSize();
|
wxSize s = wxGetApp().frame->GetClientSize();
|
||||||
return Size {(unsigned int)s.x, (unsigned int)s.y};
|
return Size {s.x, s.y};
|
||||||
#else
|
#else
|
||||||
HWND hwnd = (HWND) wxGetApp().frame->GetHandle();
|
HWND hwnd = (HWND) wxGetApp().frame->GetHandle();
|
||||||
RECT rect;
|
RECT rect;
|
||||||
@@ -559,15 +550,10 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Size get_mouse_position(wxMouseEvent &event) {
|
Size get_mouse_position(wxMouseEvent &event) {
|
||||||
#ifdef __APPLE__
|
// alkane-toolkit patch: logical (DIP) coordinates on every platform,
|
||||||
wxPoint p = event.GetPosition();
|
// matching get_client_size (upstream scaled them on Apple).
|
||||||
float scale_factor = wxGetApp().frame->GetDPIScaleFactor();
|
|
||||||
struct Size s = {p.x * scale_factor, p.y * scale_factor};
|
|
||||||
return s;
|
|
||||||
#else
|
|
||||||
wxPoint p = event.GetPosition();
|
wxPoint p = event.GetPosition();
|
||||||
return Size {p.x, p.y};
|
return Size {p.x, p.y};
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_mouse_wheel_rotation(wxMouseEvent &event) {
|
int get_mouse_wheel_rotation(wxMouseEvent &event) {
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"6e42d50107b1a43fd7cf4a4c4f538468a337ed219ad8d6b23bd9abdabd123bd5","Cargo.lock":"7f984c7231c91f2def8f3e2e923a85c2e0b3239492f5ce23400881ea4de1aa16","Cargo.toml":"8a447efc18cd97d019a9771fb258b06f694499500561564eec75480e46bcc554","Cargo.toml.orig":"6c9e7b86804255debe03545c6358eb975d3d470810a19e6c40c680299a686b1f","src/backends/mod.rs":"65cdc60cdf38968f5a7e197338f4cf6173406ce69a4f0aaa96a9e29f4f581b6e","src/backends/v2020/firmware.rs":"5a41bfb8f42f17523e68f8702e87d75bcdb268bd4950bb66227f6966ef3576a9","src/backends/v2020/mod.rs":"b2dbba5377a739bc8be3380cfbd09aa80893841c15c305bfd25f900ba7b6a0c9","src/backends/v2020/rpc.rs":"b517f88b9125fe1d8a20d5167f5d0d105b1339fce3d1a9fad5592e00470f46fb","src/backends/v2020/web.rs":"a6a3ad3eb77551b098b0092553b02cee43d165476d8c92164e12a1e765753b0d","src/backends/v2023_07/firmware.rs":"c07668e351d48dab3e24511b1aa9ab5e408bbcb5a438fdb0542a1377f94b9bbb","src/backends/v2023_07/mod.rs":"0906bff13eb51bd47fb0e06cc2c1955fe459c601cb467efc917801ead825dd61","src/backends/v2023_07/rpc.rs":"2b24bbb432b302dd15f7a354054fc96c6a75cac2c8e75b8bcc11da37255a05a3","src/backends/v2023_07/web.rs":"d39b67ed83781b2c4fa84a445b9ffe785ae3001941f800ad9860e050c61c6506","src/firmware.rs":"e75c21d63218204b61bfab067599402e5c0b20452beaf0b16bfa79bf8afb6b35","src/lib.rs":"53f7acddeff8f7d82f80d09e0a9f91962011f9ccf2e441c4ca05cd7fc4eb292e","src/test/json/mod.rs":"a3ef4d6805bb4f8ea087e3a9b875e5a1664580e1ff3e3cd2015bb0c5c18ae7bb","src/test/json/v2020/devs.json":"df17cdfc9522e23450702b93f70ff701892db54c6ce6d986300453ad5e0d22db","src/test/json/v2020/mod.rs":"4c2512d36af834d400a865a94c2e8b1919f9d8dcbf54ab2530c73861c51af67d","src/test/json/v2020/pools.json":"4c4d19ad3ef0de84bfb18daaa48428b5f7917d23287c0196eacf3a6e389e7634","src/test/json/v2020/stats.json":"6d3cb463abb7539ae77aa44ef38e62a5dc0db54670aeacf3bbd01e83f49aa1fd","src/test/json/v2020/summary.json":"2f18c81f989b7c5f70dcb0ddac0520e56ec98b6da25c24e59354a6126c965dae","src/test/json/v2020/system_info.json":"51d1ce922e39a254518a24be56ca86ef1b5843582fb26c1ff0ec4ff6f8f91ccf","src/test/json/v2020/version.json":"ae898c4c9ea3462c3e79f9de755f1fccb4ef122b94a4a512e61aa74491c1a8e9","src/test/json/v2023_07/l11_stats.json":"2eab324f253ced9a0ea4e46466691e0e71fc6fde7558fec86bd5acf6bb9c717d","src/test/json/v2023_07/l11_summary.json":"1e0fdb61b968005d0ec5393d9dc889b09efb1398ffa427629bcc0a98d1b67c22","src/test/json/v2023_07/l11_version.json":"d116921a71731c6e492aed109731c39561e34a24c7df2a88d11ac52b80f6100a","src/test/json/v2023_07/l9_stats.json":"731ee545f16dafd356d22703248b91a37f74585ad73cc27441eb3461ce53dca0","src/test/json/v2023_07/l9_summary.json":"b32b5131ad46859b270d2dbb6bdba3c4e5d7301298daee4ce56332c98faaf81d","src/test/json/v2023_07/l9_version.json":"82f03ca6ea8873f12c4d9455f21b98c547801b58fbff1dcd83c837c0f337a129","src/test/json/v2023_07/mod.rs":"1360a8b155b120f2e755ede0736bcc0d76a9d1d693b984a1b51a16e6c0413791","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"0c06e3ecbf95ae3fe5e30aacae55cf6e7ad3d965f4a93b2f85c7b64f61fc75e2"}
|
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"6e42d50107b1a43fd7cf4a4c4f538468a337ed219ad8d6b23bd9abdabd123bd5","Cargo.lock":"7f984c7231c91f2def8f3e2e923a85c2e0b3239492f5ce23400881ea4de1aa16","Cargo.toml":"8a447efc18cd97d019a9771fb258b06f694499500561564eec75480e46bcc554","Cargo.toml.orig":"6c9e7b86804255debe03545c6358eb975d3d470810a19e6c40c680299a686b1f","src/backends/mod.rs":"65cdc60cdf38968f5a7e197338f4cf6173406ce69a4f0aaa96a9e29f4f581b6e","src/backends/v2020/firmware.rs":"5a41bfb8f42f17523e68f8702e87d75bcdb268bd4950bb66227f6966ef3576a9","src/backends/v2020/mod.rs":"f709048edc8eddf71d848d0f3c55c3e2c748726072f9c838482062b66524d875","src/backends/v2020/rpc.rs":"b517f88b9125fe1d8a20d5167f5d0d105b1339fce3d1a9fad5592e00470f46fb","src/backends/v2020/web.rs":"a6a3ad3eb77551b098b0092553b02cee43d165476d8c92164e12a1e765753b0d","src/backends/v2023_07/firmware.rs":"c07668e351d48dab3e24511b1aa9ab5e408bbcb5a438fdb0542a1377f94b9bbb","src/backends/v2023_07/mod.rs":"0906bff13eb51bd47fb0e06cc2c1955fe459c601cb467efc917801ead825dd61","src/backends/v2023_07/rpc.rs":"2b24bbb432b302dd15f7a354054fc96c6a75cac2c8e75b8bcc11da37255a05a3","src/backends/v2023_07/web.rs":"d39b67ed83781b2c4fa84a445b9ffe785ae3001941f800ad9860e050c61c6506","src/firmware.rs":"e75c21d63218204b61bfab067599402e5c0b20452beaf0b16bfa79bf8afb6b35","src/lib.rs":"53f7acddeff8f7d82f80d09e0a9f91962011f9ccf2e441c4ca05cd7fc4eb292e","src/test/json/mod.rs":"a3ef4d6805bb4f8ea087e3a9b875e5a1664580e1ff3e3cd2015bb0c5c18ae7bb","src/test/json/v2020/devs.json":"df17cdfc9522e23450702b93f70ff701892db54c6ce6d986300453ad5e0d22db","src/test/json/v2020/mod.rs":"4c2512d36af834d400a865a94c2e8b1919f9d8dcbf54ab2530c73861c51af67d","src/test/json/v2020/pools.json":"4c4d19ad3ef0de84bfb18daaa48428b5f7917d23287c0196eacf3a6e389e7634","src/test/json/v2020/stats.json":"6d3cb463abb7539ae77aa44ef38e62a5dc0db54670aeacf3bbd01e83f49aa1fd","src/test/json/v2020/summary.json":"2f18c81f989b7c5f70dcb0ddac0520e56ec98b6da25c24e59354a6126c965dae","src/test/json/v2020/system_info.json":"51d1ce922e39a254518a24be56ca86ef1b5843582fb26c1ff0ec4ff6f8f91ccf","src/test/json/v2020/version.json":"ae898c4c9ea3462c3e79f9de755f1fccb4ef122b94a4a512e61aa74491c1a8e9","src/test/json/v2023_07/l11_stats.json":"2eab324f253ced9a0ea4e46466691e0e71fc6fde7558fec86bd5acf6bb9c717d","src/test/json/v2023_07/l11_summary.json":"1e0fdb61b968005d0ec5393d9dc889b09efb1398ffa427629bcc0a98d1b67c22","src/test/json/v2023_07/l11_version.json":"d116921a71731c6e492aed109731c39561e34a24c7df2a88d11ac52b80f6100a","src/test/json/v2023_07/l9_stats.json":"731ee545f16dafd356d22703248b91a37f74585ad73cc27441eb3461ce53dca0","src/test/json/v2023_07/l9_summary.json":"b32b5131ad46859b270d2dbb6bdba3c4e5d7301298daee4ce56332c98faaf81d","src/test/json/v2023_07/l9_version.json":"82f03ca6ea8873f12c4d9455f21b98c547801b58fbff1dcd83c837c0f337a129","src/test/json/v2023_07/mod.rs":"1360a8b155b120f2e755ede0736bcc0d76a9d1d693b984a1b51a16e6c0413791","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"0c06e3ecbf95ae3fe5e30aacae55cf6e7ad3d965f4a93b2f85c7b64f61fc75e2"}
|
||||||
+1
-21
@@ -202,27 +202,7 @@ fn miner_conf_with_fan_config(miner_conf: &Value, config: FanConfig) -> Value {
|
|||||||
Value::Object(payload)
|
Value::Object(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Infer an Antminer's hash algorithm from its model-family letter, for models
|
use asic_rs_makes_antminer::models::infer_antminer_algo;
|
||||||
/// asic-rs' alias table doesn't recognise (round 13 #5). Only the families whose
|
|
||||||
/// entire product line shares one algorithm are inferred; anything ambiguous
|
|
||||||
/// (the K-series spans Kadena/KHeavyHash/Eaglesong, DR is Blake256 while D is
|
|
||||||
/// X11) is left Unknown rather than guessed wrong.
|
|
||||||
fn infer_antminer_algo(model: &str) -> HashAlgorithm {
|
|
||||||
let upper = model.to_ascii_uppercase();
|
|
||||||
let name = upper
|
|
||||||
.strip_prefix("ANTMINER ")
|
|
||||||
.unwrap_or(&upper)
|
|
||||||
.trim_start();
|
|
||||||
match name.chars().next() {
|
|
||||||
// Z9 / Z11 / Z15 / Z15 Pro / Z15J -- the whole Z line is Equihash.
|
|
||||||
Some('Z') => HashAlgorithm::Equihash,
|
|
||||||
// L3+ / L7 / L9 / L11 -- the whole L line is Scrypt.
|
|
||||||
Some('L') => HashAlgorithm::Scrypt,
|
|
||||||
// S9..S21 and T9..T21 (and future revisions) are all SHA-256.
|
|
||||||
Some('S') | Some('T') => HashAlgorithm::SHA256,
|
|
||||||
_ => HashAlgorithm::Unknown,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AntMinerV2020 {
|
impl AntMinerV2020 {
|
||||||
pub fn new(ip: IpAddr, model: impl MinerModel) -> Self {
|
pub fn new(ip: IpAddr, model: impl MinerModel) -> Self {
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"de321c89f62a60690ba07d6bb145ac688c6141c458638e68b3ed36b50b8de1f1","Cargo.lock":"5942ec7c9cf5c201bd32442d65020dc3ae72e33cb5aaf374b2a26501571a1487","Cargo.toml":"cb9ee00cbb415fa66a71a7d4822839bb3552336ec9ab975ae7b1137c711449cb","Cargo.toml.orig":"08409c395e4d502015da62e97efdc9c5bc6e3076031144f3f5aa35c900c7c735","src/backends/mod.rs":"26591e67688f8d015242295dde5050c4b34986e9980018a855346291a0472206","src/backends/v1_2_0/mod.rs":"a1b0eb9e2e57cad0190eb8f31dafff0999e31c3602db2b8d84e9dd45c955b623","src/backends/v1_2_0/web.rs":"ac89f16bf623f7d85590d34b45c99b0e522d9d434b4c22af7fa8a8a653e09d2e","src/backends/v1_3_0/mod.rs":"9aa230fe942ca775f812300f0041f5565861ef32ad73207e48d02b41e423ee25","src/backends/v1_3_0/web.rs":"1ec4cbe6bdc26f165d9e54e9bf2aac4c3706357ce4677dc21113710d4a26c3c1","src/firmware.rs":"168eeffaef90cb1525bb2e126e73905b5205d49215437263813e30323f6b7a05","src/lib.rs":"16ea1c0007fa6d6c86c1f83d3ac9cdf065cd9936cd52f35ef89c227397bbc54a","src/timezone.rs":"309bf23de1bdc9126bde5db8dabff0d2c0fea797dbf2630a772a18539838a05e"},"package":"1cb662e56f104c0fe45c8ccdac13f60cbcaad45ac228f939c6ac46ff40335052"}
|
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"de321c89f62a60690ba07d6bb145ac688c6141c458638e68b3ed36b50b8de1f1","Cargo.lock":"5942ec7c9cf5c201bd32442d65020dc3ae72e33cb5aaf374b2a26501571a1487","Cargo.toml":"cb9ee00cbb415fa66a71a7d4822839bb3552336ec9ab975ae7b1137c711449cb","Cargo.toml.orig":"08409c395e4d502015da62e97efdc9c5bc6e3076031144f3f5aa35c900c7c735","src/backends/mod.rs":"26591e67688f8d015242295dde5050c4b34986e9980018a855346291a0472206","src/backends/v1_2_0/mod.rs":"f0818aae9410bcf4cf6f2efbb867ce9ea8a7542cc9cf9942be1b99570e2912c4","src/backends/v1_2_0/web.rs":"ac89f16bf623f7d85590d34b45c99b0e522d9d434b4c22af7fa8a8a653e09d2e","src/backends/v1_3_0/mod.rs":"3e1e10869930c72135ec98e69293c0aeb07d4c31c06e8f8301aa1dbfc87552bb","src/backends/v1_3_0/web.rs":"1ec4cbe6bdc26f165d9e54e9bf2aac4c3706357ce4677dc21113710d4a26c3c1","src/firmware.rs":"168eeffaef90cb1525bb2e126e73905b5205d49215437263813e30323f6b7a05","src/lib.rs":"16ea1c0007fa6d6c86c1f83d3ac9cdf065cd9936cd52f35ef89c227397bbc54a","src/timezone.rs":"309bf23de1bdc9126bde5db8dabff0d2c0fea797dbf2630a772a18539838a05e"},"package":"1cb662e56f104c0fe45c8ccdac13f60cbcaad45ac228f939c6ac46ff40335052"}
|
||||||
+66
-4
@@ -1,5 +1,6 @@
|
|||||||
use std::{collections::HashMap, net::IpAddr, str::FromStr, time::Duration};
|
use std::{collections::HashMap, net::IpAddr, str::FromStr, time::Duration};
|
||||||
|
|
||||||
|
use asic_rs_makes_antminer::models::infer_antminer_algo;
|
||||||
use anyhow;
|
use anyhow;
|
||||||
use asic_rs_core::{
|
use asic_rs_core::{
|
||||||
config::{
|
config::{
|
||||||
@@ -17,7 +18,7 @@ use asic_rs_core::{
|
|||||||
DataCollector, DataExtensions, DataExtractor, DataField, DataLocation, get_by_pointer,
|
DataCollector, DataExtensions, DataExtractor, DataField, DataLocation, get_by_pointer,
|
||||||
},
|
},
|
||||||
command::MinerCommand,
|
command::MinerCommand,
|
||||||
device::DeviceInfo,
|
device::{DeviceInfo, HashAlgorithm},
|
||||||
fan::FanData,
|
fan::FanData,
|
||||||
hashrate::{HashRate, HashRateUnit},
|
hashrate::{HashRate, HashRateUnit},
|
||||||
message::{MessageSeverity, MinerComponent, MinerMessage},
|
message::{MessageSeverity, MinerComponent, MinerMessage},
|
||||||
@@ -52,7 +53,14 @@ pub struct VnishV120 {
|
|||||||
impl VnishV120 {
|
impl VnishV120 {
|
||||||
pub fn new(ip: IpAddr, model: impl MinerModel) -> Self {
|
pub fn new(ip: IpAddr, model: impl MinerModel) -> Self {
|
||||||
let auth = Self::default_auth();
|
let auth = Self::default_auth();
|
||||||
let algo = model.hash_algorithm();
|
// A model outside asic-rs' alias table (VNish's "Antminer S19 (88)")
|
||||||
|
// resolves to HashAlgorithm::Unknown, which left its hashrate bucketed
|
||||||
|
// as "Unknown Hashrate". Infer it from the Antminer family letter, as
|
||||||
|
// the stock backend does.
|
||||||
|
let algo = match model.hash_algorithm() {
|
||||||
|
HashAlgorithm::Unknown => infer_antminer_algo(&model.to_string()),
|
||||||
|
known => known,
|
||||||
|
};
|
||||||
VnishV120 {
|
VnishV120 {
|
||||||
ip,
|
ip,
|
||||||
web: VnishWebAPI::new(ip, 80, auth),
|
web: VnishWebAPI::new(ip, 80, auth),
|
||||||
@@ -509,8 +517,24 @@ impl GetHashboards for VnishV120 {
|
|||||||
.and_then(|v| v.pointer("/factory"))
|
.and_then(|v| v.pointer("/factory"))
|
||||||
.and_then(|v| v.as_array());
|
.and_then(|v| v.as_array());
|
||||||
|
|
||||||
let mut hashboards: Vec<BoardData> =
|
// The model's hardware table gives the board count. For a model asic-rs
|
||||||
(0..self.device_info.hardware.board_count().unwrap_or(0) as usize)
|
// does not know (e.g. VNish "Antminer S19 (88)") there is no table, and
|
||||||
|
// sizing from it dropped every live chain -- the boards then vanished
|
||||||
|
// from the data although the miner reports them. Fall back to what the
|
||||||
|
// miner reports: the highest 1-based chain id, so a dead middle board
|
||||||
|
// still keeps its slot.
|
||||||
|
let reported_boards = all_chains
|
||||||
|
.iter()
|
||||||
|
.filter_map(|c| c.pointer("/id").and_then(|v| v.as_u64()))
|
||||||
|
.max()
|
||||||
|
.unwrap_or(0) as usize;
|
||||||
|
let board_count = self
|
||||||
|
.device_info
|
||||||
|
.hardware
|
||||||
|
.board_count()
|
||||||
|
.map(|n| n as usize)
|
||||||
|
.unwrap_or(reported_boards);
|
||||||
|
let mut hashboards: Vec<BoardData> = (0..board_count)
|
||||||
.map(|idx| {
|
.map(|idx| {
|
||||||
BoardData::new(idx as u8, self.device_info.hardware.chips_for_board(idx))
|
BoardData::new(idx as u8, self.device_info.hardware.chips_for_board(idx))
|
||||||
})
|
})
|
||||||
@@ -1524,4 +1548,42 @@ mod tests {
|
|||||||
assert!(config.available.contains(&Tz::Etc__GMT));
|
assert!(config.available.contains(&Tz::Etc__GMT));
|
||||||
assert_eq!(config.available.last(), Some(&Tz::Etc__GMTMinus14));
|
assert_eq!(config.available.last(), Some(&Tz::Etc__GMTMinus14));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Same as the 1.3.x backend: a model with no hardware table (VNish's
|
||||||
|
/// "Antminer S19 (88)") must keep the chains the miner reports instead of
|
||||||
|
/// sizing the board list to zero. Live 1.2.7 units (e.g. 10.4.1.111) run it.
|
||||||
|
#[tokio::test]
|
||||||
|
async fn unknown_model_keeps_the_reported_chains() {
|
||||||
|
let miner = VnishV120::new(
|
||||||
|
IpAddr::from([127, 0, 0, 1]),
|
||||||
|
AntMinerModel::Unknown("ANTMINER S19 (88)".to_string()),
|
||||||
|
);
|
||||||
|
let mut results = HashMap::new();
|
||||||
|
results.insert(
|
||||||
|
MinerCommand::WebAPI {
|
||||||
|
command: "info",
|
||||||
|
parameters: None,
|
||||||
|
},
|
||||||
|
json!({ "miner": "Antminer S19 (88)", "hr_measure": "GH/s", "fw_version": "1.2.7" }),
|
||||||
|
);
|
||||||
|
results.insert(
|
||||||
|
MinerCommand::WebAPI {
|
||||||
|
command: "summary",
|
||||||
|
parameters: None,
|
||||||
|
},
|
||||||
|
json!({ "miner": { "hr_realtime": 82600.0, "chains": [
|
||||||
|
{ "id": 1, "hashrate_rt": 27537.83 },
|
||||||
|
{ "id": 2, "hashrate_rt": 27511.20 },
|
||||||
|
{ "id": 3, "hashrate_rt": 27601.04 }
|
||||||
|
] } }),
|
||||||
|
);
|
||||||
|
let mock_api = MockAPIClient::new(results);
|
||||||
|
let mut collector = DataCollector::new_with_client(&miner, &mock_api);
|
||||||
|
let miner_data = miner.parse_data(collector.collect_all().await);
|
||||||
|
|
||||||
|
assert_eq!(miner_data.hashboards.len(), 3, "one board per reported chain");
|
||||||
|
// ...and its hashrate is SHA-256 (family letter S), not "Unknown".
|
||||||
|
assert_eq!(miner_data.hashrate.expect("hashrate").algo, HashAlgorithm::SHA256);
|
||||||
|
assert!(miner_data.hashboards.iter().all(|b| b.hashrate.is_some()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+70
-4
@@ -1,5 +1,6 @@
|
|||||||
use std::{collections::HashMap, net::IpAddr, str::FromStr, time::Duration};
|
use std::{collections::HashMap, net::IpAddr, str::FromStr, time::Duration};
|
||||||
|
|
||||||
|
use asic_rs_makes_antminer::models::infer_antminer_algo;
|
||||||
use anyhow;
|
use anyhow;
|
||||||
use asic_rs_core::{
|
use asic_rs_core::{
|
||||||
config::{
|
config::{
|
||||||
@@ -17,7 +18,7 @@ use asic_rs_core::{
|
|||||||
DataCollector, DataExtensions, DataExtractor, DataField, DataLocation, get_by_pointer,
|
DataCollector, DataExtensions, DataExtractor, DataField, DataLocation, get_by_pointer,
|
||||||
},
|
},
|
||||||
command::MinerCommand,
|
command::MinerCommand,
|
||||||
device::DeviceInfo,
|
device::{DeviceInfo, HashAlgorithm},
|
||||||
fan::FanData,
|
fan::FanData,
|
||||||
hashrate::{HashRate, HashRateUnit},
|
hashrate::{HashRate, HashRateUnit},
|
||||||
message::{MessageSeverity, MinerComponent, MinerMessage},
|
message::{MessageSeverity, MinerComponent, MinerMessage},
|
||||||
@@ -52,7 +53,14 @@ pub struct VnishV130 {
|
|||||||
impl VnishV130 {
|
impl VnishV130 {
|
||||||
pub fn new(ip: IpAddr, model: impl MinerModel) -> Self {
|
pub fn new(ip: IpAddr, model: impl MinerModel) -> Self {
|
||||||
let auth = Self::default_auth();
|
let auth = Self::default_auth();
|
||||||
let algo = model.hash_algorithm();
|
// A model outside asic-rs' alias table (VNish's "Antminer S19 (88)")
|
||||||
|
// resolves to HashAlgorithm::Unknown, which left its hashrate bucketed
|
||||||
|
// as "Unknown Hashrate". Infer it from the Antminer family letter, as
|
||||||
|
// the stock backend does.
|
||||||
|
let algo = match model.hash_algorithm() {
|
||||||
|
HashAlgorithm::Unknown => infer_antminer_algo(&model.to_string()),
|
||||||
|
known => known,
|
||||||
|
};
|
||||||
VnishV130 {
|
VnishV130 {
|
||||||
ip,
|
ip,
|
||||||
web: VnishWebAPI::new(ip, 80, auth),
|
web: VnishWebAPI::new(ip, 80, auth),
|
||||||
@@ -516,8 +524,24 @@ impl GetHashboards for VnishV130 {
|
|||||||
.and_then(|v| v.pointer("/factory"))
|
.and_then(|v| v.pointer("/factory"))
|
||||||
.and_then(|v| v.as_array());
|
.and_then(|v| v.as_array());
|
||||||
|
|
||||||
let mut hashboards: Vec<BoardData> =
|
// The model's hardware table gives the board count. For a model asic-rs
|
||||||
(0..self.device_info.hardware.board_count().unwrap_or(0) as usize)
|
// does not know (e.g. VNish "Antminer S19 (88)") there is no table, and
|
||||||
|
// sizing from it dropped every live chain -- the boards then vanished
|
||||||
|
// from the data although the miner reports them. Fall back to what the
|
||||||
|
// miner reports: the highest 1-based chain id, so a dead middle board
|
||||||
|
// still keeps its slot.
|
||||||
|
let reported_boards = all_chains
|
||||||
|
.iter()
|
||||||
|
.filter_map(|c| c.pointer("/id").and_then(|v| v.as_u64()))
|
||||||
|
.max()
|
||||||
|
.unwrap_or(0) as usize;
|
||||||
|
let board_count = self
|
||||||
|
.device_info
|
||||||
|
.hardware
|
||||||
|
.board_count()
|
||||||
|
.map(|n| n as usize)
|
||||||
|
.unwrap_or(reported_boards);
|
||||||
|
let mut hashboards: Vec<BoardData> = (0..board_count)
|
||||||
.map(|idx| {
|
.map(|idx| {
|
||||||
BoardData::new(idx as u8, self.device_info.hardware.chips_for_board(idx))
|
BoardData::new(idx as u8, self.device_info.hardware.chips_for_board(idx))
|
||||||
})
|
})
|
||||||
@@ -1661,4 +1685,46 @@ mod tests {
|
|||||||
assert!(config.available.contains(&Tz::Etc__GMT));
|
assert!(config.available.contains(&Tz::Etc__GMT));
|
||||||
assert_eq!(config.available.last(), Some(&Tz::Etc__GMTMinus14));
|
assert_eq!(config.available.last(), Some(&Tz::Etc__GMTMinus14));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A model asic-rs has no hardware table for -- VNish reports the 88-chip
|
||||||
|
/// S19 as "Antminer S19 (88)" -- must still surface the boards the miner
|
||||||
|
/// reports. Sizing the board list from the (absent) table dropped all
|
||||||
|
/// three live chains, so the GUI drew no hashboard icons for a hashing
|
||||||
|
/// miner. Chain values match the live 10.4.0.179 unit.
|
||||||
|
#[tokio::test]
|
||||||
|
async fn unknown_model_keeps_the_reported_chains() {
|
||||||
|
let miner = VnishV130::new(
|
||||||
|
IpAddr::from([127, 0, 0, 1]),
|
||||||
|
AntMinerModel::Unknown("ANTMINER S19 (88)".to_string()),
|
||||||
|
);
|
||||||
|
let mut results = HashMap::new();
|
||||||
|
results.insert(
|
||||||
|
web("info"),
|
||||||
|
json!({ "miner": "Antminer S19 (88)", "model": "s19-88", "hr_measure": "GH/s" }),
|
||||||
|
);
|
||||||
|
results.insert(
|
||||||
|
web("summary"),
|
||||||
|
json!({
|
||||||
|
"miner": {
|
||||||
|
"hr_realtime": 82600.0,
|
||||||
|
"chains": [
|
||||||
|
{ "id": 1, "hashrate_rt": 27537.83, "chip_statuses": { "grey": 88 } },
|
||||||
|
{ "id": 2, "hashrate_rt": 27511.20, "chip_statuses": { "grey": 88 } },
|
||||||
|
{ "id": 3, "hashrate_rt": 27601.04, "chip_statuses": { "grey": 88 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
let mock_api = MockAPIClient::new(results);
|
||||||
|
let mut collector = DataCollector::new_with_client(&miner, &mock_api);
|
||||||
|
let miner_data = miner.parse_data(collector.collect_all().await);
|
||||||
|
|
||||||
|
assert_eq!(miner_data.hashboards.len(), 3, "one board per reported chain");
|
||||||
|
// ...and its hashrate is SHA-256 (family letter S), not "Unknown".
|
||||||
|
assert_eq!(miner_data.hashrate.expect("hashrate").algo, HashAlgorithm::SHA256);
|
||||||
|
for (i, board) in miner_data.hashboards.iter().enumerate() {
|
||||||
|
assert_eq!(board.position as usize, i);
|
||||||
|
assert!(board.hashrate.is_some(), "board {i} keeps its live hashrate");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"aaaa0f14e3aff2543d3d09a4515efa5ab439f0651a36b582e87b9843d0475752","Cargo.lock":"58da2f3399ff680bf7d619204897b4edf5c03d336a8c3cceb54c9aba280bfed1","Cargo.toml":"57f92bf3808fa6f468dbabf43763a808d9ead128eef83b748f940ef3b219a80e","Cargo.toml.orig":"cbfb99fc843dd61ad2025dcfc16bd435afd2b6d43c2c983867af08af415916f1","src/hardware.rs":"6a52c19b38be83fe47ccf8f6c6fe3b7d9597575b79366fbc678ea3586953dd52","src/lib.rs":"b2f55767a7f3fdacb1e898c5cb961c2dec8481823f94386ee67628960e91bf7d","src/make.rs":"e968e4dbd745d485fc9ad4c5a4c081d679eddce11f66e572f81f2dbe37ede3f0","src/models.rs":"b4ea44fc627ff6c8b41bf8758d6ce6074aa690fe9f6c95a9cb3d1cdbd00e51d6"},"package":"67cca6e6bf4ac14562084ce7534521ffa7cd313fa39e2392f98ff98a047a4353"}
|
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"aaaa0f14e3aff2543d3d09a4515efa5ab439f0651a36b582e87b9843d0475752","Cargo.lock":"58da2f3399ff680bf7d619204897b4edf5c03d336a8c3cceb54c9aba280bfed1","Cargo.toml":"57f92bf3808fa6f468dbabf43763a808d9ead128eef83b748f940ef3b219a80e","Cargo.toml.orig":"cbfb99fc843dd61ad2025dcfc16bd435afd2b6d43c2c983867af08af415916f1","src/hardware.rs":"6a52c19b38be83fe47ccf8f6c6fe3b7d9597575b79366fbc678ea3586953dd52","src/lib.rs":"b2f55767a7f3fdacb1e898c5cb961c2dec8481823f94386ee67628960e91bf7d","src/make.rs":"e968e4dbd745d485fc9ad4c5a4c081d679eddce11f66e572f81f2dbe37ede3f0","src/models.rs":"11bb8edd2417dbbd8754b56d35488db5e3d4655e16e71eee85291fabea876e99"},"package":"67cca6e6bf4ac14562084ce7534521ffa7cd313fa39e2392f98ff98a047a4353"}
|
||||||
+23
@@ -201,6 +201,29 @@ pub enum AntMinerModel {
|
|||||||
Unknown(String),
|
Unknown(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Infer an Antminer's hash algorithm from its model-family letter, for models
|
||||||
|
/// asic-rs' alias table doesn't recognise (round 13 #5). Only the families whose
|
||||||
|
/// entire product line shares one algorithm are inferred; anything ambiguous
|
||||||
|
/// (the K-series spans Kadena/KHeavyHash/Eaglesong, DR is Blake256 while D is
|
||||||
|
/// X11) is left Unknown rather than guessed wrong. Shared by every firmware
|
||||||
|
/// backend that runs on Antminer hardware (stock, VNish).
|
||||||
|
pub fn infer_antminer_algo(model: &str) -> HashAlgorithm {
|
||||||
|
let upper = model.to_ascii_uppercase();
|
||||||
|
let name = upper
|
||||||
|
.strip_prefix("ANTMINER ")
|
||||||
|
.unwrap_or(&upper)
|
||||||
|
.trim_start();
|
||||||
|
match name.chars().next() {
|
||||||
|
// Z9 / Z11 / Z15 / Z15 Pro / Z15J -- the whole Z line is Equihash.
|
||||||
|
Some('Z') => HashAlgorithm::Equihash,
|
||||||
|
// L3+ / L7 / L9 / L11 -- the whole L line is Scrypt.
|
||||||
|
Some('L') => HashAlgorithm::Scrypt,
|
||||||
|
// S9..S21 and T9..T21 (and future revisions) are all SHA-256.
|
||||||
|
Some('S') | Some('T') => HashAlgorithm::SHA256,
|
||||||
|
_ => HashAlgorithm::Unknown,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FromStr for AntMinerModel {
|
impl FromStr for AntMinerModel {
|
||||||
type Err = ModelSelectionError;
|
type Err = ModelSelectionError;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user