Subject: [PATCH 0034] vnish: keep the reported boards and infer the algorithm for unknown models Field report 2026-11-03: VNish Antminer S19 (88) units showed no hashboard icons while hashing. VNish reports the model as "Antminer S19 (88)", which is not in asic-rs' alias table, so it parses to AntMinerModel::Unknown with no hardware table. parse_hashboards sized the board list from that table (board_count() = None -> 0 boards) and dropped all three live chains the miner reports in /summary. The same Unknown model also got HashAlgorithm::Unknown, so its hashrate was bucketed as "Unknown Hashrate". - VNish v1.2.x and v1.3.x parse_hashboards: when the model has no hardware table, size the boards from the highest 1-based chain id the miner reports (a dead middle board keeps its slot). Known models are unchanged. - infer_antminer_algo (family letter: S/T -> SHA-256, L -> Scrypt, Z -> Equihash, ambiguous -> Unknown) moves from the stock v2020 backend into asic-rs-makes-antminer as a public function; the stock backend and both VNish backends now use it for models the table cannot place. Tests: unknown_model_keeps_the_reported_chains (both VNish backends, chain data from the live 10.4.0.179 unit); the existing unknown_models_infer_algo_from_family_letter still passes against the moved helper. Live-verified read-only on all 13 fleet S19 (88) units (10.4.x, 10.7.1.190): three hashboard icons each, per-board state intact (e.g. one red board on 10.4.1.111), and the KPI reads "SHA-256 Hashrate". diff --git a/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs b/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs index 71195737..872bd1de 100644 --- a/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs +++ b/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs @@ -202,27 +202,7 @@ fn miner_conf_with_fan_config(miner_conf: &Value, config: FanConfig) -> Value { Value::Object(payload) } -/// Infer an Antminer's hash algorithm from its model-family letter, for models -/// asic-rs' alias table doesn't recognise (round 13 #5). Only the families whose -/// entire product line shares one algorithm are inferred; anything ambiguous -/// (the K-series spans Kadena/KHeavyHash/Eaglesong, DR is Blake256 while D is -/// X11) is left Unknown rather than guessed wrong. -fn infer_antminer_algo(model: &str) -> HashAlgorithm { - let upper = model.to_ascii_uppercase(); - let name = upper - .strip_prefix("ANTMINER ") - .unwrap_or(&upper) - .trim_start(); - match name.chars().next() { - // Z9 / Z11 / Z15 / Z15 Pro / Z15J -- the whole Z line is Equihash. - Some('Z') => HashAlgorithm::Equihash, - // L3+ / L7 / L9 / L11 -- the whole L line is Scrypt. - Some('L') => HashAlgorithm::Scrypt, - // S9..S21 and T9..T21 (and future revisions) are all SHA-256. - Some('S') | Some('T') => HashAlgorithm::SHA256, - _ => HashAlgorithm::Unknown, - } -} +use asic_rs_makes_antminer::models::infer_antminer_algo; impl AntMinerV2020 { pub fn new(ip: IpAddr, model: impl MinerModel) -> Self { diff --git a/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs b/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs index 2c14f217..3c8e1bee 100644 --- a/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs +++ b/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs @@ -1,5 +1,6 @@ use std::{collections::HashMap, net::IpAddr, str::FromStr, time::Duration}; +use asic_rs_makes_antminer::models::infer_antminer_algo; use anyhow; use asic_rs_core::{ config::{ @@ -17,7 +18,7 @@ use asic_rs_core::{ DataCollector, DataExtensions, DataExtractor, DataField, DataLocation, get_by_pointer, }, command::MinerCommand, - device::DeviceInfo, + device::{DeviceInfo, HashAlgorithm}, fan::FanData, hashrate::{HashRate, HashRateUnit}, message::{MessageSeverity, MinerComponent, MinerMessage}, @@ -52,7 +53,14 @@ pub struct VnishV120 { impl VnishV120 { pub fn new(ip: IpAddr, model: impl MinerModel) -> Self { let auth = Self::default_auth(); - let algo = model.hash_algorithm(); + // A model outside asic-rs' alias table (VNish's "Antminer S19 (88)") + // resolves to HashAlgorithm::Unknown, which left its hashrate bucketed + // as "Unknown Hashrate". Infer it from the Antminer family letter, as + // the stock backend does. + let algo = match model.hash_algorithm() { + HashAlgorithm::Unknown => infer_antminer_algo(&model.to_string()), + known => known, + }; VnishV120 { ip, web: VnishWebAPI::new(ip, 80, auth), @@ -509,8 +517,24 @@ impl GetHashboards for VnishV120 { .and_then(|v| v.pointer("/factory")) .and_then(|v| v.as_array()); - let mut hashboards: Vec = - (0..self.device_info.hardware.board_count().unwrap_or(0) as usize) + // The model's hardware table gives the board count. For a model asic-rs + // does not know (e.g. VNish "Antminer S19 (88)") there is no table, and + // sizing from it dropped every live chain -- the boards then vanished + // from the data although the miner reports them. Fall back to what the + // miner reports: the highest 1-based chain id, so a dead middle board + // still keeps its slot. + let reported_boards = all_chains + .iter() + .filter_map(|c| c.pointer("/id").and_then(|v| v.as_u64())) + .max() + .unwrap_or(0) as usize; + let board_count = self + .device_info + .hardware + .board_count() + .map(|n| n as usize) + .unwrap_or(reported_boards); + let mut hashboards: Vec = (0..board_count) .map(|idx| { BoardData::new(idx as u8, self.device_info.hardware.chips_for_board(idx)) }) @@ -1524,4 +1548,42 @@ mod tests { assert!(config.available.contains(&Tz::Etc__GMT)); assert_eq!(config.available.last(), Some(&Tz::Etc__GMTMinus14)); } + + /// Same as the 1.3.x backend: a model with no hardware table (VNish's + /// "Antminer S19 (88)") must keep the chains the miner reports instead of + /// sizing the board list to zero. Live 1.2.7 units (e.g. 10.4.1.111) run it. + #[tokio::test] + async fn unknown_model_keeps_the_reported_chains() { + let miner = VnishV120::new( + IpAddr::from([127, 0, 0, 1]), + AntMinerModel::Unknown("ANTMINER S19 (88)".to_string()), + ); + let mut results = HashMap::new(); + results.insert( + MinerCommand::WebAPI { + command: "info", + parameters: None, + }, + json!({ "miner": "Antminer S19 (88)", "hr_measure": "GH/s", "fw_version": "1.2.7" }), + ); + results.insert( + MinerCommand::WebAPI { + command: "summary", + parameters: None, + }, + json!({ "miner": { "hr_realtime": 82600.0, "chains": [ + { "id": 1, "hashrate_rt": 27537.83 }, + { "id": 2, "hashrate_rt": 27511.20 }, + { "id": 3, "hashrate_rt": 27601.04 } + ] } }), + ); + let mock_api = MockAPIClient::new(results); + let mut collector = DataCollector::new_with_client(&miner, &mock_api); + let miner_data = miner.parse_data(collector.collect_all().await); + + assert_eq!(miner_data.hashboards.len(), 3, "one board per reported chain"); + // ...and its hashrate is SHA-256 (family letter S), not "Unknown". + assert_eq!(miner_data.hashrate.expect("hashrate").algo, HashAlgorithm::SHA256); + assert!(miner_data.hashboards.iter().all(|b| b.hashrate.is_some())); + } } diff --git a/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs b/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs index e6247923..0e009f1c 100644 --- a/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs +++ b/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs @@ -1,5 +1,6 @@ use std::{collections::HashMap, net::IpAddr, str::FromStr, time::Duration}; +use asic_rs_makes_antminer::models::infer_antminer_algo; use anyhow; use asic_rs_core::{ config::{ @@ -17,7 +18,7 @@ use asic_rs_core::{ DataCollector, DataExtensions, DataExtractor, DataField, DataLocation, get_by_pointer, }, command::MinerCommand, - device::DeviceInfo, + device::{DeviceInfo, HashAlgorithm}, fan::FanData, hashrate::{HashRate, HashRateUnit}, message::{MessageSeverity, MinerComponent, MinerMessage}, @@ -52,7 +53,14 @@ pub struct VnishV130 { impl VnishV130 { pub fn new(ip: IpAddr, model: impl MinerModel) -> Self { let auth = Self::default_auth(); - let algo = model.hash_algorithm(); + // A model outside asic-rs' alias table (VNish's "Antminer S19 (88)") + // resolves to HashAlgorithm::Unknown, which left its hashrate bucketed + // as "Unknown Hashrate". Infer it from the Antminer family letter, as + // the stock backend does. + let algo = match model.hash_algorithm() { + HashAlgorithm::Unknown => infer_antminer_algo(&model.to_string()), + known => known, + }; VnishV130 { ip, web: VnishWebAPI::new(ip, 80, auth), @@ -516,8 +524,24 @@ impl GetHashboards for VnishV130 { .and_then(|v| v.pointer("/factory")) .and_then(|v| v.as_array()); - let mut hashboards: Vec = - (0..self.device_info.hardware.board_count().unwrap_or(0) as usize) + // The model's hardware table gives the board count. For a model asic-rs + // does not know (e.g. VNish "Antminer S19 (88)") there is no table, and + // sizing from it dropped every live chain -- the boards then vanished + // from the data although the miner reports them. Fall back to what the + // miner reports: the highest 1-based chain id, so a dead middle board + // still keeps its slot. + let reported_boards = all_chains + .iter() + .filter_map(|c| c.pointer("/id").and_then(|v| v.as_u64())) + .max() + .unwrap_or(0) as usize; + let board_count = self + .device_info + .hardware + .board_count() + .map(|n| n as usize) + .unwrap_or(reported_boards); + let mut hashboards: Vec = (0..board_count) .map(|idx| { BoardData::new(idx as u8, self.device_info.hardware.chips_for_board(idx)) }) @@ -1661,4 +1685,46 @@ mod tests { assert!(config.available.contains(&Tz::Etc__GMT)); assert_eq!(config.available.last(), Some(&Tz::Etc__GMTMinus14)); } + + /// A model asic-rs has no hardware table for -- VNish reports the 88-chip + /// S19 as "Antminer S19 (88)" -- must still surface the boards the miner + /// reports. Sizing the board list from the (absent) table dropped all + /// three live chains, so the GUI drew no hashboard icons for a hashing + /// miner. Chain values match the live 10.4.0.179 unit. + #[tokio::test] + async fn unknown_model_keeps_the_reported_chains() { + let miner = VnishV130::new( + IpAddr::from([127, 0, 0, 1]), + AntMinerModel::Unknown("ANTMINER S19 (88)".to_string()), + ); + let mut results = HashMap::new(); + results.insert( + web("info"), + json!({ "miner": "Antminer S19 (88)", "model": "s19-88", "hr_measure": "GH/s" }), + ); + results.insert( + web("summary"), + json!({ + "miner": { + "hr_realtime": 82600.0, + "chains": [ + { "id": 1, "hashrate_rt": 27537.83, "chip_statuses": { "grey": 88 } }, + { "id": 2, "hashrate_rt": 27511.20, "chip_statuses": { "grey": 88 } }, + { "id": 3, "hashrate_rt": 27601.04, "chip_statuses": { "grey": 88 } } + ] + } + }), + ); + let mock_api = MockAPIClient::new(results); + let mut collector = DataCollector::new_with_client(&miner, &mock_api); + let miner_data = miner.parse_data(collector.collect_all().await); + + assert_eq!(miner_data.hashboards.len(), 3, "one board per reported chain"); + // ...and its hashrate is SHA-256 (family letter S), not "Unknown". + assert_eq!(miner_data.hashrate.expect("hashrate").algo, HashAlgorithm::SHA256); + for (i, board) in miner_data.hashboards.iter().enumerate() { + assert_eq!(board.position as usize, i); + assert!(board.hashrate.is_some(), "board {i} keeps its live hashrate"); + } + } } diff --git a/vendor/asic-rs-makes-antminer/src/models.rs b/vendor/asic-rs-makes-antminer/src/models.rs index f52639fe..e3185089 100644 --- a/vendor/asic-rs-makes-antminer/src/models.rs +++ b/vendor/asic-rs-makes-antminer/src/models.rs @@ -201,6 +201,29 @@ pub enum AntMinerModel { Unknown(String), } +/// Infer an Antminer's hash algorithm from its model-family letter, for models +/// asic-rs' alias table doesn't recognise (round 13 #5). Only the families whose +/// entire product line shares one algorithm are inferred; anything ambiguous +/// (the K-series spans Kadena/KHeavyHash/Eaglesong, DR is Blake256 while D is +/// X11) is left Unknown rather than guessed wrong. Shared by every firmware +/// backend that runs on Antminer hardware (stock, VNish). +pub fn infer_antminer_algo(model: &str) -> HashAlgorithm { + let upper = model.to_ascii_uppercase(); + let name = upper + .strip_prefix("ANTMINER ") + .unwrap_or(&upper) + .trim_start(); + match name.chars().next() { + // Z9 / Z11 / Z15 / Z15 Pro / Z15J -- the whole Z line is Equihash. + Some('Z') => HashAlgorithm::Equihash, + // L3+ / L7 / L9 / L11 -- the whole L line is Scrypt. + Some('L') => HashAlgorithm::Scrypt, + // S9..S21 and T9..T21 (and future revisions) are all SHA-256. + Some('S') | Some('T') => HashAlgorithm::SHA256, + _ => HashAlgorithm::Unknown, + } +} + impl FromStr for AntMinerModel { type Err = ModelSelectionError;