Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f558ef596 | ||
|
|
576f834169 | ||
|
|
093cb62212 | ||
|
|
2e42bedb84 | ||
|
|
0b785eebb5 | ||
|
|
885a71b6fe | ||
|
|
8672507fa4 | ||
|
|
37f1f8433b | ||
|
|
b703c757e4 | ||
|
|
98d891fc67 | ||
|
|
d6e043d79f | ||
|
|
ba286758c7 | ||
|
|
b65e6bc9f1 | ||
|
|
f7aeeaa2eb | ||
|
|
1b0607cbd8 | ||
|
|
7c361aecd9 | ||
|
|
212c9198eb | ||
|
|
be0a57a1d9 |
@@ -0,0 +1,36 @@
|
||||
name: public-benchmark-pages
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '*/15 * * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: alkane-os-public-benchmark-pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: alkane-verify
|
||||
container:
|
||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install SSH client
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq --no-install-recommends openssh-client
|
||||
- name: Render measured benchmark history
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: python3 ci/bench_history.py render
|
||||
- name: Publish public benchmark page
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
BENCH_PAGES_DEPLOY_KEY: ${{ secrets.BENCH_PAGES_DEPLOY_KEY }}
|
||||
run: python3 ci/publish-bench-pages.py os
|
||||
- name: Clean generated page
|
||||
if: always()
|
||||
run: python3 ci/cleanup-generated.py
|
||||
@@ -36,8 +36,15 @@ jobs:
|
||||
run: python3 ci/test-metrics.py
|
||||
- name: Release evidence gate checks
|
||||
run: python3 ci/test-conformance.py
|
||||
- name: Research and experiment report checks
|
||||
run: |
|
||||
python3 ci/test-evidence-status.py
|
||||
python3 ci/test-experiment-priority.py
|
||||
python3 ci/test-pr-surface.py
|
||||
- name: Release publication checks
|
||||
run: python3 ci/test-release.py
|
||||
- name: Release version checks
|
||||
run: python3 ci/test-version.py
|
||||
- name: CI cleanup containment checks
|
||||
run: python3 ci/test-cleanup-generated.py
|
||||
- name: Quality
|
||||
@@ -99,11 +106,12 @@ jobs:
|
||||
with:
|
||||
name: alkane-os-benchmark-site-preview
|
||||
path: bench-site/index.html
|
||||
- name: Publish public benchmark page
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
BENCH_PAGES_DEPLOY_KEY: ${{ secrets.BENCH_PAGES_DEPLOY_KEY }}
|
||||
run: python3 ci/publish-bench-pages.py os
|
||||
- name: Separate research from release evidence
|
||||
run: python3 ci/evidence_status.py --output evidence-status-current.json
|
||||
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7
|
||||
with:
|
||||
name: alkane-os-evidence-status
|
||||
path: evidence-status-current.json
|
||||
- name: Pairing and simulator conformance
|
||||
run: python3 ci/check-conformance.py
|
||||
- name: Select release version
|
||||
|
||||
@@ -4,13 +4,11 @@ on:
|
||||
push:
|
||||
branches: [next]
|
||||
|
||||
concurrency:
|
||||
group: alkane-os-next
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: alkane-ci
|
||||
runs-on: alkane-verify
|
||||
container:
|
||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948
|
||||
env:
|
||||
CARGO_TARGET_DIR: target
|
||||
steps:
|
||||
@@ -18,7 +16,7 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Build release candidate
|
||||
run: cargo build --release --locked
|
||||
run: cargo build --release --offline --locked
|
||||
- name: Select candidate version
|
||||
id: version
|
||||
run: python3 ci/version.py next >> "$GITHUB_OUTPUT"
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
name: source-pr
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [next, main]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: alkane-os-source-pr-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
source:
|
||||
runs-on: alkane-fast
|
||||
container:
|
||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948
|
||||
env:
|
||||
CARGO_TARGET_DIR: target
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Detect changed surface
|
||||
id: surface
|
||||
run: python3 ci/pr_surface.py >> "$GITHUB_OUTPUT"
|
||||
- name: Check patch whitespace
|
||||
run: |
|
||||
if [ "${GITHUB_EVENT_NAME:-}" = pull_request ]; then
|
||||
base="$(git merge-base HEAD "origin/$GITHUB_BASE_REF")"
|
||||
git diff --check "$base" HEAD
|
||||
else
|
||||
git diff --check HEAD^ HEAD
|
||||
fi
|
||||
- name: Check CI and evidence tools
|
||||
if: steps.surface.outputs.surface != 'documentation'
|
||||
run: |
|
||||
python3 -m compileall -q ci
|
||||
for test in ci/test-*.py; do python3 "$test"; done
|
||||
python3 ci/evidence_status.py
|
||||
python3 ci/experiment_priority.py
|
||||
- name: Install source formatter
|
||||
if: steps.surface.outputs.surface == 'rust'
|
||||
run: rustup component add rustfmt
|
||||
- name: Check source formatting
|
||||
if: steps.surface.outputs.surface == 'rust'
|
||||
run: cargo fmt --check
|
||||
- name: Check changed Rust source
|
||||
if: steps.surface.outputs.surface == 'rust'
|
||||
run: |
|
||||
if [ "${GITHUB_BASE_REF:-}" = main ]; then
|
||||
cargo build --release --offline --locked
|
||||
else
|
||||
cargo check --offline --locked
|
||||
fi
|
||||
- name: Clean generated build
|
||||
if: always()
|
||||
run: python3 ci/cleanup-generated.py
|
||||
@@ -10,84 +10,56 @@
|
||||

|
||||

|
||||
|
||||
Mining and tuning core for Alkane control boards. The SDK builds board images
|
||||
and supplies the hardware backend. Management uses SSH and an optional local,
|
||||
read-only cgminer-style status endpoint; no web frontend runs on the board.
|
||||
Rust mining and tuning core for Alkane control boards. The
|
||||
[SDK](https://gitea.bluefla.re/blueflare/alkane-sdk) builds board images and
|
||||
provides the hardware backend. The miner has no on-board web frontend.
|
||||
|
||||
## Status
|
||||
|
||||
The CLI lists target obligations with `alkane-os --list-targets`. It can also
|
||||
mine through the SDK simulator HAL and a Stratum V1 pool. No production board
|
||||
backend is installed.
|
||||
The host miner supports BM1362 and BM1366 through the SDK's simulator HAL and
|
||||
Stratum V1. Tests have replayed 33 captured BM1366 shares and one BM1362
|
||||
share to a loopback pool with matching ACCEPT responses. Production board
|
||||
control is still under development.
|
||||
|
||||
The library has a versioned Unix-socket HAL client, BM1362 and BM1366
|
||||
host mining sessions, Stratum V1 job and share handling, SHA-256d share
|
||||
checks, and a Litecoin Scrypt proof verifier. Its fault path requests PSU
|
||||
shutdown on a sensor error. Failed shutdown faults the miner until a retry
|
||||
succeeds. Work IDs stay reserved until a confirmed chain reset or PSU
|
||||
shutdown. The backend still needs a power lease, an independent watchdog,
|
||||
and a board-validated temperature limit.
|
||||
The BM1370 module encodes a captured S21 Pro job and parses captured nonce
|
||||
frames. Work-ID mapping, chain control, and pool acceptance remain open.
|
||||
|
||||
Host tests replayed real captured nonces through the SDK HAL and a strict
|
||||
loopback pool: 33 distinct BM1366 shares and one BM1362 share received
|
||||
matching ACCEPT responses. The 33rd BM1366 job tested safe work-ID reuse
|
||||
after a chain reset. These tests do not establish physical chain control,
|
||||
stock-firmware boot, or production pool acceptance. The Scrypt verifier
|
||||
matches Litecoin's
|
||||
[block 29255 vector](https://github.com/litecoin-project/litecoin/wiki/Scrypt-proof-of-work);
|
||||
BM1489/BM1491 report handling and L7/L9 mining remain open.
|
||||
The HAL client requests PSU shutdown on sensor faults and reserves work IDs
|
||||
until a confirmed reset or shutdown. A production backend still needs a
|
||||
power lease, watchdog, and validated temperature limits. SHA-256d and
|
||||
Litecoin Scrypt proof verification are implemented; Scrypt chip report
|
||||
handling and mining remain open.
|
||||
|
||||
For a simulator HAL socket and a Stratum V1 pool, set `ALKANE_POOL_PASSWORD`
|
||||
and run `alkane-os --mine-simulator HAL_SOCKET POOL_ADDRESS WORKER BM1366`.
|
||||
Select `BM1362` for that chip's captured job format. The optional argument
|
||||
after the chip stops after that many accepted shares. The command
|
||||
uses the simulator's 80 C temperature limit and exits on a pool or hardware
|
||||
fault. The SDK HAL server must cut power when its client stalls or disconnects.
|
||||
Set `ALKANE_API_LISTEN=127.0.0.1:4028` to expose read-only `summary` and
|
||||
`version` commands during simulator mining. The endpoint accepts cgminer
|
||||
JSON requests or plain command names and ends replies with a NUL byte.
|
||||
It binds only to loopback; access from another machine through SSH. The
|
||||
summary reports observed accepted/rejected shares and process state, without
|
||||
an estimated hashrate. Other cgminer API commands are not yet implemented.
|
||||
Run `alkane-os --list-targets` for the target matrix. Set `POOL_PASSWORD` to
|
||||
the pool password, then mine with a simulator HAL socket and Stratum V1 pool:
|
||||
|
||||
```sh
|
||||
ALKANE_POOL_PASSWORD="$POOL_PASSWORD" alkane-os --mine-simulator HAL_SOCKET POOL_ADDRESS WORKER BM1366
|
||||
```
|
||||
|
||||
Use `BM1362` for that chip. Set `ALKANE_API_LISTEN=127.0.0.1:4028` for
|
||||
read-only `summary` and `version` commands; reach it remotely through SSH.
|
||||
|
||||
## Release gate
|
||||
|
||||
All 64 theoretical same-vendor control-board/chip pairings are required:
|
||||
52 Bitmain and 12 WhatsMiner. A stock image may reject a pairing if the
|
||||
simulator records its first genuine rejection gate; Alkane OS must still
|
||||
mine. CI needs unmodified stock firmware, real captured silicon nonces,
|
||||
pool acceptance at difficulty 1 or higher, and independent bench
|
||||
validation. Bench devices provide captures and validation, not CI execution.
|
||||
The gate is red. See [the evidence contract](ci/CONFORMANCE.md).
|
||||
`main` runs tests, benchmarks, and conformance before release; `next` builds
|
||||
release candidates. The release gate is red. It requires all 64 same-vendor
|
||||
pairings (52 Bitmain, 12 WhatsMiner), unmodified stock firmware, captured
|
||||
silicon nonces, difficulty-1 pool acceptance, and bench-validated models.
|
||||
Stock firmware may faithfully reject a pairing; Alkane OS must mine it.
|
||||
See the [evidence contract](ci/CONFORMANCE.md).
|
||||
|
||||
`main` runs tests, benchmarks, and conformance before release. `next`
|
||||
builds release candidates. Edit `ci/version-x.txt` for a major release;
|
||||
increment the minor version for mining protocol, HAL, tuning policy, or API
|
||||
changes, and the patch version for compatible fixes.
|
||||
|
||||
Badges measure host code only. The CI badge shows the last completed branch
|
||||
attempt and refreshes every 15 minutes when the runner is available.
|
||||
Benchmark deltas compare results from the same CPU class. They
|
||||
do not certify board images or the pairing matrix.
|
||||
The [benchmark history](https://blueflare.gitea.bluefla.re/alkane-benchmarks/os/)
|
||||
is readable without a Gitea login.
|
||||
Badges cover host code, not board conformance. See the public
|
||||
[benchmark history](https://blueflare.gitea.bluefla.re/alkane-benchmarks/os/).
|
||||
|
||||
## Local checks
|
||||
|
||||
```sh
|
||||
export CARGO_TARGET_DIR=/var/tmp/alkane-os-target
|
||||
cargo fmt --check
|
||||
cargo clippy --all-targets -- -D warnings
|
||||
cargo test --locked
|
||||
cargo build --release --locked
|
||||
CARGO_TARGET_DIR=/var/tmp/alkane-os-target cargo test --locked
|
||||
```
|
||||
|
||||
Use an executable target directory if the source mount is `noexec`. The
|
||||
conformance checker requires artifacts from a real CI run; its input format
|
||||
is in [ci/CONFORMANCE.md](ci/CONFORMANCE.md). Rust dependencies are vendored
|
||||
for offline SDK builds and keep their upstream licenses.
|
||||
Use an executable target directory if the source mount is `noexec`.
|
||||
|
||||
## License
|
||||
|
||||
Alkane OS source is [MIT licensed](LICENSE). Vendored dependencies retain
|
||||
their own licenses.
|
||||
[MIT](LICENSE). Vendored dependencies keep their own licenses.
|
||||
|
||||
@@ -5,6 +5,17 @@ currently fails because the simulator and bench evidence producer is not yet
|
||||
implemented. A green Rust build, host HAL replay probe, or rootfs archive does
|
||||
not fill any cell.
|
||||
|
||||
`research-evidence.json` records scoped historical observations with source
|
||||
hashes. `evidence_status.py` reports those separately from declarations in
|
||||
`conformance.json`. Neither research claims nor manifest declarations count
|
||||
as verified release cells. The current-run checker below is the only release
|
||||
validator. `experiment-queue.json` ranks the next protocol and controller
|
||||
experiments by the number of affected cells; blocked work stays visible.
|
||||
The status report names catalog, decoded protocol, stock simulator boot,
|
||||
captured-nonce pool acceptance, physical lifecycle, and complete-cell levels.
|
||||
It leaves current-run verified counts unset; the conformance checker certifies
|
||||
the full cells separately.
|
||||
|
||||
Each CI run must put a JSON report at
|
||||
`ci/evidence/<GITHUB_RUN_ID>/<board>/<chip>.json`. The report binds its
|
||||
`run_id`, `source_commit`, `os_binary_sha256`, `board`, and `chip` to the
|
||||
|
||||
+8
-1
@@ -120,7 +120,7 @@ def render_html(index: dict) -> str:
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("action", choices=("prepare", "publish"))
|
||||
parser.add_argument("action", choices=("prepare", "publish", "render"))
|
||||
args = parser.parse_args()
|
||||
api = os.environ["GITHUB_API_URL"].rstrip("/")
|
||||
repo = os.environ["GITHUB_REPOSITORY"]
|
||||
@@ -135,6 +135,13 @@ def main() -> None:
|
||||
Path("badges/bench-baseline.json").write_text(json.dumps(baseline) + "\n")
|
||||
print(f"Loaded {len(baseline)} prior benchmark measurements")
|
||||
return
|
||||
if args.action == "render":
|
||||
if not index["entries"]:
|
||||
raise ValueError("no measured benchmark history to publish")
|
||||
Path("bench-site").mkdir(exist_ok=True)
|
||||
Path("bench-site/index.html").write_text(render_html(index))
|
||||
print(f"Rendered {len(index['entries'])} measured benchmark commits")
|
||||
return
|
||||
metrics = json.loads(Path("badges/metrics.json").read_text())
|
||||
timestamp = datetime.now(timezone.utc).isoformat(timespec="seconds")
|
||||
index = updated_index(index, sha, metrics, timestamp)
|
||||
|
||||
@@ -10,7 +10,8 @@ import sys
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DIRECTORIES = ("target", "coverage", "dist", "bench-site")
|
||||
FILES = ("tests-current.txt", "bench-current.txt", "quality-current.json")
|
||||
FILES = ("tests-current.txt", "bench-current.txt", "quality-current.json",
|
||||
"evidence-status-current.json")
|
||||
|
||||
|
||||
def cleanup() -> None:
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Summarize research separately from current-run release conformance."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
|
||||
LEVELS = {"catalogued", "protocol_decoded"}
|
||||
DIGEST = re.compile(r"[0-9a-f]{64}\Z")
|
||||
|
||||
|
||||
def summarize(matrix: dict, research: dict) -> dict:
|
||||
if matrix.get("schema") != 1 or research.get("schema") != 1:
|
||||
raise ValueError("unsupported evidence schema")
|
||||
boards = matrix["boards"]
|
||||
chips = matrix["chips"]
|
||||
vendors = matrix["vendors"]
|
||||
expected = {(board, chip) for board in boards for chip in chips
|
||||
if vendors[board] == vendors[chip]}
|
||||
rows = matrix["targets"]
|
||||
actual = [(row["board"], row["chip"]) for row in rows]
|
||||
if set(actual) != expected or len(actual) != len(expected) or len(actual) != 64:
|
||||
raise ValueError("release target matrix is incomplete or duplicated")
|
||||
levels = {"catalogued": set(), "protocol_decoded": set()}
|
||||
for claim in research["claims"]:
|
||||
cell = claim["board"], claim["chip"]
|
||||
level = claim["level"]
|
||||
if cell not in expected or level not in LEVELS:
|
||||
raise ValueError("research claim is outside target matrix or level")
|
||||
if not isinstance(claim.get("scope"), str) or not claim["scope"].strip():
|
||||
raise ValueError("research claim lacks scope")
|
||||
if not isinstance(claim.get("source"), str) or not claim["source"].strip():
|
||||
raise ValueError("research claim lacks provenance")
|
||||
if not isinstance(claim.get("sha256"), str) or not DIGEST.fullmatch(claim["sha256"]):
|
||||
raise ValueError("research claim lacks a source digest")
|
||||
levels[level].add(cell)
|
||||
declared = {
|
||||
"stock_result": sum(row.get("stock_result") in {"mines", "rejects"} for row in rows),
|
||||
"alkane_share_capture": sum(bool(row.get("alkane_share_accept_capture")) for row in rows),
|
||||
"bench_validation": sum(bool(row.get("bench_validation")) for row in rows),
|
||||
}
|
||||
evidence_levels = {
|
||||
"catalogued": {"research_claims": len(levels["catalogued"])},
|
||||
"protocol_decoded": {"research_claims": len(levels["protocol_decoded"])},
|
||||
"stock_simulator_boot": {"manifest_claims_unverified": declared["stock_result"],
|
||||
"current_run_verified": None},
|
||||
"captured_nonce_pool_accept": {
|
||||
"manifest_claims_unverified": declared["alkane_share_capture"],
|
||||
"current_run_verified": None},
|
||||
"physical_install_update_uninstall_recovery": {
|
||||
"manifest_claims_unverified": declared["bench_validation"],
|
||||
"current_run_verified": None},
|
||||
"full_release_cell": {"current_run_verified": None},
|
||||
}
|
||||
return {
|
||||
"schema": 1,
|
||||
"target_cells": len(expected),
|
||||
"research_only": {key: len(value) for key, value in levels.items()},
|
||||
"evidence_levels": evidence_levels,
|
||||
"release_manifest_declarations_unverified": declared,
|
||||
"verified_release_cells": None,
|
||||
"note": "Only check-conformance.py may verify current-run artifacts; research claims never satisfy a release cell",
|
||||
}
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--matrix", type=Path, default=Path("ci/conformance.json"))
|
||||
parser.add_argument("--research", type=Path, default=Path("ci/research-evidence.json"))
|
||||
parser.add_argument("--output", type=Path)
|
||||
args = parser.parse_args()
|
||||
report = summarize(json.loads(args.matrix.read_text()), json.loads(args.research.read_text()))
|
||||
output = json.dumps(report, indent=2, sort_keys=True) + "\n"
|
||||
if args.output:
|
||||
args.output.write_text(output)
|
||||
else:
|
||||
print(output, end="")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"experiments": [
|
||||
{
|
||||
"id": "am335x-original-nand-boot",
|
||||
"kind": "controller",
|
||||
"board": "am335x-bb",
|
||||
"chip": null,
|
||||
"psu": null,
|
||||
"state": "ready_local",
|
||||
"next_evidence": "Boot hash-pinned stock NAND through the original ROM and SPL path; record the first failing register",
|
||||
"blocker": null
|
||||
},
|
||||
{
|
||||
"id": "bm1368-command-and-nonce",
|
||||
"kind": "chip",
|
||||
"board": null,
|
||||
"chip": "BM1368",
|
||||
"psu": null,
|
||||
"state": "needs_machine",
|
||||
"next_evidence": "Capture real BM1368 enumeration, job, and nonce frames on a recovered test unit",
|
||||
"blocker": "No verified BM1368 silicon candidate in the current inventory"
|
||||
},
|
||||
{
|
||||
"id": "zynq-bm1366-fpga-window",
|
||||
"kind": "transport",
|
||||
"board": "zynq-7010",
|
||||
"chip": "BM1366",
|
||||
"psu": "APW121215d/e",
|
||||
"state": "needs_identity",
|
||||
"next_evidence": "Read a bounded FPGA register/FIFO trace on a verified rooted test unit",
|
||||
"blocker": "Historical mule 10.1.2.137 now reports BTM_S21PRO; do not infer BM1366 from its address"
|
||||
},
|
||||
{
|
||||
"id": "a113d-bm1370-apw17-voltage",
|
||||
"kind": "psu",
|
||||
"board": "a113d",
|
||||
"chip": "BM1370",
|
||||
"psu": "APW171215a/c",
|
||||
"state": "needs_identity",
|
||||
"next_evidence": "Decode captured GPIO bit-bang command and read-only voltage response against an independent meter",
|
||||
"blocker": "Historical 10.4.0.192 unit is not currently reachable for confirmation"
|
||||
},
|
||||
{
|
||||
"id": "h6-kf1950-power-and-asic",
|
||||
"kind": "chip_psu",
|
||||
"board": "allwinner-h6",
|
||||
"chip": "KF1950",
|
||||
"psu": "unknown",
|
||||
"state": "needs_machine",
|
||||
"next_evidence": "Observe actual ASIC and PSU bus frames on a matched miner before modeling either device",
|
||||
"blocker": "Current H6 bench board is bare and its recovery RX path is unproven"
|
||||
},
|
||||
{
|
||||
"id": "s19-88-chain-enumeration",
|
||||
"kind": "topology_psu",
|
||||
"board": "a113d",
|
||||
"chip": "BM1362",
|
||||
"psu": "APW121417b",
|
||||
"state": "needs_identity",
|
||||
"next_evidence": "Capture the 88-chip address walk and read-only PSU identity on a rooted matched test unit",
|
||||
"blocker": "10.7.1.190 reports BTM_S19_88, but its SSH key and physical recovery are unverified"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Rank representative experiments without changing the 64-cell release gate."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
STATES = {"ready_local", "needs_identity", "needs_machine"}
|
||||
|
||||
|
||||
def rank(matrix: dict, queue: dict) -> list[dict]:
|
||||
if queue.get("schema") != 1 or matrix.get("schema") != 1:
|
||||
raise ValueError("unsupported experiment schema")
|
||||
targets = {(row["board"], row["chip"]) for row in matrix["targets"]}
|
||||
if len(targets) != 64 or len(matrix["targets"]) != 64:
|
||||
raise ValueError("expected 64 unique release targets")
|
||||
seen = set()
|
||||
result = []
|
||||
for experiment in queue["experiments"]:
|
||||
ident = experiment["id"]
|
||||
if ident in seen:
|
||||
raise ValueError("duplicate experiment id")
|
||||
seen.add(ident)
|
||||
state = experiment["state"]
|
||||
if state not in STATES:
|
||||
raise ValueError("unknown experiment state")
|
||||
board, chip = experiment["board"], experiment["chip"]
|
||||
if board is None and chip is None:
|
||||
raise ValueError("experiment has no target selector")
|
||||
affected = sorted((b, c) for b, c in targets
|
||||
if (board is None or board == b) and (chip is None or chip == c))
|
||||
if not affected:
|
||||
raise ValueError("experiment selects no same-vendor target")
|
||||
if not experiment.get("next_evidence"):
|
||||
raise ValueError("experiment lacks a measurable next result")
|
||||
if state != "ready_local" and not experiment.get("blocker"):
|
||||
raise ValueError("blocked experiment lacks a blocker")
|
||||
result.append({"id": ident, "kind": experiment["kind"], "state": state,
|
||||
"affected_release_cells": len(affected), "board": board,
|
||||
"chip": chip, "psu": experiment["psu"],
|
||||
"next_evidence": experiment["next_evidence"],
|
||||
"blocker": experiment["blocker"]})
|
||||
return sorted(result, key=lambda row: (row["state"] != "ready_local",
|
||||
-row["affected_release_cells"], row["id"]))
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--matrix", type=Path, default=Path("ci/conformance.json"))
|
||||
parser.add_argument("--queue", type=Path, default=Path("ci/experiment-queue.json"))
|
||||
args = parser.parse_args()
|
||||
for item in rank(json.loads(args.matrix.read_text()), json.loads(args.queue.read_text())):
|
||||
print(f"{item['id']}: {item['state']}, {item['affected_release_cells']} cells")
|
||||
print(f" next: {item['next_evidence']}")
|
||||
if item["blocker"]:
|
||||
print(f" blocked: {item['blocker']}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Select a safe fast PR check from the exact merge-base diff."""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def classify(paths: list[str]) -> str:
|
||||
if not paths:
|
||||
return "rust"
|
||||
docs = {"README.md", "LICENSE", "AGENTS.md", "ci/CONFORMANCE.md"}
|
||||
def is_doc(path: str) -> bool:
|
||||
return path in docs or path.startswith("docs/") and path.endswith(".md")
|
||||
def is_tool(path: str) -> bool:
|
||||
return (path.startswith("ci/") and Path(path).suffix in {".py", ".json"}
|
||||
or path.startswith(".gitea/workflows/") and path.endswith(".yml"))
|
||||
if all(is_doc(path) for path in paths):
|
||||
return "documentation"
|
||||
if all(is_doc(path) or is_tool(path) for path in paths):
|
||||
return "tooling"
|
||||
return "rust"
|
||||
|
||||
|
||||
def changed_paths() -> list[str]:
|
||||
if os.environ.get("GITHUB_EVENT_NAME") != "pull_request":
|
||||
return []
|
||||
base = os.environ.get("GITHUB_BASE_REF")
|
||||
if base not in {"next", "main"}:
|
||||
return []
|
||||
try:
|
||||
merge_base = subprocess.check_output(
|
||||
["git", "merge-base", "HEAD", f"origin/{base}"], cwd=ROOT).strip()
|
||||
diff = subprocess.check_output(
|
||||
["git", "diff", "--name-only", "-z", merge_base, "HEAD"], cwd=ROOT)
|
||||
return [path.decode() for path in diff.split(b"\0") if path]
|
||||
except (OSError, UnicodeError, subprocess.CalledProcessError):
|
||||
return []
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open(os.environ["GITHUB_OUTPUT"], "a") as output:
|
||||
output.write(f"surface={classify(changed_paths())}\n")
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"claims": [
|
||||
{
|
||||
"board": "a113d",
|
||||
"chip": "BM1366",
|
||||
"level": "protocol_decoded",
|
||||
"source": "miner-firmware/firmware-analysis/prong-b/aml-112/fullcov/capC1.strace",
|
||||
"sha256": "05303e93f6d00433a6db5a9ee973b6cdb0351f3efa35d293dd172ede7da89d54",
|
||||
"scope": "Historical BM1366 UART enumeration and nonce frames on an A113D S19k Pro"
|
||||
},
|
||||
{
|
||||
"board": "zynq-7010",
|
||||
"chip": "BM1366",
|
||||
"level": "catalogued",
|
||||
"source": "miner-firmware/firmware-analysis/prong-b/xil-137/fullcov/capC1.strace",
|
||||
"sha256": "3daa3f7381580ef87f3b5925d5a03fdb4d2e7cd93a82b943ef2578da3d545607",
|
||||
"scope": "Historical sensor and board observations; FPGA chip data path was not captured"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Research observations cannot promote a target into release conformance."""
|
||||
|
||||
import copy
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parent
|
||||
spec = importlib.util.spec_from_file_location("evidence_status", ROOT / "evidence_status.py")
|
||||
status = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(status)
|
||||
MATRIX = json.loads((ROOT / "conformance.json").read_text())
|
||||
RESEARCH = json.loads((ROOT / "research-evidence.json").read_text())
|
||||
|
||||
|
||||
class EvidenceStatusTest(unittest.TestCase):
|
||||
def test_historical_protocol_does_not_satisfy_release(self):
|
||||
report = status.summarize(MATRIX, RESEARCH)
|
||||
self.assertEqual(report["target_cells"], 64)
|
||||
self.assertEqual(report["research_only"], {"catalogued": 1, "protocol_decoded": 1})
|
||||
self.assertIsNone(report["verified_release_cells"])
|
||||
self.assertEqual(sum(report["release_manifest_declarations_unverified"].values()), 0)
|
||||
for level in ("stock_simulator_boot", "captured_nonce_pool_accept",
|
||||
"physical_install_update_uninstall_recovery", "full_release_cell"):
|
||||
self.assertIsNone(report["evidence_levels"][level]["current_run_verified"])
|
||||
|
||||
def test_rejects_missing_cell_and_unsupported_claim(self):
|
||||
matrix = copy.deepcopy(MATRIX)
|
||||
matrix["targets"].pop()
|
||||
with self.assertRaisesRegex(ValueError, "incomplete"):
|
||||
status.summarize(matrix, RESEARCH)
|
||||
research = copy.deepcopy(RESEARCH)
|
||||
research["claims"][0]["level"] = "pool_accept"
|
||||
with self.assertRaisesRegex(ValueError, "outside target matrix or level"):
|
||||
status.summarize(MATRIX, research)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Representative experiments preserve the full release target set."""
|
||||
|
||||
import copy
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parent
|
||||
spec = importlib.util.spec_from_file_location("experiment_priority", ROOT / "experiment_priority.py")
|
||||
priority = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(priority)
|
||||
MATRIX = json.loads((ROOT / "conformance.json").read_text())
|
||||
QUEUE = json.loads((ROOT / "experiment-queue.json").read_text())
|
||||
|
||||
|
||||
class ExperimentPriorityTest(unittest.TestCase):
|
||||
def test_local_boot_model_ranks_first_without_reducing_gate(self):
|
||||
ordered = priority.rank(MATRIX, QUEUE)
|
||||
self.assertEqual(ordered[0]["id"], "am335x-original-nand-boot")
|
||||
self.assertEqual(ordered[0]["affected_release_cells"], 13)
|
||||
self.assertEqual(len(MATRIX["targets"]), 64)
|
||||
self.assertEqual(next(row for row in ordered if row["id"] == "bm1368-command-and-nonce")
|
||||
["affected_release_cells"], 4)
|
||||
|
||||
def test_no_selector_or_unexplained_blocker(self):
|
||||
queue = copy.deepcopy(QUEUE)
|
||||
queue["experiments"][0]["board"] = None
|
||||
with self.assertRaisesRegex(ValueError, "no target selector"):
|
||||
priority.rank(MATRIX, queue)
|
||||
queue = copy.deepcopy(QUEUE)
|
||||
queue["experiments"][1]["blocker"] = None
|
||||
with self.assertRaisesRegex(ValueError, "lacks a blocker"):
|
||||
priority.rank(MATRIX, queue)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Unknown PR paths must retain compiled source checks."""
|
||||
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
|
||||
spec = importlib.util.spec_from_file_location("pr_surface", Path(__file__).with_name("pr_surface.py"))
|
||||
surface = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(surface)
|
||||
|
||||
|
||||
class PrSurfaceTest(unittest.TestCase):
|
||||
def test_documentation_and_tooling(self):
|
||||
self.assertEqual(surface.classify(["README.md", "docs/boards.md"]), "documentation")
|
||||
self.assertEqual(surface.classify(["ci/evidence_status.py", "ci/CONFORMANCE.md"]), "tooling")
|
||||
|
||||
def test_unknown_and_rust_paths_fail_open_to_build(self):
|
||||
for paths in ([], ["src/main.rs"], ["Cargo.toml"], ["unknown/file"],
|
||||
["ci/evidence_status.py", "src/main.rs"]):
|
||||
with self.subTest(paths=paths):
|
||||
self.assertEqual(surface.classify(paths), "rust")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Check candidate numbering and covered-commit reruns with real Git tags."""
|
||||
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
VERSION = Path(__file__).with_name("version.py")
|
||||
|
||||
|
||||
def git(root: Path, *args: str) -> str:
|
||||
result = subprocess.run(
|
||||
["git", *args], cwd=root, text=True, check=True, capture_output=True
|
||||
)
|
||||
return result.stdout.strip()
|
||||
|
||||
|
||||
def selected(root: Path, branch: str) -> dict[str, str]:
|
||||
result = subprocess.run(
|
||||
["python3", str(VERSION), branch], cwd=root,
|
||||
text=True, check=True, capture_output=True
|
||||
)
|
||||
return dict(line.split("=", 1) for line in result.stdout.splitlines())
|
||||
|
||||
|
||||
def main() -> None:
|
||||
with tempfile.TemporaryDirectory(prefix="alkane-os-version-") as path:
|
||||
root = Path(path)
|
||||
(root / "ci").mkdir()
|
||||
(root / "ci/version-x.txt").write_text("0\n")
|
||||
git(root, "init", "-q")
|
||||
git(root, "config", "user.name", "Alkane CI")
|
||||
git(root, "config", "user.email", "ci@example.invalid")
|
||||
git(root, "add", ".")
|
||||
git(root, "commit", "-qm", "First source")
|
||||
first = git(root, "rev-parse", "HEAD")
|
||||
assert selected(root, "next") == {
|
||||
"release": "true", "tag": "v0.1.0-rc.1", "version": "0.1.0-rc.1"
|
||||
}
|
||||
git(root, "tag", "v0.1.0-rc.1")
|
||||
assert selected(root, "next") == {"release": "false"}
|
||||
|
||||
(root / "README.md").write_text("A later merge.\n")
|
||||
git(root, "add", ".")
|
||||
git(root, "commit", "-qm", "Later source")
|
||||
assert selected(root, "next") == {
|
||||
"release": "true", "tag": "v0.1.0-rc.2", "version": "0.1.0-rc.2"
|
||||
}
|
||||
git(root, "tag", "v0.1.0-rc.2")
|
||||
assert selected(root, "next") == {"release": "false"}
|
||||
git(root, "checkout", "-q", first)
|
||||
assert selected(root, "next") == {"release": "false"}
|
||||
print("PASS: exact and superseded candidate reruns do not publish")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -27,6 +27,13 @@ def main():
|
||||
parser.add_argument("branch", choices=("main", "next"))
|
||||
args = parser.parse_args()
|
||||
major = int(pathlib.Path("ci/version-x.txt").read_text().strip())
|
||||
# A rerun of a commit already covered by a published tag must not issue
|
||||
# a newer candidate number for older source.
|
||||
tagged_descendants = set(git("tag", "--contains", "HEAD", "-l", "v*").splitlines())
|
||||
known_tags = {tag for _, tag in versions("main") + versions("next")}
|
||||
if tagged_descendants & known_tags:
|
||||
print("release=false")
|
||||
return
|
||||
finals = versions("main")
|
||||
previous = finals[-1] if finals else None
|
||||
if previous and previous[0][0] > major:
|
||||
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
//! BM1370 wire frames observed on an S21 Pro. This module does not control power.
|
||||
|
||||
use crate::bm13xx::{crc16, crc5};
|
||||
|
||||
pub use crate::bm1362::Job;
|
||||
|
||||
pub const JOB_BYTES: usize = 88;
|
||||
pub const REPORT_BYTES: usize = 11;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct NonceReport {
|
||||
pub nonce: u32,
|
||||
pub byte6: u8,
|
||||
pub byte7: u8,
|
||||
pub byte8: u8,
|
||||
pub byte9: u8,
|
||||
/// Raw trailer: bit 7 marks a nonce response; bits 4:0 carry CRC5.
|
||||
/// No chip identity is inferred from this byte.
|
||||
pub trailer: u8,
|
||||
}
|
||||
|
||||
impl NonceReport {
|
||||
/// Work ID observed in the Braiins S21 Pro capture. Chip and version
|
||||
/// attribution remain unknown, and this has no accepted-share proof.
|
||||
pub fn observed_work_id(&self) -> u8 {
|
||||
(self.byte7 & 0xf0) >> 1
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum ReportError {
|
||||
Length,
|
||||
Preamble,
|
||||
RegisterResponse,
|
||||
Checksum,
|
||||
}
|
||||
|
||||
/// Encode only the job shape observed in the S21 Pro capture. `Job` fields
|
||||
/// are in wire order; this does not validate a pool header or start a chain.
|
||||
pub fn encode_job(job: &Job) -> Option<[u8; JOB_BYTES]> {
|
||||
if job.work_id & 7 != 0 || job.num_midstates != 1 || job.start_nonce != 0 {
|
||||
return None;
|
||||
}
|
||||
let mut frame = crate::bm1362::encode_job(job);
|
||||
frame[3] = 0x36;
|
||||
let checksum = crc16(&frame[2..86]);
|
||||
frame[86..88].copy_from_slice(&checksum.to_be_bytes());
|
||||
Some(frame)
|
||||
}
|
||||
|
||||
/// Keep the five trailing bytes raw. The work-ID expression is correlated with
|
||||
/// same-UART jobs in one capture; chip and version mapping remain unverified.
|
||||
/// The marker bit distinguishes nonce reports from register replies.
|
||||
pub fn decode_nonce_report(frame: &[u8]) -> Result<NonceReport, ReportError> {
|
||||
if frame.len() != REPORT_BYTES {
|
||||
return Err(ReportError::Length);
|
||||
}
|
||||
if frame[..2] != [0xaa, 0x55] {
|
||||
return Err(ReportError::Preamble);
|
||||
}
|
||||
if frame[10] & 0x80 == 0 {
|
||||
return Err(ReportError::RegisterResponse);
|
||||
}
|
||||
if crc5(&frame[2..]) != 0 {
|
||||
return Err(ReportError::Checksum);
|
||||
}
|
||||
Ok(NonceReport {
|
||||
nonce: u32::from_le_bytes(frame[2..6].try_into().expect("four-byte nonce")),
|
||||
byte6: frame[6],
|
||||
byte7: frame[7],
|
||||
byte8: frame[8],
|
||||
byte9: frame[9],
|
||||
trailer: frame[10],
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// firmware-analysis/prong-b/s21-192/c2-steady.strace, SHA-256
|
||||
// c0aac1222e05e95bdcbd1de5a8ee244a581256e8f28e3dadf5300df6110229c7.
|
||||
const CAPTURED_JOB: &str = concat!(
|
||||
"55aa21366001000000008f060217834f276af0f09aafc588165b7fbfc56f8f09a55d3d0de5",
|
||||
"798bd87460278af180c4696fc200000000000000008af701003acc10cdebe5bc3c90f095e5",
|
||||
"03c6b7de69ca8b5d00000020e769"
|
||||
);
|
||||
|
||||
fn captured_bytes<const N: usize>(hex: &str) -> [u8; N] {
|
||||
assert_eq!(hex.len(), N * 2);
|
||||
let mut bytes = [0; N];
|
||||
for (index, pair) in hex.as_bytes().chunks_exact(2).enumerate() {
|
||||
bytes[index] = u8::from_str_radix(std::str::from_utf8(pair).unwrap(), 16).unwrap();
|
||||
}
|
||||
bytes
|
||||
}
|
||||
|
||||
fn with_valid_crc(mut frame: [u8; REPORT_BYTES]) -> [u8; REPORT_BYTES] {
|
||||
for checksum in 0..32 {
|
||||
frame[10] = (frame[10] & 0xe0) | checksum;
|
||||
if crc5(&frame[2..]) == 0 {
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
panic!("no valid CRC5 trailer");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn live_job_matches_all_88_bytes() {
|
||||
let captured = captured_bytes::<JOB_BYTES>(CAPTURED_JOB);
|
||||
let mut merkle_root = [0; 32];
|
||||
merkle_root.copy_from_slice(&captured[18..50]);
|
||||
let mut previous_hash = [0; 32];
|
||||
previous_hash.copy_from_slice(&captured[50..82]);
|
||||
let job = Job {
|
||||
work_id: captured[4],
|
||||
num_midstates: captured[5],
|
||||
start_nonce: u32::from_le_bytes(captured[6..10].try_into().unwrap()),
|
||||
nbits: u32::from_le_bytes(captured[10..14].try_into().unwrap()),
|
||||
ntime: u32::from_le_bytes(captured[14..18].try_into().unwrap()),
|
||||
merkle_root,
|
||||
previous_hash,
|
||||
version: u32::from_le_bytes(captured[82..86].try_into().unwrap()),
|
||||
};
|
||||
assert_eq!(encode_job(&job), Some(captured));
|
||||
let mut invalid = job;
|
||||
invalid.work_id |= 1;
|
||||
assert_eq!(encode_job(&invalid), None);
|
||||
invalid = job;
|
||||
invalid.num_midstates = 2;
|
||||
assert_eq!(encode_job(&invalid), None);
|
||||
invalid = job;
|
||||
invalid.start_nonce = 1;
|
||||
assert_eq!(encode_job(&invalid), None);
|
||||
assert_eq!(
|
||||
crc16(&captured[2..86]),
|
||||
u16::from_be_bytes([captured[86], captured[87]])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn live_nonce_reports_preserve_raw_tags() {
|
||||
for hex in [
|
||||
"aa555804a92a041e133e86",
|
||||
"aa55771def23001c16fc82",
|
||||
"aa5574480ae6021417b492",
|
||||
] {
|
||||
let frame = captured_bytes::<REPORT_BYTES>(hex);
|
||||
let report = decode_nonce_report(&frame).unwrap();
|
||||
assert_eq!(
|
||||
report.nonce,
|
||||
u32::from_le_bytes(frame[2..6].try_into().unwrap())
|
||||
);
|
||||
assert_eq!(report.byte6, frame[6]);
|
||||
assert_eq!(report.byte7, frame[7]);
|
||||
assert_eq!(report.byte8, frame[8]);
|
||||
assert_eq!(report.byte9, frame[9]);
|
||||
assert_eq!(report.trailer, frame[10]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn observed_work_id_matches_same_uart_job() {
|
||||
// c2-steady.strace lines 1287 and 1352: job byte 4 is 0x10.
|
||||
let frame = captured_bytes::<REPORT_BYTES>("aa554a3488c70022013291");
|
||||
let report = decode_nonce_report(&frame).unwrap();
|
||||
assert_eq!(report.observed_work_id(), 0x10);
|
||||
assert_eq!(report.byte7, 0x22);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_report_fails_closed() {
|
||||
let mut frame = captured_bytes::<REPORT_BYTES>("aa555804a92a041e133e86");
|
||||
assert_eq!(decode_nonce_report(&frame[..10]), Err(ReportError::Length));
|
||||
frame[0] = 0;
|
||||
assert_eq!(decode_nonce_report(&frame), Err(ReportError::Preamble));
|
||||
frame[0] = 0xaa;
|
||||
frame[10] &= 0x60;
|
||||
frame = with_valid_crc(frame);
|
||||
assert_eq!(crc5(&frame[2..]), 0);
|
||||
assert_eq!(
|
||||
decode_nonce_report(&frame),
|
||||
Err(ReportError::RegisterResponse)
|
||||
);
|
||||
frame[10] |= 0x80;
|
||||
frame = with_valid_crc(frame);
|
||||
frame[4] ^= 1;
|
||||
assert_eq!(decode_nonce_report(&frame), Err(ReportError::Checksum));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trailer_low_bits_are_checksum_not_chip_identity() {
|
||||
let original = captured_bytes::<REPORT_BYTES>("aa555804a92a041e133e86");
|
||||
let mut changed_nonce = original;
|
||||
changed_nonce[2] ^= 1;
|
||||
changed_nonce = with_valid_crc(changed_nonce);
|
||||
assert_eq!(crc5(&changed_nonce[2..]), 0);
|
||||
assert_ne!(changed_nonce[10] & 0x1f, original[10] & 0x1f);
|
||||
assert_eq!(changed_nonce[10] & 0xe0, original[10] & 0xe0);
|
||||
assert!(decode_nonce_report(&changed_nonce).is_ok());
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
pub mod bm1362;
|
||||
pub mod bm1366;
|
||||
pub mod bm1370;
|
||||
pub mod bm13xx;
|
||||
pub mod difficulty;
|
||||
pub mod hal_wire;
|
||||
|
||||
+13
-4
@@ -105,8 +105,12 @@ impl PoolSession {
|
||||
Ok(false)
|
||||
}
|
||||
PoolNotification::SetVersionMask(mask) => {
|
||||
if self.version_mask == Some(mask) {
|
||||
return Ok(false);
|
||||
}
|
||||
self.version_mask = Some(mask);
|
||||
Ok(false)
|
||||
self.tracked = std::array::from_fn(|_| None);
|
||||
Ok(true)
|
||||
}
|
||||
PoolNotification::SetExtranonce(subscription) => {
|
||||
self.subscription = subscription;
|
||||
@@ -119,7 +123,7 @@ impl PoolSession {
|
||||
}
|
||||
|
||||
/// Apply a pool control message and invalidate the hardware miner's work
|
||||
/// when an extranonce change makes earlier jobs stale.
|
||||
/// when an extranonce or version-mask change makes earlier jobs stale.
|
||||
pub fn control_with_miner<B: HardwareBackend>(
|
||||
&mut self,
|
||||
miner: &mut Bm1366Miner<'_, B>,
|
||||
@@ -360,10 +364,15 @@ mod tests {
|
||||
),
|
||||
Err(SessionError::UnverifiedShare)
|
||||
);
|
||||
session.version_mask = VersionMask::new(0x0000_2000);
|
||||
assert_eq!(
|
||||
session.control(
|
||||
b"{\"id\":null,\"method\":\"mining.set_version_mask\",\"params\":[\"00002000\"]}"
|
||||
),
|
||||
Ok(true)
|
||||
);
|
||||
assert_eq!(
|
||||
session.submission(share, "miner.worker", 8),
|
||||
Err(SessionError::Submit(SubmitError::UnrepresentableVersion))
|
||||
Err(SessionError::StaleShare)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,9 +52,27 @@ fn difficulty_changes_on_next_job_and_old_work_keeps_its_target() {
|
||||
assert_eq!(second.work_id, 8);
|
||||
assert_eq!(&second.target_le[26..28], &[0xff, 0x7f]);
|
||||
assert_ne!(first.header, second.header);
|
||||
assert!(pool
|
||||
.control(br#"{"id":null,"method":"mining.set_version_mask","params":["00006000"]}"#)
|
||||
.is_ok());
|
||||
assert_eq!(
|
||||
pool.control(br#"{"id":null,"method":"mining.set_version_mask","params":["00006000"]}"#),
|
||||
Ok(true)
|
||||
);
|
||||
assert_eq!(
|
||||
pool.submission(
|
||||
ValidShare {
|
||||
nonce: 0xedad_ff38,
|
||||
work_id: first.work_id,
|
||||
rolled_version: 0x2000_0000,
|
||||
hash_le: [0; 32],
|
||||
},
|
||||
"worker",
|
||||
10,
|
||||
),
|
||||
Err(SessionError::StaleShare)
|
||||
);
|
||||
assert_eq!(
|
||||
pool.control(br#"{"id":null,"method":"mining.set_version_mask","params":["00006000"]}"#),
|
||||
Ok(false)
|
||||
);
|
||||
let clean = pool.issue_notify(notify("third", true).as_bytes()).unwrap();
|
||||
assert!(clean.clean_jobs);
|
||||
assert_eq!(clean.work_id, 16);
|
||||
@@ -201,7 +219,7 @@ impl HardwareBackend for FakeBackend {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pool_job_dispatch_and_extranonce_invalidation_reach_the_miner() {
|
||||
fn pool_job_dispatch_and_version_mask_invalidation_reach_the_miner() {
|
||||
let mut backend = FakeBackend {
|
||||
powered: false,
|
||||
sent: 0,
|
||||
@@ -226,7 +244,7 @@ fn pool_job_dispatch_and_extranonce_invalidation_reach_the_miner() {
|
||||
}
|
||||
pool.control_with_miner(
|
||||
&mut miner,
|
||||
br#"{"id":null,"method":"mining.set_extranonce","params":["aabbccdd",4]}"#,
|
||||
br#"{"id":null,"method":"mining.set_version_mask","params":["00006000"]}"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(miner.poll(), Err(MinerError::StaleReport));
|
||||
|
||||
Reference in New Issue
Block a user