Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7feab6117b | ||
|
|
808fd4de1d | ||
|
|
63ada5bb99 |
@@ -11,6 +11,9 @@ jobs:
|
|||||||
runs-on: alkane-ci
|
runs-on: alkane-ci
|
||||||
env:
|
env:
|
||||||
WX_PREFIX: /root/.cache/wx-3.3.3-linux
|
WX_PREFIX: /root/.cache/wx-3.3.3-linux
|
||||||
|
# Set once for the whole job so build/clippy/test/bench steps don't each
|
||||||
|
# re-export it (round 18 #12).
|
||||||
|
WX_RS_WXCONFIG: /root/.cache/wx-3.3.3-linux/bin/wx-config
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout (full history for tags)
|
- name: Checkout (full history for tags)
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -52,7 +55,6 @@ jobs:
|
|||||||
- name: Clippy (our crate, warnings are errors)
|
- name: Clippy (our crate, warnings are errors)
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
run: |
|
run: |
|
||||||
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
|
||||||
rustup component add clippy >/dev/null 2>&1 || true
|
rustup component add clippy >/dev/null 2>&1 || true
|
||||||
cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings
|
cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings
|
||||||
|
|
||||||
@@ -65,19 +67,16 @@ jobs:
|
|||||||
- name: Build release
|
- name: Build release
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
run: |
|
run: |
|
||||||
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
|
||||||
cargo build --release -p alkane-gui --offline
|
cargo build --release -p alkane-gui --offline
|
||||||
|
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
run: |
|
run: |
|
||||||
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
|
||||||
cargo test -p alkane-gui --offline
|
cargo test -p alkane-gui --offline
|
||||||
|
|
||||||
- name: Microbenchmarks
|
- name: Microbenchmarks
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
run: |
|
run: |
|
||||||
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
|
||||||
cargo test -p alkane-gui --release --offline -- --ignored --nocapture bench_
|
cargo test -p alkane-gui --release --offline -- --ignored --nocapture bench_
|
||||||
|
|
||||||
- name: Headless UI self-test
|
- name: Headless UI self-test
|
||||||
@@ -108,7 +107,6 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
|
||||||
PASS=$(cargo test -p alkane-gui --offline 2>&1 \
|
PASS=$(cargo test -p alkane-gui --offline 2>&1 \
|
||||||
| grep -hoE '[0-9]+ passed' | grep -oE '[0-9]+' | awk '{s+=$1} END{print s+0}')
|
| grep -hoE '[0-9]+ passed' | grep -oE '[0-9]+' | awk '{s+=$1} END{print s+0}')
|
||||||
python3 ci/gen-badges.py --tests "${PASS:-0}" --bench "row-render + scan-parse"
|
python3 ci/gen-badges.py --tests "${PASS:-0}" --bench "row-render + scan-parse"
|
||||||
|
|||||||
+12
@@ -19,3 +19,15 @@ license = "MIT OR Apache-2.0"
|
|||||||
thiserror = "2"
|
thiserror = "2"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
|
|
||||||
|
# Release binary: small, self-contained, and fast enough for a fleet GUI whose
|
||||||
|
# hot path is network I/O, not CPU (round 18 #12). opt-level "s" + fat LTO +
|
||||||
|
# one codegen unit + symbol stripping cut the binary substantially. panic stays
|
||||||
|
# "unwind" on purpose: the scan runs many miners on tokio tasks and the wx event
|
||||||
|
# dispatch relies on unwinding so one miner's panic never aborts the whole app.
|
||||||
|
[profile.release]
|
||||||
|
opt-level = "s"
|
||||||
|
lto = "fat"
|
||||||
|
codegen-units = 1
|
||||||
|
strip = true
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="95.5" height="20" role="img" aria-label="coverage: 36%">
|
<svg xmlns="http://www.w3.org/2000/svg" width="95.5" height="20" role="img" aria-label="coverage: 35%">
|
||||||
<title>coverage: 36%</title>
|
<title>coverage: 35%</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
<text x="32.0" y="15" fill="#010101" fill-opacity=".3">coverage</text>
|
<text x="32.0" y="15" fill="#010101" fill-opacity=".3">coverage</text>
|
||||||
<text x="32.0" y="14">coverage</text>
|
<text x="32.0" y="14">coverage</text>
|
||||||
<text x="79.8" y="15" fill="#010101" fill-opacity=".3">36%</text>
|
<text x="79.8" y="15" fill="#010101" fill-opacity=".3">35%</text>
|
||||||
<text x="79.8" y="14">36%</text>
|
<text x="79.8" y="14">35%</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 919 B After Width: | Height: | Size: 919 B |
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="141.0" height="20" role="img" aria-label="lines of code: 12.5k">
|
<svg xmlns="http://www.w3.org/2000/svg" width="141.0" height="20" role="img" aria-label="lines of code: 13.2k">
|
||||||
<title>lines of code: 12.5k</title>
|
<title>lines of code: 13.2k</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
<text x="48.2" y="15" fill="#010101" fill-opacity=".3">lines of code</text>
|
<text x="48.2" y="15" fill="#010101" fill-opacity=".3">lines of code</text>
|
||||||
<text x="48.2" y="14">lines of code</text>
|
<text x="48.2" y="14">lines of code</text>
|
||||||
<text x="118.8" y="15" fill="#010101" fill-opacity=".3">12.5k</text>
|
<text x="118.8" y="15" fill="#010101" fill-opacity=".3">13.2k</text>
|
||||||
<text x="118.8" y="14">12.5k</text>
|
<text x="118.8" y="14">13.2k</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 952 B After Width: | Height: | Size: 952 B |
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="121.5" height="20" role="img" aria-label="tests: 94 passing">
|
<svg xmlns="http://www.w3.org/2000/svg" width="121.5" height="20" role="img" aria-label="tests: 99 passing">
|
||||||
<title>tests: 94 passing</title>
|
<title>tests: 99 passing</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
<text x="22.2" y="15" fill="#010101" fill-opacity=".3">tests</text>
|
<text x="22.2" y="15" fill="#010101" fill-opacity=".3">tests</text>
|
||||||
<text x="22.2" y="14">tests</text>
|
<text x="22.2" y="14">tests</text>
|
||||||
<text x="83.0" y="15" fill="#010101" fill-opacity=".3">94 passing</text>
|
<text x="83.0" y="15" fill="#010101" fill-opacity=".3">99 passing</text>
|
||||||
<text x="83.0" y="14">94 passing</text>
|
<text x="83.0" y="14">99 passing</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 935 B After Width: | Height: | Size: 935 B |
@@ -2,9 +2,10 @@
|
|||||||
# Compute the next release version for alkane-toolkit from the latest release
|
# Compute the next release version for alkane-toolkit from the latest release
|
||||||
# tag and the paths changed since it. Version scheme X.Y.Z:
|
# tag and the paths changed since it. Version scheme X.Y.Z:
|
||||||
# X - major, bumped manually (ci/version-x.txt); a bump resets Y.Z to 0.0
|
# X - major, bumped manually (ci/version-x.txt); a bump resets Y.Z to 0.0
|
||||||
# Y - backend-logic changes (core/discovery/access/flash/artifacts/cli,
|
# Y - backend-logic changes (the alkane-* crates and any GUI crate source
|
||||||
# scan+model+main in the GUI crate, build/CI config); resets Z to 0
|
# other than the view files below, plus vendored deps and build/CI config);
|
||||||
# Z - UI changes (the GUI view + fixtures + the wx-rs widget bridge)
|
# resets Z to 0
|
||||||
|
# Z - UI changes (the GUI view: ui.rs + fixtures.rs + bin/ + the wx-rs bridge)
|
||||||
# When both backend and UI changed, backend wins (bump Y). Docs-only changes
|
# When both backend and UI changed, backend wins (bump Y). Docs-only changes
|
||||||
# produce no release.
|
# produce no release.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -240,23 +240,39 @@ fn wm_aes_ecb_enc(pwd_md5: &str, data: &str) -> Option<String> {
|
|||||||
fn probe_whatsminer_access(ip: &str, passwords: &[String]) -> Option<bool> {
|
fn probe_whatsminer_access(ip: &str, passwords: &[String]) -> Option<bool> {
|
||||||
let timeout = Duration::from_secs(6);
|
let timeout = Duration::from_secs(6);
|
||||||
let mut reachable = false;
|
let mut reachable = false;
|
||||||
|
// A transient error on one candidate must not abandon the others (round 18 #12):
|
||||||
|
// skip to the next candidate, but remember it happened so we never report a
|
||||||
|
// confident "locked" when the answer was really indeterminate.
|
||||||
|
let mut errored = false;
|
||||||
for pass in passwords {
|
for pass in passwords {
|
||||||
// 1. get_token (no auth) -> salt / newsalt / time.
|
// 1. get_token (no auth) -> salt / newsalt / time.
|
||||||
let tok_resp = match wm_rpc(ip, "{\"command\":\"get_token\"}", timeout) {
|
let tok_resp = match wm_rpc(ip, "{\"command\":\"get_token\"}", timeout) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(_) => return None,
|
Err(_) => {
|
||||||
|
errored = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let v: serde_json::Value = match serde_json::from_str(&tok_resp) {
|
let v: serde_json::Value = match serde_json::from_str(&tok_resp) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(_) => return None,
|
Err(_) => {
|
||||||
|
errored = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let msg = v.get("Msg")?;
|
let (Some(salt), Some(newsalt), Some(time)) = v
|
||||||
let (Some(salt), Some(newsalt), Some(time)) = (
|
.get("Msg")
|
||||||
msg.get("salt").and_then(|s| s.as_str()),
|
.map(|msg| {
|
||||||
msg.get("newsalt").and_then(|s| s.as_str()),
|
(
|
||||||
msg.get("time").and_then(|s| s.as_str()),
|
msg.get("salt").and_then(|s| s.as_str()),
|
||||||
) else {
|
msg.get("newsalt").and_then(|s| s.as_str()),
|
||||||
return None;
|
msg.get("time").and_then(|s| s.as_str()),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.unwrap_or((None, None, None))
|
||||||
|
else {
|
||||||
|
errored = true;
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
reachable = true;
|
reachable = true;
|
||||||
// 2. Derive the md5crypt password hash + write-token from the password.
|
// 2. Derive the md5crypt password hash + write-token from the password.
|
||||||
@@ -274,15 +290,19 @@ fn probe_whatsminer_access(ip: &str, passwords: &[String]) -> Option<bool> {
|
|||||||
let payload = format!("{{\"enc\":1,\"data\":\"{enc}\"}}");
|
let payload = format!("{{\"enc\":1,\"data\":\"{enc}\"}}");
|
||||||
let resp = match wm_rpc(ip, &payload, timeout) {
|
let resp = match wm_rpc(ip, &payload, timeout) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(_) => return None,
|
Err(_) => {
|
||||||
|
errored = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if resp.contains("\"enc\"") {
|
if resp.contains("\"enc\"") {
|
||||||
return Some(false); // accepted -> unlocked/writable
|
return Some(false); // accepted -> unlocked/writable
|
||||||
}
|
}
|
||||||
// rejected -> try the next candidate password
|
// rejected -> try the next candidate password
|
||||||
}
|
}
|
||||||
// Reached the miner and every candidate password was rejected -> locked.
|
// Only report "locked" when we cleanly reached the miner and every candidate
|
||||||
if reachable { Some(true) } else { None }
|
// was rejected with no transient errors; otherwise the result is indeterminate.
|
||||||
|
if reachable && !errored { Some(true) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -191,7 +191,12 @@ pub fn clear_firmware_credentials() -> std::io::Result<()> {
|
|||||||
/// otherwise the backend falls back to its own default auth. With nothing saved
|
/// otherwise the backend falls back to its own default auth. With nothing saved
|
||||||
/// this is plain `MinerFactory::new()`.
|
/// this is plain `MinerFactory::new()`.
|
||||||
pub fn configured_factory() -> MinerFactory {
|
pub fn configured_factory() -> MinerFactory {
|
||||||
let mut factory = MinerFactory::new();
|
// Apply the operator's configured identification timeout to every factory
|
||||||
|
// (round 18 #12: config actions / refresh / pools / flash previously used
|
||||||
|
// asic-rs's 10s default, so on a slow link they could fail to reach miners a
|
||||||
|
// longer-timeout scan had found). start_scan may still override it explicitly.
|
||||||
|
let mut factory =
|
||||||
|
MinerFactory::new().with_identification_timeout_secs(crate::scan::load_scan_timeout().max(1));
|
||||||
let global = load_credentials();
|
let global = load_credentials();
|
||||||
let per_fw = load_firmware_credentials();
|
let per_fw = load_firmware_credentials();
|
||||||
if global.is_none() && per_fw.is_empty() {
|
if global.is_none() && per_fw.is_empty() {
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ impl Board {
|
|||||||
let control_board = crate::naming::control_board_code(self.make, self.board, &model);
|
let control_board = crate::naming::control_board_code(self.make, self.board, &model);
|
||||||
let cpu = crate::naming::control_board_cpu(self.make, self.board, &model);
|
let cpu = crate::naming::control_board_cpu(self.make, self.board, &model);
|
||||||
let board_code = crate::naming::control_board_board(self.make, self.board, &model);
|
let board_code = crate::naming::control_board_board(self.make, self.board, &model);
|
||||||
|
// Computed before `model` is moved into the struct literal below.
|
||||||
|
let pic_present = crate::scan::infer_pic(&model);
|
||||||
MinerRow {
|
MinerRow {
|
||||||
ip: self.ip.to_string(),
|
ip: self.ip.to_string(),
|
||||||
selected: false,
|
selected: false,
|
||||||
@@ -192,13 +194,9 @@ impl Board {
|
|||||||
// show variety offline). control_board is derived above via naming.
|
// show variety offline). control_board is derived above via naming.
|
||||||
algorithm: "SHA256".to_string(),
|
algorithm: "SHA256".to_string(),
|
||||||
control_board,
|
control_board,
|
||||||
pic_present: if self.model_id.contains("S21") {
|
// Use the same PIC inference the live scan uses (round 18 #12: the demo
|
||||||
Some(false) // noPIC example
|
// previously reimplemented a simplified version that disagreed with it).
|
||||||
} else if self.make.eq_ignore_ascii_case("antminer") {
|
pic_present,
|
||||||
Some(true)
|
|
||||||
} else {
|
|
||||||
None // WhatsMiner: unknown over the network
|
|
||||||
},
|
|
||||||
// Access: idle/view-only units (no worker) shown locked; the rest
|
// Access: idle/view-only units (no worker) shown locked; the rest
|
||||||
// unlocked. (Live rows infer this from control capabilities.)
|
// unlocked. (Live rows infer this from control capabilities.)
|
||||||
write_locked: Some(self.worker.is_empty()),
|
write_locked: Some(self.worker.is_empty()),
|
||||||
|
|||||||
@@ -689,7 +689,13 @@ impl MinerRow {
|
|||||||
if (0..base.len()).any(board_faulted) {
|
if (0..base.len()).any(board_faulted) {
|
||||||
for (i, h) in base.iter_mut().enumerate() {
|
for (i, h) in base.iter_mut().enumerate() {
|
||||||
if board_faulted(i) {
|
if board_faulted(i) {
|
||||||
*h = CompHealth::Down;
|
// A genuinely-undetected board stays grey ("not detected") even
|
||||||
|
// when a fault text names it: a message like "chain N not found"
|
||||||
|
// describes exactly that missing board, and grey-vs-red is the
|
||||||
|
// documented distinction (round 18 #12). Only detected boards go red.
|
||||||
|
if *h != CompHealth::Unreachable {
|
||||||
|
*h = CompHealth::Down;
|
||||||
|
}
|
||||||
} else if *h == CompHealth::Down {
|
} else if *h == CompHealth::Down {
|
||||||
*h = ok; // stall-reddened but not named by the fault codes
|
*h = ok; // stall-reddened but not named by the fault codes
|
||||||
}
|
}
|
||||||
@@ -1896,6 +1902,21 @@ mod tests {
|
|||||||
assert_eq!(rb[0], CompHealth::Ok); // running -> green despite PSU fault
|
assert_eq!(rb[0], CompHealth::Ok); // running -> green despite PSU fault
|
||||||
assert_eq!(rb[1], CompHealth::Ok);
|
assert_eq!(rb[1], CompHealth::Ok);
|
||||||
assert_eq!(rb[2], CompHealth::Unreachable); // only the undetected board is grey
|
assert_eq!(rb[2], CompHealth::Unreachable); // only the undetected board is grey
|
||||||
|
|
||||||
|
// Round 18 #12: a genuinely-undetected board that is ALSO named by a board
|
||||||
|
// fault (e.g. a "chain 2 not found" message attributed to Board(2)) must
|
||||||
|
// stay grey ("not detected"), not turn red -- grey vs red is the
|
||||||
|
// detected/undetected distinction.
|
||||||
|
let missing_named = MinerRow {
|
||||||
|
is_mining: true,
|
||||||
|
board_status: vec![BoardHealth::Ok, BoardHealth::Ok, BoardHealth::Missing],
|
||||||
|
faults: vec![fault(FaultComponent::Board(2), "Chain 2 not found, check connection")],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let mb = missing_named.board_healths();
|
||||||
|
assert_eq!(mb[0], CompHealth::Ok);
|
||||||
|
assert_eq!(mb[1], CompHealth::Ok);
|
||||||
|
assert_eq!(mb[2], CompHealth::Unreachable, "undetected board named by a fault stays grey");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -287,8 +287,10 @@ fn is_s17_era(clean_model: &str) -> bool {
|
|||||||
/// S19k Pro, and the S21 Pro; everything else AMLogic is the 120mm C76. asic-rs
|
/// S19k Pro, and the S21 Pro; everything else AMLogic is the 120mm C76. asic-rs
|
||||||
/// cannot tell these apart, so this is a model-family heuristic, not a read.
|
/// cannot tell these apart, so this is a model-family heuristic, not a read.
|
||||||
fn is_aml_140mm(clean_model: &str) -> bool {
|
fn is_aml_140mm(clean_model: &str) -> bool {
|
||||||
|
// Per the doc above: XP-class, the S19k Pro, and the S21 Pro -- NOT every S21
|
||||||
|
// (plain S21 / S21+ / S21e are the 120mm C76 board) (round 18 #12).
|
||||||
let m = clean_model.trim_start();
|
let m = clean_model.trim_start();
|
||||||
m.contains("XP") || m.starts_with("S19k") || m.starts_with("S21")
|
m.contains("XP") || m.starts_with("S19k") || m.contains("S21 Pro")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Nameplate expected hashrate in Sol/s for an Equihash (Zcash) miner model, when
|
/// Nameplate expected hashrate in Sol/s for an Equihash (Zcash) miner model, when
|
||||||
|
|||||||
@@ -599,7 +599,7 @@ mod board_index_tests {
|
|||||||
///
|
///
|
||||||
/// The one genuinely ambiguous model is the plain "S19j Pro" (both PIC and noPIC
|
/// The one genuinely ambiguous model is the plain "S19j Pro" (both PIC and noPIC
|
||||||
/// revisions exist); it is assumed PIC unless the model string says noPIC.
|
/// revisions exist); it is assumed PIC unless the model string says noPIC.
|
||||||
fn infer_pic(model: &str) -> Option<bool> {
|
pub(crate) fn infer_pic(model: &str) -> Option<bool> {
|
||||||
let m = model.to_lowercase();
|
let m = model.to_lowercase();
|
||||||
if m.contains("nopic") {
|
if m.contains("nopic") {
|
||||||
return Some(false);
|
return Some(false);
|
||||||
|
|||||||
+111
-10
@@ -647,6 +647,10 @@ pub struct App {
|
|||||||
// the first time fill_rows runs with rows present, so the default widths fit
|
// the first time fill_rows runs with rows present, so the default widths fit
|
||||||
// their contents (capped) once and manual resizes afterwards are preserved.
|
// their contents (capped) once and manual resizes afterwards are preserved.
|
||||||
columns_autosized: bool,
|
columns_autosized: bool,
|
||||||
|
// Set when a scan streamed new rows this drain; flushed by tick() at most once
|
||||||
|
// per second (or immediately once the scan ends) so the full table refill runs
|
||||||
|
// ~1 Hz during a scan instead of every fast tick (round 18 #12).
|
||||||
|
rows_dirty: bool,
|
||||||
// The columns the wxDataViewCtrl was actually built with, in creation order.
|
// The columns the wxDataViewCtrl was actually built with, in creation order.
|
||||||
// fill_rows/header_click/reorder index the widget through table_columns() and
|
// fill_rows/header_click/reorder index the widget through table_columns() and
|
||||||
// assume it stays in lockstep; with auto-hide-empty on, a scan can change which
|
// assume it stays in lockstep; with auto-hide-empty on, a scan can change which
|
||||||
@@ -709,6 +713,10 @@ pub struct App {
|
|||||||
// IPs the current config action targets, re-probed after it completes so the
|
// IPs the current config action targets, re-probed after it completes so the
|
||||||
// table reflects the change (e.g. the identify light toggling).
|
// table reflects the change (e.g. the identify light toggling).
|
||||||
action_targets: Vec<String>,
|
action_targets: Vec<String>,
|
||||||
|
// A new password from an in-flight ChangePassword action, applied to the saved
|
||||||
|
// credentials once the action succeeds so the toolkit keeps reaching the miners
|
||||||
|
// it just changed (round 18 #12).
|
||||||
|
pending_password_update: Option<String>,
|
||||||
// Per-miner in-flight operation label (round 14 #4): while a miner has an
|
// Per-miner in-flight operation label (round 14 #4): while a miner has an
|
||||||
// operation running (refresh, config action, light, firmware, restore, access
|
// operation running (refresh, config action, light, firmware, restore, access
|
||||||
// check), its Health cell shows this text instead of the component icons.
|
// check), its Health cell shows this text instead of the component icons.
|
||||||
@@ -1022,6 +1030,7 @@ pub fn build(frame: Widget) -> App {
|
|||||||
progress,
|
progress,
|
||||||
table: None,
|
table: None,
|
||||||
columns_autosized: false,
|
columns_autosized: false,
|
||||||
|
rows_dirty: false,
|
||||||
built_columns: Vec::new(),
|
built_columns: Vec::new(),
|
||||||
table_parent,
|
table_parent,
|
||||||
root_sizer: root,
|
root_sizer: root,
|
||||||
@@ -1053,6 +1062,7 @@ pub fn build(frame: Widget) -> App {
|
|||||||
action_total: 0,
|
action_total: 0,
|
||||||
action_done: 0,
|
action_done: 0,
|
||||||
action_targets: Vec::new(),
|
action_targets: Vec::new(),
|
||||||
|
pending_password_update: None,
|
||||||
op_status: std::collections::HashMap::new(),
|
op_status: std::collections::HashMap::new(),
|
||||||
confirm_dialog: frame,
|
confirm_dialog: frame,
|
||||||
pending_confirm: None,
|
pending_confirm: None,
|
||||||
@@ -1836,13 +1846,17 @@ impl App {
|
|||||||
wx_rs::set_status_text("firmware flash in progress -- wait for it to finish");
|
wx_rs::set_status_text("firmware flash in progress -- wait for it to finish");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// A restore-to-stock is reverting + rebooting miners; writing pools mid-
|
// This path sets self.action directly, so it needs start_action's full
|
||||||
// revert could hit a unit in an undefined state (round 18 #12 -- this path
|
// exclusivity guard: don't write pools during a restore or a live scan
|
||||||
// sets self.action directly, so it needs the same guard as start_action).
|
// (round 18 #12).
|
||||||
if self.restore.is_some() {
|
if self.restore.is_some() {
|
||||||
wx_rs::set_status_text("restore-to-stock in progress -- wait for it to finish");
|
wx_rs::set_status_text("restore-to-stock in progress -- wait for it to finish");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if self.scanning {
|
||||||
|
wx_rs::set_status_text("scan in progress -- wait for it to finish");
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Collect the raw rows: (address, account, worker_template, password).
|
// Collect the raw rows: (address, account, worker_template, password).
|
||||||
let mut rows: Vec<(String, String, String, String)> = Vec::new();
|
let mut rows: Vec<(String, String, String, String)> = Vec::new();
|
||||||
for row in 0..3usize {
|
for row in 0..3usize {
|
||||||
@@ -1920,6 +1934,14 @@ impl App {
|
|||||||
wx_rs::set_status_text("restore-to-stock in progress -- wait for it to finish");
|
wx_rs::set_status_text("restore-to-stock in progress -- wait for it to finish");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// A scan is opening its own connections to these same miners; a mutating
|
||||||
|
// action racing the scan's probe traffic can be dropped or interleaved, so
|
||||||
|
// hold it until the scan finishes (round 18 #12 -- matches the flash/restore
|
||||||
|
// invariant).
|
||||||
|
if self.scanning {
|
||||||
|
wx_rs::set_status_text("scan in progress -- wait for it to finish");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if let Some(old) = self.action.take() {
|
if let Some(old) = self.action.take() {
|
||||||
old.stop();
|
old.stop();
|
||||||
// The superseded action's drain will never run again, so clear its
|
// The superseded action's drain will never run again, so clear its
|
||||||
@@ -1934,6 +1956,13 @@ impl App {
|
|||||||
// line; the bottom-right indicator still surfaces failures at the end.
|
// line; the bottom-right indicator still surfaces failures at the end.
|
||||||
crate::logs::log(format!("apply {} to {} miner(s)", action.label(), ips.len()));
|
crate::logs::log(format!("apply {} to {} miner(s)", action.label(), ips.len()));
|
||||||
self.action_targets = ips.clone();
|
self.action_targets = ips.clone();
|
||||||
|
// Remember a password change so we can update our own saved credentials
|
||||||
|
// once it succeeds -- otherwise the toolkit keeps using the old password
|
||||||
|
// and locks itself out of the miners it just changed (round 18 #12).
|
||||||
|
self.pending_password_update = match &action {
|
||||||
|
scan::ConfigAction::ChangePassword(p) => Some(p.clone()),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
self.set_op_status(&ips, &action.progress_label());
|
self.set_op_status(&ips, &action.progress_label());
|
||||||
self.action = Some(scan::start_config_action(ips, action));
|
self.action = Some(scan::start_config_action(ips, action));
|
||||||
// Clear any stale error/warning from a previous operation; the new
|
// Clear any stale error/warning from a previous operation; the new
|
||||||
@@ -2238,7 +2267,10 @@ impl App {
|
|||||||
Ok(scan::AccessProbeMsg::Result { ip, locked, error }) => {
|
Ok(scan::AccessProbeMsg::Result { ip, locked, error }) => {
|
||||||
op_clear.push(ip.clone());
|
op_clear.push(ip.clone());
|
||||||
if let Some(r) = self.rows.iter_mut().find(|r| r.ip == ip) {
|
if let Some(r) = self.rows.iter_mut().find(|r| r.ip == ip) {
|
||||||
if error.is_none() {
|
// Only a definitive answer updates the cell; an indeterminate
|
||||||
|
// probe (locked = None) must not blank a previously-known
|
||||||
|
// locked/unlocked state (round 18 #12).
|
||||||
|
if error.is_none() && locked.is_some() {
|
||||||
r.write_locked = locked;
|
r.write_locked = locked;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -2488,7 +2520,14 @@ impl App {
|
|||||||
PromptKind::Password => format!("New web/API password for {n} miner(s):"),
|
PromptKind::Password => format!("New web/API password for {n} miner(s):"),
|
||||||
};
|
};
|
||||||
root.add(Widget::static_text(dlg, &lbl), 0, sf::BORDER_ALL, 8);
|
root.add(Widget::static_text(dlg, &lbl), 0, sf::BORDER_ALL, 8);
|
||||||
let input = Widget::text_ctrl(dlg, false);
|
// The change-password prompt masks its field so the new fleet password is
|
||||||
|
// never shown in the clear (round 18 #12); the numeric/timezone prompts use
|
||||||
|
// a normal field.
|
||||||
|
let input = if matches!(kind, PromptKind::Password) {
|
||||||
|
Widget::password_ctrl(dlg)
|
||||||
|
} else {
|
||||||
|
Widget::text_ctrl(dlg, false)
|
||||||
|
};
|
||||||
input.set_min_size(200, -1);
|
input.set_min_size(200, -1);
|
||||||
root.add(input, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 8);
|
root.add(input, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 8);
|
||||||
let btns = Widget::box_sizer(false);
|
let btns = Widget::box_sizer(false);
|
||||||
@@ -2859,6 +2898,13 @@ impl App {
|
|||||||
for (name, user_ctrl, pass_ctrl) in &self.fwcreds_rows {
|
for (name, user_ctrl, pass_ctrl) in &self.fwcreds_rows {
|
||||||
let user = user_ctrl.get_value();
|
let user = user_ctrl.get_value();
|
||||||
let pass = pass_ctrl.get_value();
|
let pass = pass_ctrl.get_value();
|
||||||
|
// A fully-blank row means "no override, use the shipped default" -- the
|
||||||
|
// natural way to clear one firmware's override. Without this, a blanked
|
||||||
|
// row was saved as an explicit ("","") override that then broke auth
|
||||||
|
// fleet-wide for that firmware (round 18 #12).
|
||||||
|
if user.trim().is_empty() && pass.trim().is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let default = credentials::firmware_default_for(name);
|
let default = credentials::firmware_default_for(name);
|
||||||
if (user.clone(), pass.clone()) != default {
|
if (user.clone(), pass.clone()) != default {
|
||||||
map.insert(name.clone(), (user, pass));
|
map.insert(name.clone(), (user, pass));
|
||||||
@@ -2935,6 +2981,34 @@ impl App {
|
|||||||
} else {
|
} else {
|
||||||
Some((false, format!("apply: {}/{total} miner(s) failed", total - ok)))
|
Some((false, format!("apply: {}/{total} miner(s) failed", total - ok)))
|
||||||
});
|
});
|
||||||
|
// A password change succeeded on every target: update our own
|
||||||
|
// saved global credential so the toolkit keeps reaching them. On
|
||||||
|
// a partial change we leave saved creds alone (we can't tell which
|
||||||
|
// password now works for which miner) and warn (round 18 #12).
|
||||||
|
// (self.pending_password_update is a different field than self.action,
|
||||||
|
// so this disjoint borrow is fine while `h` still holds self.action.)
|
||||||
|
if let Some(newpass) = self.pending_password_update.take() {
|
||||||
|
if ok == total && total > 0 {
|
||||||
|
let user = credentials::load_credentials()
|
||||||
|
.map(|(u, _)| u)
|
||||||
|
.unwrap_or_else(|| "root".into());
|
||||||
|
match credentials::save_credentials(&user, &newpass) {
|
||||||
|
Ok(()) => crate::logs::log(
|
||||||
|
"saved credentials updated to the new password".to_string(),
|
||||||
|
),
|
||||||
|
Err(e) => crate::logs::log(format!(
|
||||||
|
"could not update saved credentials after password change: {e}"
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
crate::logs::log(
|
||||||
|
"password change was partial -- saved credentials left unchanged; \
|
||||||
|
update Settings > Credentials manually so the toolkit can reach \
|
||||||
|
the changed miners"
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
finished = true;
|
finished = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3120,7 +3194,15 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if changed {
|
if changed {
|
||||||
self.fill_rows();
|
if self.scanning {
|
||||||
|
// Still scanning: defer the whole-table refill to tick()'s ~1 Hz
|
||||||
|
// flush so streaming rows don't trigger a refill on every fast tick
|
||||||
|
// (round 18 #12).
|
||||||
|
self.rows_dirty = true;
|
||||||
|
} else {
|
||||||
|
// The scan just ended (or wasn't running): show the final state now.
|
||||||
|
self.fill_rows();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3140,6 +3222,13 @@ impl App {
|
|||||||
// auto-rescan scheduler + idle status only need ~1 Hz, so run them once
|
// auto-rescan scheduler + idle status only need ~1 Hz, so run them once
|
||||||
// per second.
|
// per second.
|
||||||
self.tick_accum = self.tick_accum.wrapping_add(1);
|
self.tick_accum = self.tick_accum.wrapping_add(1);
|
||||||
|
// Flush a scan's batched row updates at most once per second (or right away
|
||||||
|
// once the scan has ended), so the whole-table refill runs ~1 Hz during a
|
||||||
|
// scan rather than on every fast tick (round 18 #12).
|
||||||
|
if self.rows_dirty && (!self.scanning || self.tick_accum.is_multiple_of(TICKS_PER_SEC)) {
|
||||||
|
self.rows_dirty = false;
|
||||||
|
self.fill_rows();
|
||||||
|
}
|
||||||
if !self.tick_accum.is_multiple_of(TICKS_PER_SEC) {
|
if !self.tick_accum.is_multiple_of(TICKS_PER_SEC) {
|
||||||
return to_show;
|
return to_show;
|
||||||
}
|
}
|
||||||
@@ -3177,12 +3266,22 @@ impl App {
|
|||||||
/// overlap rather than block the UI by joining the old scan thread (which
|
/// overlap rather than block the UI by joining the old scan thread (which
|
||||||
/// could freeze it for up to the per-miner scan timeout); the probes target
|
/// could freeze it for up to the per-miner scan timeout); the probes target
|
||||||
/// live miners, so a momentary overlap is harmless.
|
/// live miners, so a momentary overlap is harmless.
|
||||||
fn begin_scan(&mut self, lines: Vec<String>) {
|
/// Returns whether a scan actually started (false if deferred, e.g. mid-flash),
|
||||||
|
/// so callers don't overwrite the real status with a bogus "scanning..."
|
||||||
|
/// (round 18 #12).
|
||||||
|
fn begin_scan(&mut self, lines: Vec<String>) -> bool {
|
||||||
// Never probe the network while a firmware flash is uploading: a stray
|
// Never probe the network while a firmware flash is uploading: a stray
|
||||||
// scan connection to a miner mid-write can interrupt/corrupt the flash.
|
// scan connection to a miner mid-write can interrupt/corrupt the flash.
|
||||||
if self.flashing {
|
if self.flashing {
|
||||||
wx_rs::set_status_text("firmware flash in progress -- scan deferred");
|
wx_rs::set_status_text("firmware flash in progress -- scan deferred");
|
||||||
return;
|
return false;
|
||||||
|
}
|
||||||
|
// Symmetric to start_action's scan guard: don't start a scan (including an
|
||||||
|
// auto-rescan) while a config action or restore is writing to miners, so
|
||||||
|
// the two never race on the same unit (round 18 #12).
|
||||||
|
if self.action.is_some() || self.restore.is_some() {
|
||||||
|
wx_rs::set_status_text("operation in progress -- scan deferred");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if let Some(old) = self.scan.take() {
|
if let Some(old) = self.scan.take() {
|
||||||
old.stop();
|
old.stop();
|
||||||
@@ -3190,12 +3289,14 @@ impl App {
|
|||||||
self.scan = Some(scan::start_scan(lines, self.scan_timeout_secs));
|
self.scan = Some(scan::start_scan(lines, self.scan_timeout_secs));
|
||||||
self.scanning = true;
|
self.scanning = true;
|
||||||
self.countdown = 0;
|
self.countdown = 0;
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start a fresh scan of the saved ranges.
|
/// Start a fresh scan of the saved ranges.
|
||||||
fn start_new_scan(&mut self) {
|
fn start_new_scan(&mut self) {
|
||||||
self.begin_scan(scan::load_ranges());
|
if self.begin_scan(scan::load_ranges()) {
|
||||||
wx_rs::set_status_text("scanning...");
|
wx_rs::set_status_text("scanning...");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The table's selection changed (ctrl/shift-click). Mirror it into the
|
/// The table's selection changed (ctrl/shift-click). Mirror it into the
|
||||||
|
|||||||
Reference in New Issue
Block a user