diff --git a/thirdparty/asic-rs/patches/0034-vnish-unknown-model-boards-and-algorithm.patch b/thirdparty/asic-rs/patches/0034-vnish-unknown-model-boards-and-algorithm.patch new file mode 100644 index 00000000..08b9af83 --- /dev/null +++ b/thirdparty/asic-rs/patches/0034-vnish-unknown-model-boards-and-algorithm.patch @@ -0,0 +1,308 @@ +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; + diff --git a/vendor/asic-rs-firmwares-antminer/.cargo-checksum.json b/vendor/asic-rs-firmwares-antminer/.cargo-checksum.json index c61fb1b3..7788d834 100644 --- a/vendor/asic-rs-firmwares-antminer/.cargo-checksum.json +++ b/vendor/asic-rs-firmwares-antminer/.cargo-checksum.json @@ -1 +1 @@ -{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"6e42d50107b1a43fd7cf4a4c4f538468a337ed219ad8d6b23bd9abdabd123bd5","Cargo.lock":"7f984c7231c91f2def8f3e2e923a85c2e0b3239492f5ce23400881ea4de1aa16","Cargo.toml":"8a447efc18cd97d019a9771fb258b06f694499500561564eec75480e46bcc554","Cargo.toml.orig":"6c9e7b86804255debe03545c6358eb975d3d470810a19e6c40c680299a686b1f","src/backends/mod.rs":"65cdc60cdf38968f5a7e197338f4cf6173406ce69a4f0aaa96a9e29f4f581b6e","src/backends/v2020/firmware.rs":"5a41bfb8f42f17523e68f8702e87d75bcdb268bd4950bb66227f6966ef3576a9","src/backends/v2020/mod.rs":"b2dbba5377a739bc8be3380cfbd09aa80893841c15c305bfd25f900ba7b6a0c9","src/backends/v2020/rpc.rs":"b517f88b9125fe1d8a20d5167f5d0d105b1339fce3d1a9fad5592e00470f46fb","src/backends/v2020/web.rs":"a6a3ad3eb77551b098b0092553b02cee43d165476d8c92164e12a1e765753b0d","src/backends/v2023_07/firmware.rs":"c07668e351d48dab3e24511b1aa9ab5e408bbcb5a438fdb0542a1377f94b9bbb","src/backends/v2023_07/mod.rs":"0906bff13eb51bd47fb0e06cc2c1955fe459c601cb467efc917801ead825dd61","src/backends/v2023_07/rpc.rs":"2b24bbb432b302dd15f7a354054fc96c6a75cac2c8e75b8bcc11da37255a05a3","src/backends/v2023_07/web.rs":"d39b67ed83781b2c4fa84a445b9ffe785ae3001941f800ad9860e050c61c6506","src/firmware.rs":"e75c21d63218204b61bfab067599402e5c0b20452beaf0b16bfa79bf8afb6b35","src/lib.rs":"53f7acddeff8f7d82f80d09e0a9f91962011f9ccf2e441c4ca05cd7fc4eb292e","src/test/json/mod.rs":"a3ef4d6805bb4f8ea087e3a9b875e5a1664580e1ff3e3cd2015bb0c5c18ae7bb","src/test/json/v2020/devs.json":"df17cdfc9522e23450702b93f70ff701892db54c6ce6d986300453ad5e0d22db","src/test/json/v2020/mod.rs":"4c2512d36af834d400a865a94c2e8b1919f9d8dcbf54ab2530c73861c51af67d","src/test/json/v2020/pools.json":"4c4d19ad3ef0de84bfb18daaa48428b5f7917d23287c0196eacf3a6e389e7634","src/test/json/v2020/stats.json":"6d3cb463abb7539ae77aa44ef38e62a5dc0db54670aeacf3bbd01e83f49aa1fd","src/test/json/v2020/summary.json":"2f18c81f989b7c5f70dcb0ddac0520e56ec98b6da25c24e59354a6126c965dae","src/test/json/v2020/system_info.json":"51d1ce922e39a254518a24be56ca86ef1b5843582fb26c1ff0ec4ff6f8f91ccf","src/test/json/v2020/version.json":"ae898c4c9ea3462c3e79f9de755f1fccb4ef122b94a4a512e61aa74491c1a8e9","src/test/json/v2023_07/l11_stats.json":"2eab324f253ced9a0ea4e46466691e0e71fc6fde7558fec86bd5acf6bb9c717d","src/test/json/v2023_07/l11_summary.json":"1e0fdb61b968005d0ec5393d9dc889b09efb1398ffa427629bcc0a98d1b67c22","src/test/json/v2023_07/l11_version.json":"d116921a71731c6e492aed109731c39561e34a24c7df2a88d11ac52b80f6100a","src/test/json/v2023_07/l9_stats.json":"731ee545f16dafd356d22703248b91a37f74585ad73cc27441eb3461ce53dca0","src/test/json/v2023_07/l9_summary.json":"b32b5131ad46859b270d2dbb6bdba3c4e5d7301298daee4ce56332c98faaf81d","src/test/json/v2023_07/l9_version.json":"82f03ca6ea8873f12c4d9455f21b98c547801b58fbff1dcd83c837c0f337a129","src/test/json/v2023_07/mod.rs":"1360a8b155b120f2e755ede0736bcc0d76a9d1d693b984a1b51a16e6c0413791","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"0c06e3ecbf95ae3fe5e30aacae55cf6e7ad3d965f4a93b2f85c7b64f61fc75e2"} \ No newline at end of file +{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"6e42d50107b1a43fd7cf4a4c4f538468a337ed219ad8d6b23bd9abdabd123bd5","Cargo.lock":"7f984c7231c91f2def8f3e2e923a85c2e0b3239492f5ce23400881ea4de1aa16","Cargo.toml":"8a447efc18cd97d019a9771fb258b06f694499500561564eec75480e46bcc554","Cargo.toml.orig":"6c9e7b86804255debe03545c6358eb975d3d470810a19e6c40c680299a686b1f","src/backends/mod.rs":"65cdc60cdf38968f5a7e197338f4cf6173406ce69a4f0aaa96a9e29f4f581b6e","src/backends/v2020/firmware.rs":"5a41bfb8f42f17523e68f8702e87d75bcdb268bd4950bb66227f6966ef3576a9","src/backends/v2020/mod.rs":"f709048edc8eddf71d848d0f3c55c3e2c748726072f9c838482062b66524d875","src/backends/v2020/rpc.rs":"b517f88b9125fe1d8a20d5167f5d0d105b1339fce3d1a9fad5592e00470f46fb","src/backends/v2020/web.rs":"a6a3ad3eb77551b098b0092553b02cee43d165476d8c92164e12a1e765753b0d","src/backends/v2023_07/firmware.rs":"c07668e351d48dab3e24511b1aa9ab5e408bbcb5a438fdb0542a1377f94b9bbb","src/backends/v2023_07/mod.rs":"0906bff13eb51bd47fb0e06cc2c1955fe459c601cb467efc917801ead825dd61","src/backends/v2023_07/rpc.rs":"2b24bbb432b302dd15f7a354054fc96c6a75cac2c8e75b8bcc11da37255a05a3","src/backends/v2023_07/web.rs":"d39b67ed83781b2c4fa84a445b9ffe785ae3001941f800ad9860e050c61c6506","src/firmware.rs":"e75c21d63218204b61bfab067599402e5c0b20452beaf0b16bfa79bf8afb6b35","src/lib.rs":"53f7acddeff8f7d82f80d09e0a9f91962011f9ccf2e441c4ca05cd7fc4eb292e","src/test/json/mod.rs":"a3ef4d6805bb4f8ea087e3a9b875e5a1664580e1ff3e3cd2015bb0c5c18ae7bb","src/test/json/v2020/devs.json":"df17cdfc9522e23450702b93f70ff701892db54c6ce6d986300453ad5e0d22db","src/test/json/v2020/mod.rs":"4c2512d36af834d400a865a94c2e8b1919f9d8dcbf54ab2530c73861c51af67d","src/test/json/v2020/pools.json":"4c4d19ad3ef0de84bfb18daaa48428b5f7917d23287c0196eacf3a6e389e7634","src/test/json/v2020/stats.json":"6d3cb463abb7539ae77aa44ef38e62a5dc0db54670aeacf3bbd01e83f49aa1fd","src/test/json/v2020/summary.json":"2f18c81f989b7c5f70dcb0ddac0520e56ec98b6da25c24e59354a6126c965dae","src/test/json/v2020/system_info.json":"51d1ce922e39a254518a24be56ca86ef1b5843582fb26c1ff0ec4ff6f8f91ccf","src/test/json/v2020/version.json":"ae898c4c9ea3462c3e79f9de755f1fccb4ef122b94a4a512e61aa74491c1a8e9","src/test/json/v2023_07/l11_stats.json":"2eab324f253ced9a0ea4e46466691e0e71fc6fde7558fec86bd5acf6bb9c717d","src/test/json/v2023_07/l11_summary.json":"1e0fdb61b968005d0ec5393d9dc889b09efb1398ffa427629bcc0a98d1b67c22","src/test/json/v2023_07/l11_version.json":"d116921a71731c6e492aed109731c39561e34a24c7df2a88d11ac52b80f6100a","src/test/json/v2023_07/l9_stats.json":"731ee545f16dafd356d22703248b91a37f74585ad73cc27441eb3461ce53dca0","src/test/json/v2023_07/l9_summary.json":"b32b5131ad46859b270d2dbb6bdba3c4e5d7301298daee4ce56332c98faaf81d","src/test/json/v2023_07/l9_version.json":"82f03ca6ea8873f12c4d9455f21b98c547801b58fbff1dcd83c837c0f337a129","src/test/json/v2023_07/mod.rs":"1360a8b155b120f2e755ede0736bcc0d76a9d1d693b984a1b51a16e6c0413791","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"0c06e3ecbf95ae3fe5e30aacae55cf6e7ad3d965f4a93b2f85c7b64f61fc75e2"} \ No newline at end of file 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/.cargo-checksum.json b/vendor/asic-rs-firmwares-vnish/.cargo-checksum.json index fdf753f7..f9ea49be 100644 --- a/vendor/asic-rs-firmwares-vnish/.cargo-checksum.json +++ b/vendor/asic-rs-firmwares-vnish/.cargo-checksum.json @@ -1 +1 @@ -{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"de321c89f62a60690ba07d6bb145ac688c6141c458638e68b3ed36b50b8de1f1","Cargo.lock":"5942ec7c9cf5c201bd32442d65020dc3ae72e33cb5aaf374b2a26501571a1487","Cargo.toml":"cb9ee00cbb415fa66a71a7d4822839bb3552336ec9ab975ae7b1137c711449cb","Cargo.toml.orig":"08409c395e4d502015da62e97efdc9c5bc6e3076031144f3f5aa35c900c7c735","src/backends/mod.rs":"26591e67688f8d015242295dde5050c4b34986e9980018a855346291a0472206","src/backends/v1_2_0/mod.rs":"a1b0eb9e2e57cad0190eb8f31dafff0999e31c3602db2b8d84e9dd45c955b623","src/backends/v1_2_0/web.rs":"ac89f16bf623f7d85590d34b45c99b0e522d9d434b4c22af7fa8a8a653e09d2e","src/backends/v1_3_0/mod.rs":"9aa230fe942ca775f812300f0041f5565861ef32ad73207e48d02b41e423ee25","src/backends/v1_3_0/web.rs":"1ec4cbe6bdc26f165d9e54e9bf2aac4c3706357ce4677dc21113710d4a26c3c1","src/firmware.rs":"168eeffaef90cb1525bb2e126e73905b5205d49215437263813e30323f6b7a05","src/lib.rs":"16ea1c0007fa6d6c86c1f83d3ac9cdf065cd9936cd52f35ef89c227397bbc54a","src/timezone.rs":"309bf23de1bdc9126bde5db8dabff0d2c0fea797dbf2630a772a18539838a05e"},"package":"1cb662e56f104c0fe45c8ccdac13f60cbcaad45ac228f939c6ac46ff40335052"} \ No newline at end of file +{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"de321c89f62a60690ba07d6bb145ac688c6141c458638e68b3ed36b50b8de1f1","Cargo.lock":"5942ec7c9cf5c201bd32442d65020dc3ae72e33cb5aaf374b2a26501571a1487","Cargo.toml":"cb9ee00cbb415fa66a71a7d4822839bb3552336ec9ab975ae7b1137c711449cb","Cargo.toml.orig":"08409c395e4d502015da62e97efdc9c5bc6e3076031144f3f5aa35c900c7c735","src/backends/mod.rs":"26591e67688f8d015242295dde5050c4b34986e9980018a855346291a0472206","src/backends/v1_2_0/mod.rs":"f0818aae9410bcf4cf6f2efbb867ce9ea8a7542cc9cf9942be1b99570e2912c4","src/backends/v1_2_0/web.rs":"ac89f16bf623f7d85590d34b45c99b0e522d9d434b4c22af7fa8a8a653e09d2e","src/backends/v1_3_0/mod.rs":"3e1e10869930c72135ec98e69293c0aeb07d4c31c06e8f8301aa1dbfc87552bb","src/backends/v1_3_0/web.rs":"1ec4cbe6bdc26f165d9e54e9bf2aac4c3706357ce4677dc21113710d4a26c3c1","src/firmware.rs":"168eeffaef90cb1525bb2e126e73905b5205d49215437263813e30323f6b7a05","src/lib.rs":"16ea1c0007fa6d6c86c1f83d3ac9cdf065cd9936cd52f35ef89c227397bbc54a","src/timezone.rs":"309bf23de1bdc9126bde5db8dabff0d2c0fea797dbf2630a772a18539838a05e"},"package":"1cb662e56f104c0fe45c8ccdac13f60cbcaad45ac228f939c6ac46ff40335052"} \ No newline at end of file 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/.cargo-checksum.json b/vendor/asic-rs-makes-antminer/.cargo-checksum.json index a6165fe3..48a81321 100644 --- a/vendor/asic-rs-makes-antminer/.cargo-checksum.json +++ b/vendor/asic-rs-makes-antminer/.cargo-checksum.json @@ -1 +1 @@ -{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"aaaa0f14e3aff2543d3d09a4515efa5ab439f0651a36b582e87b9843d0475752","Cargo.lock":"58da2f3399ff680bf7d619204897b4edf5c03d336a8c3cceb54c9aba280bfed1","Cargo.toml":"57f92bf3808fa6f468dbabf43763a808d9ead128eef83b748f940ef3b219a80e","Cargo.toml.orig":"cbfb99fc843dd61ad2025dcfc16bd435afd2b6d43c2c983867af08af415916f1","src/hardware.rs":"6a52c19b38be83fe47ccf8f6c6fe3b7d9597575b79366fbc678ea3586953dd52","src/lib.rs":"b2f55767a7f3fdacb1e898c5cb961c2dec8481823f94386ee67628960e91bf7d","src/make.rs":"e968e4dbd745d485fc9ad4c5a4c081d679eddce11f66e572f81f2dbe37ede3f0","src/models.rs":"b4ea44fc627ff6c8b41bf8758d6ce6074aa690fe9f6c95a9cb3d1cdbd00e51d6"},"package":"67cca6e6bf4ac14562084ce7534521ffa7cd313fa39e2392f98ff98a047a4353"} \ No newline at end of file +{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"aaaa0f14e3aff2543d3d09a4515efa5ab439f0651a36b582e87b9843d0475752","Cargo.lock":"58da2f3399ff680bf7d619204897b4edf5c03d336a8c3cceb54c9aba280bfed1","Cargo.toml":"57f92bf3808fa6f468dbabf43763a808d9ead128eef83b748f940ef3b219a80e","Cargo.toml.orig":"cbfb99fc843dd61ad2025dcfc16bd435afd2b6d43c2c983867af08af415916f1","src/hardware.rs":"6a52c19b38be83fe47ccf8f6c6fe3b7d9597575b79366fbc678ea3586953dd52","src/lib.rs":"b2f55767a7f3fdacb1e898c5cb961c2dec8481823f94386ee67628960e91bf7d","src/make.rs":"e968e4dbd745d485fc9ad4c5a4c081d679eddce11f66e572f81f2dbe37ede3f0","src/models.rs":"11bb8edd2417dbbd8754b56d35488db5e3d4655e16e71eee85291fabea876e99"},"package":"67cca6e6bf4ac14562084ce7534521ffa7cd313fa39e2392f98ff98a047a4353"} \ No newline at end of file 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;