Compare commits
66
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e746efcb94 | ||
|
|
16c9d4962a | ||
|
|
283287f74f | ||
|
|
98f3eb75c0 | ||
|
|
853cb845ff | ||
|
|
e9a3c3a669 | ||
|
|
895081e509 | ||
|
|
b76b74cb63 | ||
|
|
289ad40d86 | ||
|
|
f0c9d4d904 | ||
|
|
f6b5df831e | ||
|
|
d1d7c576cf | ||
|
|
8d19cdeae6 | ||
|
|
52e6093011 | ||
|
|
7fd9c8eee3 | ||
|
|
f302bbbb24 | ||
|
|
b22b494ede | ||
|
|
6c23ce847d | ||
|
|
6a466a611f | ||
|
|
1300d7e372 | ||
|
|
66e4f3d47a | ||
|
|
37028cc3eb | ||
|
|
0e6fd9269b | ||
|
|
3d63bbb3eb | ||
|
|
5d8f14c992 | ||
|
|
6f87f48dca | ||
|
|
7d398caa66 | ||
|
|
96dd7bf6d2 | ||
|
|
59249d44d3 | ||
|
|
f011557cd5 | ||
|
|
d52996c02a | ||
|
|
b59aa8d9c1 | ||
|
|
523ec5fd0b | ||
|
|
a1d8e34390 | ||
|
|
2d6233cdc7 | ||
|
|
eb9dcf830b | ||
|
|
af49d4905d | ||
|
|
8fa9e5d9e6 | ||
|
|
492fe68c9e | ||
|
|
f215cb3196 | ||
|
|
6e3b798273 | ||
|
|
16b55b58e3 | ||
|
|
90a2fe12d5 | ||
|
|
bc38a4a787 | ||
|
|
654b205e00 | ||
|
|
ece32ef55f | ||
|
|
5cd77eb5de | ||
|
|
e7a23faa5a | ||
|
|
e0f9b1ab50 | ||
|
|
323e45ab0e | ||
|
|
6fd329e047 | ||
|
|
7d602d2f03 | ||
|
|
78b9416985 | ||
|
|
d2afef19a9 | ||
|
|
e67ffcd204 | ||
|
|
6cf9ed1620 | ||
|
|
4f21677ae5 | ||
|
|
9f7d8ebb51 | ||
|
|
81d726cca2 | ||
|
|
74ba049b5c | ||
|
|
46a4f58019 | ||
|
|
e9d7200a05 | ||
|
|
544711885e | ||
|
|
7d3cebea79 | ||
|
|
1ce22d9d9f | ||
|
|
4eef88b5df |
@@ -1,37 +0,0 @@
|
||||
name: public-benchmark-pages
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [main-release-gate]
|
||||
types: [completed]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: alkane-os-public-benchmark-pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: alkane-pages
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install SSH client
|
||||
run: |
|
||||
if ! command -v ssh >/dev/null 2>&1; then
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq --no-install-recommends openssh-client
|
||||
fi
|
||||
- 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
|
||||
@@ -1,9 +1,8 @@
|
||||
name: completed-ci-badge
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [main-release-gate, next-build]
|
||||
types: [completed]
|
||||
schedule:
|
||||
- cron: '*/15 * * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
@@ -12,7 +11,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: alkane-fast
|
||||
runs-on: alkane-ci
|
||||
permissions:
|
||||
actions: read
|
||||
contents: write
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
name: source-pr
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main, next]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: alkane-os-source-pr-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
source:
|
||||
runs-on: alkane-fast
|
||||
env:
|
||||
CARGO_TARGET_DIR: target
|
||||
CARGO_BUILD_JOBS: 2
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Detect README-only change
|
||||
id: surface
|
||||
run: |
|
||||
surface=full
|
||||
if [ "$GITHUB_EVENT_NAME" = pull_request ] &&
|
||||
{ [ "$GITHUB_BASE_REF" = main ] || [ "$GITHUB_BASE_REF" = next ]; } &&
|
||||
base="$(git merge-base HEAD "origin/$GITHUB_BASE_REF" 2>/dev/null)" &&
|
||||
changed="$(git diff --name-only "$base" HEAD)" &&
|
||||
[ "$changed" = README.md ]; then
|
||||
surface=documentation
|
||||
fi
|
||||
echo "surface=$surface" >> "$GITHUB_OUTPUT"
|
||||
- name: Check README-only change
|
||||
if: steps.surface.outputs.surface == 'documentation'
|
||||
run: |
|
||||
base="$(git merge-base HEAD "origin/$GITHUB_BASE_REF")"
|
||||
git diff --check "$base" HEAD
|
||||
if git grep -nIE '^[[:space:]]*-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----[[:space:]]*$' --; then
|
||||
echo "private key material found in tracked source" >&2
|
||||
exit 1
|
||||
else
|
||||
status=$?
|
||||
[ "$status" -eq 1 ]
|
||||
fi
|
||||
- name: Check source
|
||||
if: steps.surface.outputs.surface != 'documentation'
|
||||
run: |
|
||||
rustup component add rustfmt
|
||||
cargo fmt --check
|
||||
cargo test --locked
|
||||
- name: Clean generated source check
|
||||
if: always()
|
||||
run: python3 ci/cleanup-generated.py
|
||||
@@ -22,10 +22,8 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- name: Install Pages SSH client
|
||||
run: |
|
||||
if ! command -v ssh >/dev/null 2>&1; then
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq --no-install-recommends openssh-client
|
||||
fi
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq --no-install-recommends openssh-client
|
||||
- name: Install Rust quality tools
|
||||
run: rustup component add rustfmt clippy
|
||||
- name: Formatting
|
||||
@@ -56,18 +54,12 @@ jobs:
|
||||
run: |
|
||||
set -o pipefail
|
||||
cargo test --release --locked -- --ignored --nocapture --test-threads=1 | tee bench-current.txt
|
||||
- name: Restore coverage tool
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /root/.cargo/bin/cargo-llvm-cov
|
||||
key: cargo-llvm-cov-0.8.7-rust-1.97.1-${{ runner.os }}
|
||||
- name: Coverage tool
|
||||
run: |
|
||||
rustup component add llvm-tools-preview
|
||||
if [ "$(cargo llvm-cov --version 2>/dev/null || true)" != 'cargo-llvm-cov 0.8.7' ]; then
|
||||
cargo install --locked --force cargo-llvm-cov --version 0.8.7
|
||||
if ! command -v cargo-llvm-cov >/dev/null 2>&1; then
|
||||
cargo install --locked cargo-llvm-cov --version 0.8.7
|
||||
fi
|
||||
[ "$(cargo llvm-cov --version)" = 'cargo-llvm-cov 0.8.7' ]
|
||||
- name: Unit test coverage
|
||||
run: |
|
||||
mkdir -p coverage
|
||||
@@ -107,6 +99,11 @@ 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: Pairing and simulator conformance
|
||||
run: python3 ci/check-conformance.py
|
||||
- name: Select release version
|
||||
|
||||
@@ -10,10 +10,9 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: alkane-fast
|
||||
runs-on: alkane-ci
|
||||
env:
|
||||
CARGO_TARGET_DIR: target
|
||||
CARGO_BUILD_JOBS: 2
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
||||
@@ -10,53 +10,84 @@
|
||||

|
||||

|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
## Status
|
||||
|
||||
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 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 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.
|
||||
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.
|
||||
|
||||
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:
|
||||
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.
|
||||
|
||||
```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.
|
||||
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.
|
||||
|
||||
## Release gate
|
||||
|
||||
`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).
|
||||
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).
|
||||
|
||||
Badges cover host code, not board conformance. See the public
|
||||
[benchmark history](https://blueflare.gitea.bluefla.re/alkane-benchmarks/os/).
|
||||
`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.
|
||||
|
||||
## Local checks
|
||||
|
||||
```sh
|
||||
CARGO_TARGET_DIR=/var/tmp/alkane-os-target cargo test --locked
|
||||
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
|
||||
```
|
||||
|
||||
Use an executable target directory if the source mount is `noexec`.
|
||||
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.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE). Vendored dependencies keep their own licenses.
|
||||
Alkane OS source is [MIT licensed](LICENSE). Vendored dependencies retain
|
||||
their own licenses.
|
||||
|
||||
+1
-8
@@ -120,7 +120,7 @@ def render_html(index: dict) -> str:
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("action", choices=("prepare", "publish", "render"))
|
||||
parser.add_argument("action", choices=("prepare", "publish"))
|
||||
args = parser.parse_args()
|
||||
api = os.environ["GITHUB_API_URL"].rstrip("/")
|
||||
repo = os.environ["GITHUB_REPOSITORY"]
|
||||
@@ -135,13 +135,6 @@ 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)
|
||||
|
||||
@@ -55,8 +55,8 @@ def publish(api: str, repo: str, branch: str, data: bytes, token: str) -> None:
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if os.environ["GITHUB_EVENT_NAME"] not in ("workflow_run", "workflow_dispatch"):
|
||||
raise RuntimeError("badge publisher must follow CI completion or manual dispatch")
|
||||
if os.environ["GITHUB_EVENT_NAME"] not in ("schedule", "workflow_dispatch"):
|
||||
raise RuntimeError("badge publisher must run on a timer or manual dispatch")
|
||||
if os.environ["GITHUB_REF"] != "refs/heads/main":
|
||||
raise RuntimeError("badge publisher must use the main branch")
|
||||
repo = os.environ["GITHUB_REPOSITORY"]
|
||||
|
||||
@@ -16,17 +16,12 @@ 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]:
|
||||
result = subprocess.run(args, env=env, cwd=cwd, text=True,
|
||||
capture_output=True, check=False)
|
||||
if result.returncode:
|
||||
detail = result.stderr.strip()[:2000]
|
||||
raise RuntimeError(f"{args[0]} {args[1]} exited {result.returncode}: {detail}")
|
||||
return result
|
||||
return subprocess.run(args, env=env, cwd=cwd, text=True,
|
||||
capture_output=True, check=True)
|
||||
|
||||
|
||||
def current_main_sha() -> str:
|
||||
@@ -67,15 +62,16 @@ def publish(site: str) -> None:
|
||||
key_path = temporary / "deploy_key"
|
||||
key_path.write_text(key.rstrip("\n") + "\n")
|
||||
key_path.chmod(0o600)
|
||||
scanned = run("ssh-keyscan", "-p", "2222", "-t", "ed25519", PAGES_HOST)
|
||||
known_hosts = temporary / "known_hosts"
|
||||
known_hosts.write_text(PAGES_HOST_KEY + "\n")
|
||||
known_hosts.write_text(scanned.stdout)
|
||||
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")
|
||||
"-o StrictHostKeyChecking=yes")
|
||||
git_env["GIT_SSH_COMMAND"] = ssh_command
|
||||
git_env["GIT_TERMINAL_PROMPT"] = "0"
|
||||
checkout = temporary / "site"
|
||||
|
||||
@@ -36,7 +36,7 @@ assert b">fail</text>" in svg
|
||||
assert b"#d1242f" in svg
|
||||
assert b">pass</text>" in module.badge("next", "success", 108)
|
||||
environment = {
|
||||
"GITHUB_EVENT_NAME": "workflow_run",
|
||||
"GITHUB_EVENT_NAME": "schedule",
|
||||
"GITHUB_REF": "refs/heads/main",
|
||||
"GITHUB_REPOSITORY": "owner/repo",
|
||||
"GITHUB_API_URL": "https://example.invalid/api/v1",
|
||||
@@ -49,19 +49,13 @@ with patch.dict(os.environ, environment), \
|
||||
module.main()
|
||||
assert latest.call_count == 2
|
||||
assert [call.args[2] for call in published.call_args_list] == ["main", "next"]
|
||||
with patch.dict(os.environ, {**environment, "GITHUB_EVENT_NAME": "workflow_dispatch"}), \
|
||||
patch.object(module, "latest_completed", side_effect=[(201, "success"),
|
||||
(202, "failure")]), \
|
||||
patch.object(module, "publish") as published:
|
||||
module.main()
|
||||
assert published.call_count == 2
|
||||
with patch.dict(os.environ, {**environment, "GITHUB_EVENT_NAME": "schedule"}):
|
||||
with patch.dict(os.environ, {**environment, "GITHUB_EVENT_NAME": "workflow_run"}):
|
||||
try:
|
||||
module.main()
|
||||
except RuntimeError as error:
|
||||
assert "CI completion or manual dispatch" in str(error)
|
||||
assert "timer or manual dispatch" in str(error)
|
||||
else:
|
||||
raise AssertionError("scheduled event entered badge publisher")
|
||||
raise AssertionError("workflow_run event entered badge publisher")
|
||||
for invalid in ("", "/main.svg", "../main.svg", "badges//main.svg"):
|
||||
try:
|
||||
publish_file("https://example.invalid/api/v1", "owner/repo", invalid,
|
||||
|
||||
+4
-13
@@ -105,12 +105,8 @@ impl PoolSession {
|
||||
Ok(false)
|
||||
}
|
||||
PoolNotification::SetVersionMask(mask) => {
|
||||
if self.version_mask == Some(mask) {
|
||||
return Ok(false);
|
||||
}
|
||||
self.version_mask = Some(mask);
|
||||
self.tracked = std::array::from_fn(|_| None);
|
||||
Ok(true)
|
||||
Ok(false)
|
||||
}
|
||||
PoolNotification::SetExtranonce(subscription) => {
|
||||
self.subscription = subscription;
|
||||
@@ -123,7 +119,7 @@ impl PoolSession {
|
||||
}
|
||||
|
||||
/// Apply a pool control message and invalidate the hardware miner's work
|
||||
/// when an extranonce or version-mask change makes earlier jobs stale.
|
||||
/// when an extranonce change makes earlier jobs stale.
|
||||
pub fn control_with_miner<B: HardwareBackend>(
|
||||
&mut self,
|
||||
miner: &mut Bm1366Miner<'_, B>,
|
||||
@@ -364,15 +360,10 @@ mod tests {
|
||||
),
|
||||
Err(SessionError::UnverifiedShare)
|
||||
);
|
||||
assert_eq!(
|
||||
session.control(
|
||||
b"{\"id\":null,\"method\":\"mining.set_version_mask\",\"params\":[\"00002000\"]}"
|
||||
),
|
||||
Ok(true)
|
||||
);
|
||||
session.version_mask = VersionMask::new(0x0000_2000);
|
||||
assert_eq!(
|
||||
session.submission(share, "miner.worker", 8),
|
||||
Err(SessionError::StaleShare)
|
||||
Err(SessionError::Submit(SubmitError::UnrepresentableVersion))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -76,9 +76,7 @@ fn rejects_wrong_response_sequence() {
|
||||
let mut body = [0_u8; 1];
|
||||
server.read_exact(&mut body).unwrap();
|
||||
header[8..12].copy_from_slice(&2_u32.to_le_bytes());
|
||||
header[6..8].copy_from_slice(&1_u16.to_le_bytes());
|
||||
header[12..16].copy_from_slice(&1_u32.to_le_bytes());
|
||||
server.write_all(&header).unwrap();
|
||||
reply(&mut server, &header, &[0]);
|
||||
let mut one = [0_u8; 1];
|
||||
assert_eq!(server.read(&mut one).unwrap(), 0);
|
||||
});
|
||||
|
||||
@@ -52,27 +52,9 @@ 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_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)
|
||||
);
|
||||
assert!(pool
|
||||
.control(br#"{"id":null,"method":"mining.set_version_mask","params":["00006000"]}"#)
|
||||
.is_ok());
|
||||
let clean = pool.issue_notify(notify("third", true).as_bytes()).unwrap();
|
||||
assert!(clean.clean_jobs);
|
||||
assert_eq!(clean.work_id, 16);
|
||||
@@ -219,7 +201,7 @@ impl HardwareBackend for FakeBackend {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pool_job_dispatch_and_version_mask_invalidation_reach_the_miner() {
|
||||
fn pool_job_dispatch_and_extranonce_invalidation_reach_the_miner() {
|
||||
let mut backend = FakeBackend {
|
||||
powered: false,
|
||||
sent: 0,
|
||||
@@ -244,7 +226,7 @@ fn pool_job_dispatch_and_version_mask_invalidation_reach_the_miner() {
|
||||
}
|
||||
pool.control_with_miner(
|
||||
&mut miner,
|
||||
br#"{"id":null,"method":"mining.set_version_mask","params":["00006000"]}"#,
|
||||
br#"{"id":null,"method":"mining.set_extranonce","params":["aabbccdd",4]}"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(miner.poll(), Err(MinerError::StaleReport));
|
||||
|
||||
Reference in New Issue
Block a user