Initialize Alkane OS target matrix and release gates
main-release-gate / verify-and-release (push) Failing after 4s
next-build / build (push) Successful in 4s

This commit is contained in:
2026-10-13 11:13:39 -06:00
commit 3ab9d1a4bf
14 changed files with 1320 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
name: main-release-gate
on:
push:
branches: [main]
jobs:
verify-and-release:
runs-on: alkane-ci
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Formatting
run: cargo fmt --check
- name: Quality
run: cargo clippy --all-targets --locked -- -D warnings
- name: Build
run: cargo build --release --locked
- name: Unit and workflow tests
run: cargo test --locked
- name: Microbenchmarks
run: |
set -o pipefail
cargo test --release --locked -- --ignored --nocapture | tee bench-current.txt
- name: Pairing and simulator conformance
run: python3 ci/check-conformance.py
- name: Select release version
id: version
run: python3 ci/version.py main >> "$GITHUB_OUTPUT"
- name: Package source and benchmark result
if: steps.version.outputs.release == 'true'
run: |
mkdir -p dist
git archive --format=tar.gz --output="dist/alkane-os-${{ steps.version.outputs.version }}-source.tar.gz" HEAD
cp bench-current.txt dist/
- name: Create private release
if: steps.version.outputs.release == 'true'
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python3 ci/release.py "${{ steps.version.outputs.tag }}" false "dist/alkane-os-${{ steps.version.outputs.version }}-source.tar.gz" dist/bench-current.txt
+30
View File
@@ -0,0 +1,30 @@
name: next-build
on:
push:
branches: [next]
jobs:
build:
runs-on: alkane-ci
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build release candidate
run: cargo build --release --locked
- name: Select candidate version
id: version
run: python3 ci/version.py next >> "$GITHUB_OUTPUT"
- name: Package source and build output
if: steps.version.outputs.release == 'true'
run: |
mkdir -p dist
git archive --format=tar.gz --output="dist/alkane-os-${{ steps.version.outputs.version }}-source.tar.gz" HEAD
cp target/release/libalkane_os.rlib dist/
- name: Create private prerelease
if: steps.version.outputs.release == 'true'
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python3 ci/release.py "${{ steps.version.outputs.tag }}" true "dist/alkane-os-${{ steps.version.outputs.version }}-source.tar.gz"
+4
View File
@@ -0,0 +1,4 @@
/target/
/dist/
/coverage/
__pycache__/
Generated
+7
View File
@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "alkane-os"
version = "0.1.0"
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "alkane-os"
version = "0.1.0"
edition = "2021"
license = "MIT"
description = "Portable mining and tuning core for Alkane control boards"
[lib]
name = "alkane_os"
[profile.release]
lto = true
codegen-units = 1
+22
View File
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2026 BlueFlare
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+36
View File
@@ -0,0 +1,36 @@
# Alkane OS
Portable mining, tuning, and management logic for Alkane control boards. The
source is MIT licensed. `alkane-sdk` owns the board images and supplies the
hardware backend at build time. This repository has no on-board web frontend;
the intended management surfaces are SSH, cgminer-compatible port 4028, and a
minimal API.
## Status
This is the initial interface and release tooling. It does not mine yet. A
target in the matrix is an obligation to implement and validate, not a claim
of support. All 64 theoretical same-vendor controller/chip pairings are in
scope: 52 Bitmain and 12 WhatsMiner. For pairings a stock image rejects, the
simulator must record the first genuine rejection gate and Alkane OS must mine.
No live board is required by CI. Bench devices supply captures and independent
validation of the simulator.
The `main` branch has full tests and a conformance gate; releases are created
only after every required cell passes. `next` runs a build check and produces
release candidates. `ci/version-x.txt` is the manually edited major version.
For this repository, Y changes when the mining protocol, HAL contract, tuning
policy or API changes; Z changes for compatible fixes and packaging updates.
## Local checks
```sh
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test
python3 ci/check-conformance.py
```
The last command currently fails because simulator and device evidence are
still pending. It is a release gate, not a unit test.
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env python3
"""Fail the final release gate until every target has traceable evidence."""
import json
import pathlib
import sys
manifest = json.loads(pathlib.Path("ci/conformance.json").read_text())
rows = manifest["targets"]
expected = {(board, chip) for board in manifest["boards"] for chip in manifest["chips"]
if manifest["vendors"][board] == manifest["vendors"][chip]}
actual = {(row["board"], row["chip"]) for row in rows}
if actual != expected or len(rows) != len(expected):
sys.exit(f"matrix mismatch: {len(actual)} present, {len(expected)} expected")
required = ("sdk_image_sha256", "stock_image_sha256", "stock_result",
"alkane_share_accept_capture", "simulator_trace_sha256",
"bench_validation")
incomplete = []
for row in rows:
missing = [field for field in required if not row.get(field)]
if row.get("stock_result") not in (None, "mines", "rejects"):
missing.append("stock_result invalid")
if row.get("stock_result") == "rejects" and not row.get("stock_first_rejection"):
missing.append("stock_first_rejection")
if missing:
incomplete.append((row["board"], row["chip"], missing))
if incomplete:
print(f"Conformance pending: {len(incomplete)}/{len(rows)} targets")
for board, chip, missing in incomplete[:8]:
print(f" {board} x {chip}: {', '.join(missing)}")
sys.exit(1)
print(f"Conformance complete: {len(rows)} targets")
+763
View File
@@ -0,0 +1,763 @@
{
"schema": 1,
"boards": [
"am335x-bb",
"zynq-7010",
"cv1835",
"a113d",
"allwinner-h3",
"allwinner-h6",
"allwinner-h616"
],
"chips": [
"BM1384",
"BM1387",
"BM1360",
"BM1362",
"BM1366",
"BM1368",
"BM1370",
"BM1396",
"BM1397",
"BM1398",
"BM1489",
"BM1491",
"BM1746",
"KF1950",
"ID-1968",
"ID-1980",
"ID-1990"
],
"vendors": {
"am335x-bb": "bitmain",
"zynq-7010": "bitmain",
"cv1835": "bitmain",
"a113d": "bitmain",
"allwinner-h3": "whatsminer",
"allwinner-h6": "whatsminer",
"allwinner-h616": "whatsminer",
"BM1384": "bitmain",
"BM1387": "bitmain",
"BM1360": "bitmain",
"BM1362": "bitmain",
"BM1366": "bitmain",
"BM1368": "bitmain",
"BM1370": "bitmain",
"BM1396": "bitmain",
"BM1397": "bitmain",
"BM1398": "bitmain",
"BM1489": "bitmain",
"BM1491": "bitmain",
"BM1746": "bitmain",
"KF1950": "whatsminer",
"ID-1968": "whatsminer",
"ID-1980": "whatsminer",
"ID-1990": "whatsminer"
},
"targets": [
{
"board": "am335x-bb",
"chip": "BM1384",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1387",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1360",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1362",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1366",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1368",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1370",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1396",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1397",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1398",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1489",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1491",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "am335x-bb",
"chip": "BM1746",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1384",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1387",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1360",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1362",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1366",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1368",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1370",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1396",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1397",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1398",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1489",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1491",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "zynq-7010",
"chip": "BM1746",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1384",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1387",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1360",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1362",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1366",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1368",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1370",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1396",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1397",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1398",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1489",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1491",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "cv1835",
"chip": "BM1746",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1384",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1387",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1360",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1362",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1366",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1368",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1370",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1396",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1397",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1398",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1489",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1491",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "a113d",
"chip": "BM1746",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h3",
"chip": "KF1950",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h3",
"chip": "ID-1968",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h3",
"chip": "ID-1980",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h3",
"chip": "ID-1990",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h6",
"chip": "KF1950",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h6",
"chip": "ID-1968",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h6",
"chip": "ID-1980",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h6",
"chip": "ID-1990",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h616",
"chip": "KF1950",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h616",
"chip": "ID-1968",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h616",
"chip": "ID-1980",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
},
{
"board": "allwinner-h616",
"chip": "ID-1990",
"sdk_image_sha256": null,
"stock_image_sha256": null,
"stock_result": null,
"stock_first_rejection": null,
"alkane_share_accept_capture": null,
"simulator_trace_sha256": null,
"bench_validation": null
}
]
}
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env python3
"""Create one Gitea release and attach files using the runner's scoped token."""
import json
import os
import pathlib
import sys
import urllib.error
import urllib.parse
import urllib.request
def request(url, payload, content_type):
headers = {
"Authorization": "token " + os.environ["GITEA_TOKEN"],
"Content-Type": content_type,
}
req = urllib.request.Request(url, data=payload, headers=headers, method="POST")
with urllib.request.urlopen(req, timeout=60) as response:
return json.load(response)
def main():
if len(sys.argv) < 4:
sys.exit("usage: release.py TAG PRERELEASE FILE [FILE ...]")
tag, prerelease, *files = sys.argv[1:]
api = os.environ.get("GITHUB_API_URL", "https://gitea.bluefla.re/api/v1").rstrip("/")
repo = os.environ["GITHUB_REPOSITORY"]
sha = os.environ["GITHUB_SHA"]
body = f"Automated Alkane OS build from {sha}. Conformance results are in the repository."
metadata = {
"tag_name": tag,
"target_commitish": sha,
"name": tag,
"body": body,
"prerelease": prerelease.lower() == "true",
}
try:
release = request(f"{api}/repos/{repo}/releases", json.dumps(metadata).encode(), "application/json")
except urllib.error.HTTPError as exc:
sys.exit(f"release creation failed: HTTP {exc.code}")
release_id = release["id"]
for name in files:
path = pathlib.Path(name)
query = urllib.parse.urlencode({"name": path.name})
try:
request(f"{api}/repos/{repo}/releases/{release_id}/assets?{query}",
path.read_bytes(), "application/octet-stream")
except urllib.error.HTTPError as exc:
sys.exit(f"asset upload failed for {path.name}: HTTP {exc.code}")
print(f"Created {tag} with {len(files)} assets")
if __name__ == "__main__":
main()
+1
View File
@@ -0,0 +1 @@
0
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env python3
"""Select a release tag from Git history. The major version is manual."""
import argparse
import pathlib
import re
import subprocess
def git(*args):
return subprocess.check_output(["git", *args], text=True).strip()
def versions(branch):
suffix = r"" if branch == "main" else r"-rc\.(\d+)"
pattern = re.compile(r"^v(\d+)\.(\d+)\.(\d+)" + suffix + r"$")
result = []
for tag in git("tag", "-l", "v*").splitlines():
match = pattern.fullmatch(tag)
if match:
result.append((tuple(map(int, match.groups())), tag))
return sorted(result)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("branch", choices=("main", "next"))
args = parser.parse_args()
major = int(pathlib.Path("ci/version-x.txt").read_text().strip())
finals = versions("main")
previous = finals[-1] if finals else None
if previous and previous[0][0] > major:
raise SystemExit("manual major version is behind the latest release")
if previous and previous[0][0] == major:
_, minor, patch = previous[0]
changed = git("diff", "--name-only", previous[1], "HEAD").splitlines()
if not changed:
print("release=false")
return
feature = any(path.startswith("src/") or path == "Cargo.toml" for path in changed)
minor, patch = (minor + 1, 0) if feature else (minor, patch + 1)
else:
minor, patch = (1, 0) if major == 0 else (0, 0)
base = f"v{major}.{minor}.{patch}"
if args.branch == "next":
candidates = [parts[0][3] for parts in versions("next") if parts[0][:3] == (major, minor, patch)]
tag = f"{base}-rc.{max(candidates, default=0) + 1}"
else:
tag = base
print("release=true")
print(f"tag={tag}")
print(f"version={tag[1:]}")
if __name__ == "__main__":
main()
+225
View File
@@ -0,0 +1,225 @@
//! Board independent policy and hardware interfaces for Alkane OS.
//!
//! An entry in the target matrix is a development obligation, not a claim that
//! the pairing already mines. Hardware backends are supplied by SDK images.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Vendor {
Bitmain,
Whatsminer,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Algorithm {
Sha256,
Scrypt,
Equihash,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct ControlBoard {
pub id: &'static str,
pub vendor: Vendor,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct HashChip {
pub id: &'static str,
pub vendor: Vendor,
pub algorithm: Algorithm,
}
pub const CONTROL_BOARDS: [ControlBoard; 7] = [
ControlBoard {
id: "am335x-bb",
vendor: Vendor::Bitmain,
},
ControlBoard {
id: "zynq-7010",
vendor: Vendor::Bitmain,
},
ControlBoard {
id: "cv1835",
vendor: Vendor::Bitmain,
},
ControlBoard {
id: "a113d",
vendor: Vendor::Bitmain,
},
ControlBoard {
id: "allwinner-h3",
vendor: Vendor::Whatsminer,
},
ControlBoard {
id: "allwinner-h6",
vendor: Vendor::Whatsminer,
},
ControlBoard {
id: "allwinner-h616",
vendor: Vendor::Whatsminer,
},
];
pub const HASH_CHIPS: [HashChip; 17] = [
HashChip {
id: "BM1384",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "BM1387",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "BM1360",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "BM1362",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "BM1366",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "BM1368",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "BM1370",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "BM1396",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "BM1397",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "BM1398",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "BM1489",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Scrypt,
},
HashChip {
id: "BM1491",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Scrypt,
},
HashChip {
id: "BM1746",
vendor: Vendor::Bitmain,
algorithm: Algorithm::Equihash,
},
HashChip {
id: "KF1950",
vendor: Vendor::Whatsminer,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "ID-1968",
vendor: Vendor::Whatsminer,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "ID-1980",
vendor: Vendor::Whatsminer,
algorithm: Algorithm::Sha256,
},
HashChip {
id: "ID-1990",
vendor: Vendor::Whatsminer,
algorithm: Algorithm::Sha256,
},
];
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Target {
pub control: ControlBoard,
pub chip: HashChip,
}
impl Target {
pub fn new(control: ControlBoard, chip: HashChip) -> Option<Self> {
(control.vendor == chip.vendor).then_some(Self { control, chip })
}
}
/// Every same-vendor theoretical pairing is in scope for Alkane OS.
pub fn target_matrix() -> impl Iterator<Item = Target> {
CONTROL_BOARDS.into_iter().flat_map(|control| {
HASH_CHIPS
.into_iter()
.filter_map(move |chip| Target::new(control, chip))
})
}
/// Hardware operations implemented by a board backend in the SDK image.
/// The methods deliberately expose no assumed UART, FPGA or Bitmicro layout.
pub trait HardwareBackend {
type Error;
fn send_frame(&mut self, chain: u8, frame: &[u8]) -> Result<(), Self::Error>;
fn receive_frame(&mut self, chain: u8, frame: &mut [u8]) -> Result<usize, Self::Error>;
fn set_chain_reset(&mut self, chain: u8, asserted: bool) -> Result<(), Self::Error>;
fn set_fan_target(&mut self, fan: u8, percent: u8) -> Result<(), Self::Error>;
fn read_temperature_mc(&mut self, sensor: u8) -> Result<i32, Self::Error>;
fn set_psu_enabled(&mut self, enabled: bool) -> Result<(), Self::Error>;
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PowerDecision {
Hold,
Stop,
}
/// A safe starting policy: no hashing while temperature is unknown or unsafe.
/// Board-specific thresholds will come from measured, revision-specific data.
pub fn power_decision(temperature_mc: Option<i32>, max_mc: i32) -> PowerDecision {
match temperature_mc {
Some(value) if value < max_mc => PowerDecision::Hold,
_ => PowerDecision::Stop,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn all_theoretical_same_vendor_targets_are_included() {
let targets: Vec<_> = target_matrix().collect();
assert_eq!(targets.len(), 4 * 13 + 3 * 4);
assert!(targets.iter().all(|t| t.control.vendor == t.chip.vendor));
for control in CONTROL_BOARDS {
for chip in HASH_CHIPS {
assert_eq!(
targets.contains(&Target { control, chip }),
control.vendor == chip.vendor
);
}
}
}
#[test]
fn unknown_or_hot_sensor_stops_power() {
assert_eq!(power_decision(None, 80_000), PowerDecision::Stop);
assert_eq!(power_decision(Some(80_000), 80_000), PowerDecision::Stop);
assert_eq!(power_decision(Some(79_999), 80_000), PowerDecision::Hold);
}
}
+32
View File
@@ -0,0 +1,32 @@
use alkane_os::{power_decision, target_matrix};
use std::hint::black_box;
use std::time::Instant;
fn measure(name: &str, iterations: u64, mut f: impl FnMut()) {
let started = Instant::now();
for _ in 0..iterations {
f();
}
let ns = started.elapsed().as_nanos() as f64 / iterations as f64;
println!("BENCH {name} {ns:.3} ns/op");
}
#[test]
#[ignore = "microbenchmark"]
fn bench_target_matrix() {
measure("target_matrix", 20_000, || {
black_box(
target_matrix()
.filter(|target| black_box(target.chip.algorithm) == alkane_os::Algorithm::Sha256)
.count(),
);
});
}
#[test]
#[ignore = "microbenchmark"]
fn bench_power_policy() {
measure("power_policy", 100_000, || {
black_box(power_decision(black_box(Some(64_000)), 80_000));
});
}