Subject: [PATCH 0008] antminer: resolve Z15J / unknown-model algorithm Round-13 #4/#5. A Z15J reports its model as "ANTMINER Z15J", which asic-rs' alias table did not recognise, so it deserialised to AntMinerModel::Unknown and its hash algorithm resolved to HashAlgorithm::Unknown. That left the miner's Sol/s hashrate un-bucketed as "unknown hashrate" in the GUI, even though the round-10 unit reinterpretation already read the value correctly. (The older ANTMINER Z15 matched the table and reported Equihash; only the J revision was affected.) Two layers of fix: - models.rs / hardware.rs: add a first-class Z15J model (Equihash, same 3-chip x 3-board / 2-fan chassis profile as the Z15) so it parses to a named model and carries the right algorithm, and shows a clean "Z15J" model name. - v2020 backend: when the alias table still can't place a model, infer the algorithm from the Antminer family letter for the lines that are single-algorithm end to end (Z -> Equihash, L -> Scrypt, S/T -> SHA-256), so other not-yet-tabled models are bucketed sensibly instead of Unknown. Ambiguous families (K spans Kadena/KHeavyHash/Eaglesong; DR is Blake256 while D is X11) are deliberately left Unknown rather than guessed wrong. Live-verified on 10.5.1.{50,72,196,205}: Z15 and Z15J now both report algo=Equihash with their real Sol/s rates (e.g. 305k, 132k; 0 on idle units). The antminer crate tests pass, plus two new unit tests (z15j_parses_as_equihash, unknown_models_infer_algo_from_family_letter). diff --git a/vendor/asic-rs-makes-antminer/src/models.rs b/vendor/asic-rs-makes-antminer/src/models.rs --- a/vendor/asic-rs-makes-antminer/src/models.rs +++ b/vendor/asic-rs-makes-antminer/src/models.rs @@ -78,6 +78,9 @@ #[serde(alias = "ANTMINER Z15 PRO")] #[algorithm(HashAlgorithm::Equihash)] Z15Pro, + #[serde(alias = "ANTMINER Z15J")] + #[algorithm(HashAlgorithm::Equihash)] + Z15J, #[serde(alias = "ANTMINER S17")] #[algorithm(HashAlgorithm::SHA256)] S17, @@ -281,12 +284,22 @@ (AntMinerModel::E9Pro, HashAlgorithm::EtHash), (AntMinerModel::Z15, HashAlgorithm::Equihash), (AntMinerModel::Z15Pro, HashAlgorithm::Equihash), + (AntMinerModel::Z15J, HashAlgorithm::Equihash), ] { assert_eq!(model.hash_algorithm(), expected, "{model}"); } } #[test] + fn z15j_parses_as_equihash() { + // The Z15J reports "ANTMINER Z15J"; before it had an alias it fell back to + // Unknown, which left its Sol/s hashrate un-bucketed (round 13 #5). + let model = AntMinerModel::from_str("ANTMINER Z15J").unwrap(); + assert_eq!(model, AntMinerModel::Z15J); + assert_eq!(model.hash_algorithm(), HashAlgorithm::Equihash); + } + + #[test] fn unknown_model_uses_unknown_algorithm() { let model = AntMinerModel::from_str("ANTMINER S99").unwrap(); diff --git a/vendor/asic-rs-makes-antminer/src/hardware.rs b/vendor/asic-rs-makes-antminer/src/hardware.rs --- a/vendor/asic-rs-makes-antminer/src/hardware.rs +++ b/vendor/asic-rs-makes-antminer/src/hardware.rs @@ -97,6 +97,10 @@ AntMinerModel::Z15Pro => Self { fans: Some(2), boards: Some(vec![Some(6), Some(6), Some(6)]), + }, + AntMinerModel::Z15J => Self { + fans: Some(2), + boards: Some(vec![Some(3), Some(3), Some(3)]), }, AntMinerModel::S17 => Self { fans: Some(4), diff --git a/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs b/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs --- a/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs +++ b/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs @@ -201,10 +201,41 @@ 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, + } +} + impl AntMinerV2020 { pub fn new(ip: IpAddr, model: impl MinerModel) -> Self { let auth = Self::default_auth(); - let algo = model.hash_algorithm(); + // asic-rs maps a model string to its algorithm through a fixed alias + // table; a model that is not in the table (a Z15J, a not-yet-added + // S-series, ...) resolves to HashAlgorithm::Unknown, which then leaves the + // miner's hashrate un-bucketed ("unknown hashrate", round 13 #5). When the + // table can't place the model, infer the algorithm from its Antminer + // family letter for the lines that are single-algorithm end to end. + let algo = match model.hash_algorithm() { + HashAlgorithm::Unknown => infer_antminer_algo(&model.to_string()), + known => known, + }; AntMinerV2020 { ip, rpc: AntMinerRPCAPI::new(ip), @@ -1431,6 +1462,21 @@ }; #[test] + fn unknown_models_infer_algo_from_family_letter() { + // Round 13 #5: a model outside asic-rs' alias table must still resolve a + // sensible algorithm from its Antminer family letter instead of Unknown. + assert_eq!(infer_antminer_algo("ANTMINER Z15J"), HashAlgorithm::Equihash); + assert_eq!(infer_antminer_algo("Z9"), HashAlgorithm::Equihash); + assert_eq!(infer_antminer_algo("ANTMINER L15"), HashAlgorithm::Scrypt); + assert_eq!(infer_antminer_algo("ANTMINER S23"), HashAlgorithm::SHA256); + assert_eq!(infer_antminer_algo("ANTMINER T23"), HashAlgorithm::SHA256); + // Ambiguous / unrelated families stay Unknown (K-series spans three + // algorithms; a bare unknown string has no family). + assert_eq!(infer_antminer_algo("ANTMINER KS7"), HashAlgorithm::Unknown); + assert_eq!(infer_antminer_algo("WHATSMINER M30"), HashAlgorithm::Unknown); + } + + #[test] fn set_miner_conf_payload_matches_cgi_contract_for_pause_resume() { let pre = json!({ "pools": [