Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e825f3ee5 | ||
|
|
8e67c50fe0 | ||
|
|
da0d1582be |
@@ -62,6 +62,18 @@ async fn scan(cidrs: &[String]) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// Cap identification concurrency to match the GUI (see
|
||||||
|
// scan::SCAN_CONCURRENCY_LIMIT). asic-rs defaults to 1000, which over a real
|
||||||
|
// link starves the per-responder get_data -- Braiins miners drop most values
|
||||||
|
// (watts=0, no best-share) and some responders are missed entirely. 128 is the
|
||||||
|
// highest cap that stayed fully reliable on the live fleet. ALKANE_PROBE_CONCURRENCY
|
||||||
|
// overrides it for diagnostics.
|
||||||
|
let concurrency = std::env::var("ALKANE_PROBE_CONCURRENCY")
|
||||||
|
.ok()
|
||||||
|
.and_then(|c| c.parse::<usize>().ok())
|
||||||
|
.unwrap_or(128);
|
||||||
|
eprintln!("(scan concurrency = {concurrency})");
|
||||||
|
f = f.with_concurrent_limit(concurrency);
|
||||||
println!("ip\tmake\tfirmware\tfw_version\tmodel_id\tcontrol_board\twatts\tsupports_power_limit\tsupports_tuning\tbest_share\tsession_best_share");
|
println!("ip\tmake\tfirmware\tfw_version\tmodel_id\tcontrol_board\twatts\tsupports_power_limit\tsupports_tuning\tbest_share\tsession_best_share");
|
||||||
let mut stream = f.scan_stream_with_ip();
|
let mut stream = f.scan_stream_with_ip();
|
||||||
let mut found = 0usize;
|
let mut found = 0usize;
|
||||||
@@ -263,6 +275,9 @@ async fn msgs(ip_s: &str) {
|
|||||||
match f.scan_miner(ip).await {
|
match f.scan_miner(ip).await {
|
||||||
Ok(Some(m)) => {
|
Ok(Some(m)) => {
|
||||||
let d = m.get_data().await;
|
let d = m.get_data().await;
|
||||||
|
let th = |h: &Option<asic_rs::core::data::hashrate::HashRate>| {
|
||||||
|
h.clone().map(|x| x.as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
||||||
|
};
|
||||||
println!(
|
println!(
|
||||||
"{ip}: {} {} hashboards={:?} expected={:?}",
|
"{ip}: {} {} hashboards={:?} expected={:?}",
|
||||||
d.device_info.firmware,
|
d.device_info.firmware,
|
||||||
@@ -270,13 +285,28 @@ async fn msgs(ip_s: &str) {
|
|||||||
d.hashboards.len(),
|
d.hashboards.len(),
|
||||||
d.expected_hashboards,
|
d.expected_hashboards,
|
||||||
);
|
);
|
||||||
|
println!(
|
||||||
|
" TOTAL hashrate={:?} TH wattage={:?} W fluid/env_temp={:?} best_share={:?}",
|
||||||
|
th(&d.hashrate),
|
||||||
|
d.wattage.as_ref().map(|p| p.as_watts()),
|
||||||
|
d.fluid_temperature.as_ref().map(|t| t.as_celsius()),
|
||||||
|
d.best_share,
|
||||||
|
);
|
||||||
|
let fans: Vec<i64> = d
|
||||||
|
.fans
|
||||||
|
.iter()
|
||||||
|
.map(|f| f.rpm.as_ref().map(|r| r.as_rpm() as i64).unwrap_or(-1))
|
||||||
|
.collect();
|
||||||
|
println!(" fans(rpm)={fans:?} psu_fans={}", d.psu_fans.len());
|
||||||
for b in d.hashboards.iter() {
|
for b in d.hashboards.iter() {
|
||||||
println!(
|
println!(
|
||||||
" board position={} hashrate={:?} chips={:?}/{:?}",
|
" board pos={} hr={:?}TH chips={:?}/{:?} board_temp={:?} outlet_temp={:?}",
|
||||||
b.position,
|
b.position,
|
||||||
b.hashrate.clone().map(|h| h.as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value),
|
th(&b.hashrate),
|
||||||
b.working_chips,
|
b.working_chips,
|
||||||
b.expected_chips,
|
b.expected_chips,
|
||||||
|
b.board_temperature.as_ref().map(|t| t.as_celsius()),
|
||||||
|
b.outlet_chip_temperature.as_ref().map(|t| t.as_celsius()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if d.messages.is_empty() {
|
if d.messages.is_empty() {
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ impl Board {
|
|||||||
} else {
|
} else {
|
||||||
vec![]
|
vec![]
|
||||||
};
|
};
|
||||||
|
// Per-board hashrate for the R2 Health tooltip demo: split the total three
|
||||||
|
// ways with a little variety (index-aligned with the 3 boards).
|
||||||
|
let board_hashrates = if self.mining && self.hashrate > 0.0 {
|
||||||
|
vec![self.hashrate * 0.34, self.hashrate * 0.35, self.hashrate * 0.31]
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
};
|
||||||
// Air-cooled WhatsMiners report an ambient reading (asic-rs surfaces it in
|
// Air-cooled WhatsMiners report an ambient reading (asic-rs surfaces it in
|
||||||
// its fluid_temperature field); the scan routes it to env_temp for
|
// its fluid_temperature field); the scan routes it to env_temp for
|
||||||
// air-cooled models, so the demo mirrors that (round 11 #17).
|
// air-cooled models, so the demo mirrors that (round 11 #17).
|
||||||
@@ -109,6 +116,7 @@ impl Board {
|
|||||||
board_code,
|
board_code,
|
||||||
hashrate_ths: self.hashrate,
|
hashrate_ths: self.hashrate,
|
||||||
expected_ths: self.expected,
|
expected_ths: self.expected,
|
||||||
|
board_hashrates,
|
||||||
efficiency,
|
efficiency,
|
||||||
power_w: self.power,
|
power_w: self.power,
|
||||||
chip_temp_c: self.temp,
|
chip_temp_c: self.temp,
|
||||||
|
|||||||
+147
-74
@@ -306,10 +306,26 @@ pub enum FaultComponent {
|
|||||||
pub struct Fault {
|
pub struct Fault {
|
||||||
pub component: FaultComponent,
|
pub component: FaultComponent,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
|
/// Firmware's numeric error code for this message, or 0 when none. Shown in
|
||||||
|
/// the tooltip alongside the text (round 17 R2) so an operator can look the
|
||||||
|
/// code up.
|
||||||
|
pub code: u64,
|
||||||
/// True for Error severity; false for Warning. (Info is dropped upstream.)
|
/// True for Error severity; false for Warning. (Info is dropped upstream.)
|
||||||
pub is_error: bool,
|
pub is_error: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Fault {
|
||||||
|
/// The tooltip line for this fault: the message, with the firmware error code
|
||||||
|
/// appended when there is one (round 17 R2).
|
||||||
|
pub fn display_line(&self) -> String {
|
||||||
|
if self.code != 0 {
|
||||||
|
format!("{} (code {})", self.message, self.code)
|
||||||
|
} else {
|
||||||
|
self.message.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// One component's health for the Health icon column (round 13 #3). Rendered as a
|
/// One component's health for the Health icon column (round 13 #3). Rendered as a
|
||||||
/// coloured icon: grey = unreachable / not detected, red = detected but not
|
/// coloured icon: grey = unreachable / not detected, red = detected but not
|
||||||
/// functioning, yellow = functioning sub-optimally, green = fully functioning.
|
/// functioning, yellow = functioning sub-optimally, green = fully functioning.
|
||||||
@@ -394,9 +410,18 @@ pub struct MinerRow {
|
|||||||
// performance
|
// performance
|
||||||
pub hashrate_ths: f64,
|
pub hashrate_ths: f64,
|
||||||
pub expected_ths: f64,
|
pub expected_ths: f64,
|
||||||
|
/// Per-hashboard hashrate in TH/s, index-aligned with the hashboards (index 0
|
||||||
|
/// = board 1). Drives the per-board Health tooltip (round 17 R2). Empty when
|
||||||
|
/// the firmware reports no per-board hashrate.
|
||||||
|
pub board_hashrates: Vec<f64>,
|
||||||
#[allow(dead_code)] // retained for the "slow" band; not shown as its own column
|
#[allow(dead_code)] // retained for the "slow" band; not shown as its own column
|
||||||
pub efficiency: f64,
|
pub efficiency: f64,
|
||||||
pub power_w: f64,
|
pub power_w: f64,
|
||||||
|
/// PSU output voltage/current, when the firmware reports them (round 17 R2 /
|
||||||
|
/// roadmap G15). `None` until the PSU-info scan lands; the power tooltip then
|
||||||
|
/// shows "V / A" for a healthy PSU instead of a bare "PSU OK".
|
||||||
|
pub psu_out_voltage_v: Option<f64>,
|
||||||
|
pub psu_out_current_a: Option<f64>,
|
||||||
pub tuning_percent: Option<u8>,
|
pub tuning_percent: Option<u8>,
|
||||||
// thermal / cooling
|
// thermal / cooling
|
||||||
/// Average chip temperature (used for sorting/colour banding of the
|
/// Average chip temperature (used for sorting/colour banding of the
|
||||||
@@ -625,7 +650,7 @@ impl MinerRow {
|
|||||||
self.faults
|
self.faults
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|f| f.component == component)
|
.filter(|f| f.component == component)
|
||||||
.map(|f| f.message.clone())
|
.map(|f| f.display_line())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,7 +660,7 @@ impl MinerRow {
|
|||||||
self.faults
|
self.faults
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|f| matches!(f.component, FaultComponent::Other | FaultComponent::Control))
|
.filter(|f| matches!(f.component, FaultComponent::Other | FaultComponent::Control))
|
||||||
.map(|f| f.message.clone())
|
.map(|f| f.display_line())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,84 +671,86 @@ impl MinerRow {
|
|||||||
/// reports for that component.
|
/// reports for that component.
|
||||||
pub fn health_tooltips(&self, max_fans: usize, max_boards: usize) -> Vec<String> {
|
pub fn health_tooltips(&self, max_fans: usize, max_boards: usize) -> Vec<String> {
|
||||||
let mut tips: Vec<String> = Vec::with_capacity(2 + max_fans + max_boards);
|
let mut tips: Vec<String> = Vec::with_capacity(2 + max_fans + max_boards);
|
||||||
// Power -- the bolt icon carries any power-supply faults (round 16 #2).
|
// Power (bolt). A working PSU shows its output voltage + amperage when the
|
||||||
|
// firmware reports them (else a short OK); a faulted one shows the error
|
||||||
|
// and code instead (round 17 R2). asic-rs does not yet surface PSU output
|
||||||
|
// V/A (roadmap G15), so `psu_output` is None until that lands and the OK
|
||||||
|
// branch shows just the status.
|
||||||
let power_faults = self.fault_texts_for(FaultComponent::Power);
|
let power_faults = self.fault_texts_for(FaultComponent::Power);
|
||||||
let mut power = format!(
|
if !power_faults.is_empty() {
|
||||||
"Power supply: {}",
|
tips.push(power_faults.join("\n"));
|
||||||
match self.power_health() {
|
} else {
|
||||||
CompHealth::Ok => "OK (drawing power)",
|
tips.push(match (self.power_health(), self.psu_output_label()) {
|
||||||
CompHealth::Down if !power_faults.is_empty() => "fault reported",
|
(CompHealth::Ok, Some(va)) => va,
|
||||||
CompHealth::Down => "detected but not delivering",
|
(CompHealth::Ok, None) => "PSU OK".to_string(),
|
||||||
CompHealth::Degraded => "sub-optimal",
|
(CompHealth::Degraded, _) => "PSU sub-optimal".to_string(),
|
||||||
CompHealth::Unreachable => "unknown (no wattage/PSU-fan reported)",
|
(CompHealth::Down, _) => "PSU not delivering".to_string(),
|
||||||
}
|
(CompHealth::Unreachable, _) => "PSU unknown".to_string(),
|
||||||
);
|
});
|
||||||
for e in &power_faults {
|
|
||||||
power.push('\n');
|
|
||||||
power.push_str(e);
|
|
||||||
}
|
}
|
||||||
tips.push(power);
|
// Control board (brain) -- its own and the miner's un-attributed faults
|
||||||
// Control board -- also carries the miner's un-attributed / control faults.
|
// with codes; a short OK when clean.
|
||||||
let mut ctl = format!(
|
let ctl_faults = self.general_fault_texts();
|
||||||
"Control board: {}",
|
if !ctl_faults.is_empty() {
|
||||||
match self.control_health() {
|
tips.push(ctl_faults.join("\n"));
|
||||||
CompHealth::Ok => "OK (miner reachable)",
|
} else {
|
||||||
CompHealth::Degraded => "miner-level fault",
|
tips.push(match self.control_health() {
|
||||||
CompHealth::Down => "fault reported",
|
CompHealth::Ok => "Control board OK".to_string(),
|
||||||
CompHealth::Unreachable => "unknown",
|
_ => "Control board fault".to_string(),
|
||||||
}
|
});
|
||||||
);
|
|
||||||
for e in self.general_fault_texts() {
|
|
||||||
ctl.push('\n');
|
|
||||||
ctl.push_str(&e);
|
|
||||||
}
|
}
|
||||||
tips.push(ctl);
|
// Fans -- just the RPM, unless the fan has a fault (then the error+code).
|
||||||
// Fans.
|
|
||||||
let fans = self.fan_healths();
|
let fans = self.fan_healths();
|
||||||
for i in 0..max_fans {
|
for i in 0..max_fans {
|
||||||
let s = match fans.get(i) {
|
let fault = self.fault_texts_for(FaultComponent::Fan(i));
|
||||||
Some(CompHealth::Ok) => {
|
let t = if !fault.is_empty() {
|
||||||
let rpm = self.fan_rpms.get(i).map(|r| format!(" ({:.0} rpm)", r)).unwrap_or_default();
|
fault.join("\n")
|
||||||
format!("spinning{rpm}")
|
} else {
|
||||||
|
match fans.get(i) {
|
||||||
|
Some(_) => format!("{:.0} rpm", self.fan_rpms.get(i).copied().unwrap_or(0.0)),
|
||||||
|
None => String::new(), // padding slot for fleet alignment
|
||||||
}
|
}
|
||||||
Some(CompHealth::Degraded) => {
|
|
||||||
let rpm = self.fan_rpms.get(i).map(|r| format!(" ({:.0} rpm)", r)).unwrap_or_default();
|
|
||||||
format!("slow{rpm}")
|
|
||||||
}
|
|
||||||
Some(CompHealth::Down) => "stopped (0 rpm)".to_string(),
|
|
||||||
Some(CompHealth::Unreachable) => "expected but not detected".to_string(),
|
|
||||||
None => "not present".to_string(),
|
|
||||||
};
|
};
|
||||||
let mut t = format!("Fan {}: {s}", i + 1);
|
|
||||||
for e in self.fault_texts_for(FaultComponent::Fan(i)) {
|
|
||||||
t.push('\n');
|
|
||||||
t.push_str(&e);
|
|
||||||
}
|
|
||||||
tips.push(t);
|
tips.push(t);
|
||||||
}
|
}
|
||||||
// Hashboards. When the PSU has failed the boards can't be tested, so they
|
// Hashboards -- an operating board shows its number (counting DOWN, n-1..0,
|
||||||
// read "unpowered" (grey) rather than "faulted" (round 16 #2/#3).
|
// left to right) and hashrate; a faulted board shows its error+code; a
|
||||||
|
// board the failed PSU left untested shows "unpowered" (round 17 R2,
|
||||||
|
// round 16 #2/#3). No generic "Hashboard N: faulted" prose.
|
||||||
let boards = self.board_healths();
|
let boards = self.board_healths();
|
||||||
let psu_down = self.power_supply_faulted();
|
let psu_down = self.power_supply_faulted();
|
||||||
|
let n = self.hashboards.map(|v| v as usize).unwrap_or(boards.len());
|
||||||
for i in 0..max_boards {
|
for i in 0..max_boards {
|
||||||
let s = match boards.get(i) {
|
let fault = self.fault_texts_for(FaultComponent::Board(i));
|
||||||
Some(CompHealth::Ok) => "hashing".to_string(),
|
let t = if !fault.is_empty() {
|
||||||
Some(CompHealth::Degraded) => "hashing sub-optimally".to_string(),
|
fault.join("\n")
|
||||||
Some(CompHealth::Down) => "faulted".to_string(),
|
} else if matches!(boards.get(i), Some(CompHealth::Unreachable)) && psu_down {
|
||||||
Some(CompHealth::Unreachable) if psu_down => "unpowered (PSU fault)".to_string(),
|
"unpowered (PSU fault)".to_string()
|
||||||
Some(CompHealth::Unreachable) => "expected but not detected".to_string(),
|
} else if i < n {
|
||||||
None => "not present".to_string(),
|
let num = n - 1 - i; // count down, left to right
|
||||||
|
match self.board_hashrates.get(i).copied() {
|
||||||
|
Some(hr) if hr > 0.0 => format!("{num} \u{00b7} {hr:.1} TH/s"),
|
||||||
|
_ => num.to_string(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String::new() // padding slot for fleet alignment
|
||||||
};
|
};
|
||||||
let mut t = format!("Hashboard {}: {s}", i + 1);
|
|
||||||
for e in self.fault_texts_for(FaultComponent::Board(i)) {
|
|
||||||
t.push('\n');
|
|
||||||
t.push_str(&e);
|
|
||||||
}
|
|
||||||
tips.push(t);
|
tips.push(t);
|
||||||
}
|
}
|
||||||
tips
|
tips
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The PSU output "V / A" tooltip label when the firmware reports it, else
|
||||||
|
/// None. asic-rs does not yet expose PSU output voltage/current (roadmap G15),
|
||||||
|
/// so this is a forward-compatible hook that stays None for now (round 17 R2).
|
||||||
|
fn psu_output_label(&self) -> Option<String> {
|
||||||
|
match (self.psu_out_voltage_v, self.psu_out_current_a) {
|
||||||
|
(Some(v), Some(a)) if v > 0.0 => Some(format!("{v:.1} V \u{00b7} {a:.1} A")),
|
||||||
|
(Some(v), None) if v > 0.0 => Some(format!("{v:.1} V")),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Compact plain-text summary of component health (round 13 #3), used as the
|
/// Compact plain-text summary of component health (round 13 #3), used as the
|
||||||
/// Health column's filter/sort-fallback text and the base of its hover
|
/// Health column's filter/sort-fallback text and the base of its hover
|
||||||
/// tooltip. e.g. "power ok, fans 3/4, boards 3/3".
|
/// tooltip. e.g. "power ok, fans 3/4, boards 3/3".
|
||||||
@@ -1221,11 +1248,20 @@ impl Column {
|
|||||||
Column::Cpu => r.cpu.clone(),
|
Column::Cpu => r.cpu.clone(),
|
||||||
Column::BoardCode => r.board_code.clone(),
|
Column::BoardCode => r.board_code.clone(),
|
||||||
Column::Algorithm => r.algorithm.clone(),
|
Column::Algorithm => r.algorithm.clone(),
|
||||||
Column::Pic => match r.pic_present {
|
Column::Pic => {
|
||||||
Some(true) => "PIC".to_string(),
|
// A per-board PIC MCU is an Antminer hashboard property; it has no
|
||||||
Some(false) => "noPIC".to_string(),
|
// meaning for WhatsMiner or any other make, which show nothing
|
||||||
None => "?".to_string(),
|
// rather than a "?" that implies an unanswered Antminer question.
|
||||||
},
|
if !r.brand.eq_ignore_ascii_case("antminer") {
|
||||||
|
String::new()
|
||||||
|
} else {
|
||||||
|
match r.pic_present {
|
||||||
|
Some(true) => "PIC".to_string(),
|
||||||
|
Some(false) => "noPIC".to_string(),
|
||||||
|
None => "?".to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Column::Locked => match r.write_locked {
|
Column::Locked => match r.write_locked {
|
||||||
Some(true) => "locked".to_string(),
|
Some(true) => "locked".to_string(),
|
||||||
Some(false) => "unlocked".to_string(),
|
Some(false) => "unlocked".to_string(),
|
||||||
@@ -1645,6 +1681,7 @@ mod tests {
|
|||||||
let fault = |c: FaultComponent, m: &str| Fault {
|
let fault = |c: FaultComponent, m: &str| Fault {
|
||||||
component: c,
|
component: c,
|
||||||
message: m.to_string(),
|
message: m.to_string(),
|
||||||
|
code: 0,
|
||||||
is_error: true,
|
is_error: true,
|
||||||
};
|
};
|
||||||
let r = MinerRow {
|
let r = MinerRow {
|
||||||
@@ -1687,6 +1724,41 @@ mod tests {
|
|||||||
assert!(ptips[2 + 2].contains("unpowered")); // first board tooltip
|
assert!(ptips[2 + 2].contains("unpowered")); // first board tooltip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn health_tooltips_are_bare_data_round17_r2() {
|
||||||
|
// R2: operating boards show their number counting DOWN (n-1..0) left to
|
||||||
|
// right plus hashrate; fans show just RPM; a fault shows the message with
|
||||||
|
// its code; no "Hashboard N: faulted" prose.
|
||||||
|
let r = MinerRow {
|
||||||
|
is_mining: true,
|
||||||
|
hashboards: Some(3),
|
||||||
|
board_status: vec![BoardHealth::Ok, BoardHealth::Ok, BoardHealth::Fault],
|
||||||
|
board_hashrates: vec![33.5, 34.6, 0.0],
|
||||||
|
expected_fans: Some(2),
|
||||||
|
fan_rpms: vec![4700.0, 4650.0],
|
||||||
|
power_w: 3000.0,
|
||||||
|
faults: vec![Fault {
|
||||||
|
component: FaultComponent::Board(2),
|
||||||
|
message: "Slot 2 chip failure.".to_string(),
|
||||||
|
code: 540,
|
||||||
|
is_error: true,
|
||||||
|
}],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let tips = r.health_tooltips(2, 3);
|
||||||
|
// power OK (no V/A yet), control OK, 2 fans, 3 boards.
|
||||||
|
assert_eq!(tips[0], "PSU OK");
|
||||||
|
assert_eq!(tips[1], "Control board OK");
|
||||||
|
assert_eq!(tips[2], "4700 rpm");
|
||||||
|
assert_eq!(tips[3], "4650 rpm");
|
||||||
|
// Boards count DOWN left->right: leftmost = 2, then 1, then 0.
|
||||||
|
assert!(tips[4].starts_with("2") && tips[4].contains("33.5 TH/s"), "{}", tips[4]);
|
||||||
|
assert!(tips[5].starts_with("1") && tips[5].contains("34.6 TH/s"), "{}", tips[5]);
|
||||||
|
// The faulted board shows its error WITH the code, no "Hashboard" prose.
|
||||||
|
assert!(tips[6].contains("Slot 2 chip failure.") && tips[6].contains("540"), "{}", tips[6]);
|
||||||
|
assert!(!tips[6].to_lowercase().contains("hashboard"), "{}", tips[6]);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn kpis_match_expected_hardware_output() {
|
fn kpis_match_expected_hardware_output() {
|
||||||
// This does not hardcode fixture counts: it independently recomputes
|
// This does not hardcode fixture counts: it independently recomputes
|
||||||
@@ -1984,13 +2056,14 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pic_locked_error_columns_render() {
|
fn pic_locked_error_columns_render() {
|
||||||
// PIC (best-effort): known -> PIC/noPIC, unknown -> "?".
|
// PIC (best-effort): Antminer known -> PIC/noPIC, unknown Antminer -> "?".
|
||||||
let pic = MinerRow { pic_present: Some(true), ..Default::default() };
|
let am = |pic| MinerRow { brand: "Antminer".into(), pic_present: pic, ..Default::default() };
|
||||||
let nopic = MinerRow { pic_present: Some(false), ..Default::default() };
|
assert_eq!(Column::Pic.cell(&am(Some(true))), "PIC");
|
||||||
let pic_unknown = MinerRow { pic_present: None, ..Default::default() };
|
assert_eq!(Column::Pic.cell(&am(Some(false))), "noPIC");
|
||||||
assert_eq!(Column::Pic.cell(&pic), "PIC");
|
assert_eq!(Column::Pic.cell(&am(None)), "?");
|
||||||
assert_eq!(Column::Pic.cell(&nopic), "noPIC");
|
// Non-Antminer makes: PIC has no meaning -> blank, never "?".
|
||||||
assert_eq!(Column::Pic.cell(&pic_unknown), "?");
|
let wm = MinerRow { brand: "WhatsMiner".into(), pic_present: None, ..Default::default() };
|
||||||
|
assert_eq!(Column::Pic.cell(&wm), "");
|
||||||
|
|
||||||
// Access column.
|
// Access column.
|
||||||
let locked = MinerRow { write_locked: Some(true), ..Default::default() };
|
let locked = MinerRow { write_locked: Some(true), ..Default::default() };
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ pub const AUTO_FILE: &str = "auto-rescan-secs.txt";
|
|||||||
pub const SCAN_TIMEOUT_FILE: &str = "scan-timeout-secs.txt";
|
pub const SCAN_TIMEOUT_FILE: &str = "scan-timeout-secs.txt";
|
||||||
/// Default per-miner scan timeout (matches asic-rs' identification timeout).
|
/// Default per-miner scan timeout (matches asic-rs' identification timeout).
|
||||||
pub const DEFAULT_SCAN_TIMEOUT_SECS: u64 = 10;
|
pub const DEFAULT_SCAN_TIMEOUT_SECS: u64 = 10;
|
||||||
|
/// Maximum in-flight address probes during a scan. asic-rs would otherwise use
|
||||||
|
/// 1000 for any range up to /22, saturating a real link and starving the
|
||||||
|
/// per-responder get_data (Braiins miners drop most values under that burst).
|
||||||
|
/// 128 was the highest cap that stayed fully reliable on the live fleet.
|
||||||
|
pub const SCAN_CONCURRENCY_LIMIT: usize = 128;
|
||||||
pub const DEFAULT_RANGE: &str = "10.255.1.0/24";
|
pub const DEFAULT_RANGE: &str = "10.255.1.0/24";
|
||||||
/// Default seconds between automatic rescans.
|
/// Default seconds between automatic rescans.
|
||||||
pub const DEFAULT_AUTO_SECS: u64 = 300;
|
pub const DEFAULT_AUTO_SECS: u64 = 300;
|
||||||
@@ -377,7 +382,18 @@ pub fn start_scan(lines: Vec<String>, timeout_secs: u64) -> ScanHandle {
|
|||||||
};
|
};
|
||||||
rt.block_on(async move {
|
rt.block_on(async move {
|
||||||
let mut factory = crate::credentials::configured_factory()
|
let mut factory = crate::credentials::configured_factory()
|
||||||
.with_identification_timeout_secs(timeout_secs.max(1));
|
.with_identification_timeout_secs(timeout_secs.max(1))
|
||||||
|
// Cap identification concurrency. asic-rs defaults to 1000 for any
|
||||||
|
// range up to /22, so a /24 fires all 254 probes at once. Over a
|
||||||
|
// real link (VPN, or a subnet full of dead IPs whose TCP connects
|
||||||
|
// sit open for the whole identification timeout) that burst starves
|
||||||
|
// the per-responder get_data -- a Braiins miner fans out ~12
|
||||||
|
// authenticated REST calls and drops most of its values (watts=0,
|
||||||
|
// no best-share/temps), and some responders are missed entirely.
|
||||||
|
// 128 is the highest cap that stayed fully reliable on the live
|
||||||
|
// fleet (192 already dropped responders); a /24 still finishes in
|
||||||
|
// ~35s. Larger ranges just take proportionally longer, still correct.
|
||||||
|
.with_concurrent_limit(SCAN_CONCURRENCY_LIMIT);
|
||||||
for (ip, prefix) in &cidrs {
|
for (ip, prefix) in &cidrs {
|
||||||
factory = match factory.with_subnet(&format!("{ip}/{prefix}")) {
|
factory = match factory.with_subnet(&format!("{ip}/{prefix}")) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
@@ -489,6 +505,7 @@ fn messages_to_faults(
|
|||||||
Some(Fault {
|
Some(Fault {
|
||||||
component,
|
component,
|
||||||
message: text.to_string(),
|
message: text.to_string(),
|
||||||
|
code: m.code,
|
||||||
is_error,
|
is_error,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -557,6 +574,20 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
|||||||
})
|
})
|
||||||
.filter(|&t| t > 0.0)
|
.filter(|&t| t > 0.0)
|
||||||
.collect();
|
.collect();
|
||||||
|
// Per-board hashrate (TH/s), index-aligned with the hashboards, for the
|
||||||
|
// per-board Health tooltip (round 17 R2). Unlike board_temps this is NOT
|
||||||
|
// filtered/compacted -- index i must stay board i so the tooltip numbering
|
||||||
|
// lines up.
|
||||||
|
let board_hashrates: Vec<f64> = data
|
||||||
|
.hashboards
|
||||||
|
.iter()
|
||||||
|
.map(|b| {
|
||||||
|
b.hashrate
|
||||||
|
.as_ref()
|
||||||
|
.map(|h| h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
||||||
|
.unwrap_or(0.0)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
let fan_rpms: Vec<f64> = data
|
let fan_rpms: Vec<f64> = data
|
||||||
.fans
|
.fans
|
||||||
.iter()
|
.iter()
|
||||||
@@ -735,8 +766,13 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
|||||||
board_code,
|
board_code,
|
||||||
hashrate_ths,
|
hashrate_ths,
|
||||||
expected_ths,
|
expected_ths,
|
||||||
|
board_hashrates,
|
||||||
efficiency: data.efficiency.unwrap_or(0.0),
|
efficiency: data.efficiency.unwrap_or(0.0),
|
||||||
power_w,
|
power_w,
|
||||||
|
// PSU output V/A is not yet exposed by asic-rs (roadmap G15); the tooltip
|
||||||
|
// falls back to a status string until it is.
|
||||||
|
psu_out_voltage_v: None,
|
||||||
|
psu_out_current_a: None,
|
||||||
tuning_percent: data.tuning_percent,
|
tuning_percent: data.tuning_percent,
|
||||||
chip_temp_c,
|
chip_temp_c,
|
||||||
board_temps,
|
board_temps,
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Reclaim disk from the local cargo build directory.
|
||||||
|
#
|
||||||
|
# The app and the miner_probe CLI ship as release builds, and the unit tests run
|
||||||
|
# under --release too (see the build notes), so the dev/debug profile tree, any
|
||||||
|
# cross-compile target trees, and the coverage tree are all disposable: they only
|
||||||
|
# ever reappear if something explicitly rebuilds them, and left alone they grow
|
||||||
|
# without bound (a stray `cargo check`/`cargo test` can push the debug tree past
|
||||||
|
# 30 GiB on its own). The release tree is kept warm so the next iteration is still
|
||||||
|
# incremental; only its throwaway bits are pruned.
|
||||||
|
#
|
||||||
|
# Run it right after a release push -- the pushed commit is what CI builds and
|
||||||
|
# ships, so the local intermediates are spare from that point. Safe to run any
|
||||||
|
# time; it never deletes the release build itself.
|
||||||
|
#
|
||||||
|
# Honours CARGO_TARGET_DIR (the build sets it to ~/.cache/alkane-tk-target).
|
||||||
|
set -uo pipefail
|
||||||
|
|
||||||
|
TARGET="${CARGO_TARGET_DIR:-$HOME/.cache/alkane-tk-target}"
|
||||||
|
if [ ! -d "$TARGET" ]; then
|
||||||
|
echo "clean-old-builds: no target dir at $TARGET (nothing to do)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
human() { du -sh "$1" 2>/dev/null | cut -f1; }
|
||||||
|
before=$(human "$TARGET")
|
||||||
|
|
||||||
|
# Disposable profile/aux trees -- regenerated on demand, never shipped.
|
||||||
|
rm -rf "$TARGET"/debug "$TARGET"/llvm-cov-target "$TARGET"/doc 2>/dev/null
|
||||||
|
|
||||||
|
# Cross-compile target trees (e.g. armv7-unknown-linux-musleabihf). Rust target
|
||||||
|
# triples all carry "-unknown-"; the host release/debug trees do not, so this
|
||||||
|
# never touches the warm release build.
|
||||||
|
for d in "$TARGET"/*-unknown-*; do
|
||||||
|
[ -d "$d" ] && rm -rf "$d"
|
||||||
|
done
|
||||||
|
|
||||||
|
# The incremental caches are rebuild accelerators, not build output -- dropping
|
||||||
|
# them costs one slightly-slower rebuild and can free a few GiB.
|
||||||
|
rm -rf "$TARGET"/release/incremental 2>/dev/null
|
||||||
|
|
||||||
|
# If cargo-sweep is installed, additionally drop release artifacts not touched in
|
||||||
|
# the last few days (old dependency versions left by past rebuilds), keeping the
|
||||||
|
# current build. Optional: install with `cargo install cargo-sweep`.
|
||||||
|
if command -v cargo-sweep >/dev/null 2>&1; then
|
||||||
|
cargo sweep --time 3 "$TARGET" >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
after=$(human "$TARGET")
|
||||||
|
echo "clean-old-builds: $TARGET $before -> $after"
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
Subject: [PATCH 0016] braiins v26_04: single-flight auth + defensive get_data timeout
|
||||||
|
|
||||||
|
Round 17 R4 support. Braiins get_data fans out to ~12 authenticated REST calls
|
||||||
|
concurrently. Two hardening changes so a Braiins miner survives a busy scan:
|
||||||
|
|
||||||
|
- ensure_authenticated single-flights the login. Previously all ~12 concurrent
|
||||||
|
commands could see no token and each POST /auth/login -- a thundering herd that
|
||||||
|
doubled the connection load. Now the write lock is held across the login with a
|
||||||
|
double-check, so exactly one call authenticates and the rest reuse the token.
|
||||||
|
- The per-call timeout goes 5s -> 15s as defensive headroom (a healthy miner still
|
||||||
|
answers well under a second) so a call queued behind a scan burst completes
|
||||||
|
instead of dropping miner/stats.
|
||||||
|
|
||||||
|
Neither is the primary fix for the fleet-scan value dropout -- that is the
|
||||||
|
app-side scan concurrency cap (scan::SCAN_CONCURRENCY_LIMIT = 128), which keeps
|
||||||
|
the identification burst from starving these calls. These are the belt to that
|
||||||
|
suspenders. Verified live: a 10.4.1.0/24 scan now populates both Braiins corpus
|
||||||
|
miners (.27, .83) fully (watts, best-share, fw/control-board) and misses no
|
||||||
|
responders.
|
||||||
|
diff --git a/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs b/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
|
||||||
|
index 3e06b682..ae433d98 100644
|
||||||
|
--- a/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
|
||||||
|
+++ b/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
|
||||||
|
@@ -87,7 +87,13 @@ impl BraiinsWebAPI {
|
||||||
|
client: OnceCell::new(),
|
||||||
|
ip,
|
||||||
|
port: 80,
|
||||||
|
- timeout: Duration::from_secs(5),
|
||||||
|
+ // Braiins get_data fans out to ~12 authenticated REST calls that run
|
||||||
|
+ // concurrently. A healthy miner answers well under a second; the extra
|
||||||
|
+ // headroom over the old 5 s is defensive so a call that queues behind a
|
||||||
|
+ // scan burst still completes instead of dropping miner/stats
|
||||||
|
+ // (hashrate/watts/best-share). The real fix for the fleet-scan dropout
|
||||||
|
+ // is the app-side scan concurrency cap (see scan::SCAN_CONCURRENCY_LIMIT).
|
||||||
|
+ timeout: Duration::from_secs(15),
|
||||||
|
bearer_token: RwLock::new(None),
|
||||||
|
auth,
|
||||||
|
}
|
||||||
|
@@ -122,13 +128,22 @@ impl BraiinsWebAPI {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Single-flight the login: get_data fires ~12 commands concurrently, and
|
||||||
|
+ // without this they would ALL see no token and each POST /auth/login (a
|
||||||
|
+ // thundering herd that doubles the connection load and races under a
|
||||||
|
+ // high-concurrency fleet scan, dropping most values). Hold the write lock
|
||||||
|
+ // across the login so exactly one call authenticates and the rest reuse it.
|
||||||
|
+ let mut guard = self.bearer_token.write().await;
|
||||||
|
+ if guard.is_some() {
|
||||||
|
+ return Ok(());
|
||||||
|
+ }
|
||||||
|
let token = match &self.auth {
|
||||||
|
MinerAuth::TokenAuth(token) => token.expose_secret().to_string(),
|
||||||
|
MinerAuth::UserAndPass(creds) => {
|
||||||
|
self.authenticate(creds.password.expose_secret()).await?
|
||||||
|
}
|
||||||
|
};
|
||||||
|
- *self.bearer_token.write().await = Some(token);
|
||||||
|
+ *guard = Some(token);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -335,13 +335,26 @@ int DrawShape(wxDC* dc, wxUniChar shape, wxCoord x, const wxRect& cell,
|
|||||||
if (h < 8) h = 8;
|
if (h < 8) h = 8;
|
||||||
int w = (sv->vbh > 0) ? (int)((double)h * sv->vbw / sv->vbh + 0.5) : h;
|
int w = (sv->vbh > 0) ? (int)((double)h * sv->vbw / sv->vbh + 0.5) : h;
|
||||||
if (w < 1) w = 1;
|
if (w < 1) w = 1;
|
||||||
const wxBitmap& bmp = ShapeBitmap(shape, *sv, colour, w, h);
|
// The Font Awesome fan glyph fills its square box more than the other health
|
||||||
|
// icons (brain/chip/bolt), so at the shared size it reads as oversized. Draw
|
||||||
|
// it a bit smaller, centred in its full-size slot, so the slot advance and the
|
||||||
|
// per-icon tooltip hit-test (both keyed to the full width) are unchanged
|
||||||
|
// (round 17 R1).
|
||||||
|
int dw = w, dh = h;
|
||||||
|
if (shape == SHAPE_FAN) {
|
||||||
|
dh = (int)(h * 0.80 + 0.5);
|
||||||
|
if (dh < 8) dh = 8;
|
||||||
|
dw = (sv->vbh > 0) ? (int)((double)dh * sv->vbw / sv->vbh + 0.5) : dh;
|
||||||
|
if (dw < 1) dw = 1;
|
||||||
|
}
|
||||||
|
const wxBitmap& bmp = ShapeBitmap(shape, *sv, colour, dw, dh);
|
||||||
if (bmp.IsOk()) {
|
if (bmp.IsOk()) {
|
||||||
if (health) {
|
if (health) {
|
||||||
// Left-align and advance by less than the icon width so adjacent health
|
// Left-align in the full slot (a shrunk fan is centred within it) and
|
||||||
// icons sit close together (the Font Awesome glyphs carry inner margin,
|
// advance by less than the full icon width so adjacent health icons sit
|
||||||
// so a small bounding-box overlap does not visually collide).
|
// close together (the Font Awesome glyphs carry inner margin, so a small
|
||||||
dc->DrawBitmap(bmp, x, cy - h / 2, true);
|
// bounding-box overlap does not visually collide).
|
||||||
|
dc->DrawBitmap(bmp, x + (w - dw) / 2, cy - dh / 2, true);
|
||||||
int adv = w - 3;
|
int adv = w - 3;
|
||||||
return adv < 1 ? 1 : adv;
|
return adv < 1 ? 1 : adv;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+17
-2
@@ -87,7 +87,13 @@ impl BraiinsWebAPI {
|
|||||||
client: OnceCell::new(),
|
client: OnceCell::new(),
|
||||||
ip,
|
ip,
|
||||||
port: 80,
|
port: 80,
|
||||||
timeout: Duration::from_secs(5),
|
// Braiins get_data fans out to ~12 authenticated REST calls that run
|
||||||
|
// concurrently. A healthy miner answers well under a second; the extra
|
||||||
|
// headroom over the old 5 s is defensive so a call that queues behind a
|
||||||
|
// scan burst still completes instead of dropping miner/stats
|
||||||
|
// (hashrate/watts/best-share). The real fix for the fleet-scan dropout
|
||||||
|
// is the app-side scan concurrency cap (see scan::SCAN_CONCURRENCY_LIMIT).
|
||||||
|
timeout: Duration::from_secs(15),
|
||||||
bearer_token: RwLock::new(None),
|
bearer_token: RwLock::new(None),
|
||||||
auth,
|
auth,
|
||||||
}
|
}
|
||||||
@@ -122,13 +128,22 @@ impl BraiinsWebAPI {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Single-flight the login: get_data fires ~12 commands concurrently, and
|
||||||
|
// without this they would ALL see no token and each POST /auth/login (a
|
||||||
|
// thundering herd that doubles the connection load and races under a
|
||||||
|
// high-concurrency fleet scan, dropping most values). Hold the write lock
|
||||||
|
// across the login so exactly one call authenticates and the rest reuse it.
|
||||||
|
let mut guard = self.bearer_token.write().await;
|
||||||
|
if guard.is_some() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
let token = match &self.auth {
|
let token = match &self.auth {
|
||||||
MinerAuth::TokenAuth(token) => token.expose_secret().to_string(),
|
MinerAuth::TokenAuth(token) => token.expose_secret().to_string(),
|
||||||
MinerAuth::UserAndPass(creds) => {
|
MinerAuth::UserAndPass(creds) => {
|
||||||
self.authenticate(creds.password.expose_secret()).await?
|
self.authenticate(creds.password.expose_secret()).await?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*self.bearer_token.write().await = Some(token);
|
*guard = Some(token);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user