Round 19 #10 telemetry extension, tier 2b. Adds the cumulative share statistics from item #10 end to end: difficulty-weighted accepted/rejected work, raw stale share count, and blocks found. Core (asic-rs-core): - New ShareSummary sub-struct (data/share.rs) with a parse_cgminer_share_summary helper reading a cgminer/btminer SUMMARY[0] object. - New DataField::ShareSummary; MinerData gains share_summary. - Rides the existing GetBestShare trait via a defaulted parse_share_summary method (no new supertrait bound, no per-backend empty impl); parse_data wires it in. Backends (read the already-fetched SUMMARY, so no extra round-trips; these are miner-level aggregates -> top-level MinerData fields, not per-pool PoolData): - Antminer v2020 + v2023_07, LuxOS, WhatsMiner V1 + V2 override parse_share_summary. - Braiins (no cumulative difficulty), ePIC (current difficulty only), WhatsMiner V3 and VNish expose none and inherit None -- fixtures confirm. GUI: four new columns (Diff acc / Diff rej / Stale / Blocks), right-aligned, in the Pools category, auto-hidden when empty. MinerRow gains the four fields; to_row reads them from share_summary. ALL_COLUMNS 63 -> 67. Fixture tests: whatsminer v1 and antminer v2020 assert the parsed values. Patch 0026. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6
400 lines
17 KiB
Diff
400 lines
17 KiB
Diff
Subject: [PATCH 0026] telemetry: cumulative share stats (difficulty acc/rej, stale, blocks)
|
|
|
|
Round 19 #10 telemetry extension, tier 2b. Exposes the cumulative share
|
|
statistics the GUI wanted: difficulty-weighted accepted/rejected work, raw stale
|
|
share count, and blocks found.
|
|
|
|
- New ShareSummary sub-struct (data/share.rs) + parse_cgminer_share_summary helper
|
|
that reads a cgminer/btminer SUMMARY[0] object ("Difficulty Accepted",
|
|
"Difficulty Rejected", "Stale", "Found Blocks").
|
|
- New DataField::ShareSummary; MinerData gains share_summary.
|
|
- Rides the EXISTING GetBestShare trait via a defaulted parse_share_summary method
|
|
(default None), so no new supertrait bound and no empty impl per backend; only
|
|
the cgminer-family backends override it. parse_data wires it in.
|
|
- Backends (each reads the SUMMARY the collector already fetches, so no extra
|
|
round-trips): Antminer v2020 + v2023_07, LuxOS, WhatsMiner V1 + V2. These are
|
|
miner-level aggregates, not per-pool, so they are top-level MinerData fields (the
|
|
per-pool accepted/rejected share counts stay on PoolData). Braiins does not
|
|
expose cumulative difficulty; ePIC reports only the current difficulty target;
|
|
WhatsMiner V3 and VNish expose none -> all inherit None.
|
|
|
|
Fixture tests for whatsminer v1 and antminer v2020 assert the parsed values.
|
|
|
|
diff --git a/vendor/asic-rs-core/src/data/collector.rs b/vendor/asic-rs-core/src/data/collector.rs
|
|
index 5899c039..942b39f6 100644
|
|
--- a/vendor/asic-rs-core/src/data/collector.rs
|
|
+++ b/vendor/asic-rs-core/src/data/collector.rs
|
|
@@ -111,6 +111,9 @@ pub enum DataField {
|
|
/// Difficulty of the best share found over the miner's lifetime, when reported.
|
|
#[cfg_attr(feature = "python", pydantic(value = "BestShare"))]
|
|
BestShare,
|
|
+ /// Cumulative share statistics (difficulty accepted/rejected, stale, blocks).
|
|
+ #[cfg_attr(feature = "python", pydantic(value = "ShareSummary"))]
|
|
+ ShareSummary,
|
|
/// Difficulty of the best share found since the last boot or hashing start, when reported.
|
|
#[cfg_attr(feature = "python", pydantic(value = "SessionBestShare"))]
|
|
SessionBestShare,
|
|
diff --git a/vendor/asic-rs-core/src/data/miner.rs b/vendor/asic-rs-core/src/data/miner.rs
|
|
index 38c7f3be..660850f4 100644
|
|
--- a/vendor/asic-rs-core/src/data/miner.rs
|
|
+++ b/vendor/asic-rs-core/src/data/miner.rs
|
|
@@ -17,6 +17,7 @@ use super::{
|
|
operating_state::OperatingState,
|
|
pool::PoolGroupData,
|
|
psu::PsuInfo,
|
|
+ share::ShareSummary,
|
|
};
|
|
use crate::data::{
|
|
deserialize::deserialize_macaddr,
|
|
@@ -237,6 +238,9 @@ pub struct MinerData {
|
|
/// Difficulty of the best share found since the last boot or hashing start,
|
|
/// when the firmware distinguishes session from all-time.
|
|
pub session_best_share: Option<f64>,
|
|
+ /// Cumulative share statistics (difficulty accepted/rejected, stale, blocks),
|
|
+ /// when reported. Miner-level aggregate from the cgminer/btminer summary.
|
|
+ pub share_summary: Option<ShareSummary>,
|
|
}
|
|
|
|
#[cfg(feature = "python")]
|
|
diff --git a/vendor/asic-rs-core/src/data/share.rs b/vendor/asic-rs-core/src/data/share.rs
|
|
index 3cc50651..73b0a0a8 100644
|
|
--- a/vendor/asic-rs-core/src/data/share.rs
|
|
+++ b/vendor/asic-rs-core/src/data/share.rs
|
|
@@ -3,7 +3,61 @@
|
|
//! Firmwares report best-share difficulty as a JSON number, a decimal string,
|
|
//! or an AxeOS-style suffix string (`"483k"`, `"1.2M"`).
|
|
|
|
+#[cfg(feature = "python")]
|
|
+use pyo3::pyclass;
|
|
+use serde::{Deserialize, Serialize};
|
|
use serde_json::Value;
|
|
+use ts_rs::TS;
|
|
+
|
|
+/// Cumulative share statistics reported by a miner (round 19 #10, T2).
|
|
+///
|
|
+/// These are miner-level aggregates from the cgminer/btminer summary. Difficulty
|
|
+/// values are difficulty-weighted sums (not raw share counts, which live on
|
|
+/// [`PoolData`][`super::pool::PoolData`]). Every field is optional; a backend
|
|
+/// fills in only what its firmware exposes.
|
|
+#[cfg_attr(feature = "python", pyclass(from_py_object, module = "asic_rs"))]
|
|
+#[cfg_attr(feature = "python", asic_rs_pydantic::py_pydantic_model(getters))]
|
|
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, TS)]
|
|
+pub struct ShareSummary {
|
|
+ /// Difficulty-weighted accepted work, when reported.
|
|
+ pub difficulty_accepted: Option<f64>,
|
|
+ /// Difficulty-weighted rejected work, when reported.
|
|
+ pub difficulty_rejected: Option<f64>,
|
|
+ /// Raw stale share count, when reported.
|
|
+ pub stale_shares: Option<u64>,
|
|
+ /// Number of blocks found by this miner, when reported.
|
|
+ pub found_blocks: Option<u64>,
|
|
+}
|
|
+
|
|
+impl ShareSummary {
|
|
+ /// True when no field is populated.
|
|
+ pub fn is_empty(&self) -> bool {
|
|
+ self.difficulty_accepted.is_none()
|
|
+ && self.difficulty_rejected.is_none()
|
|
+ && self.stale_shares.is_none()
|
|
+ && self.found_blocks.is_none()
|
|
+ }
|
|
+}
|
|
+
|
|
+/// Parse a [`ShareSummary`] from a cgminer/btminer `SUMMARY[0]` object (the value
|
|
+/// extracted at `/SUMMARY/0`). Reads "Difficulty Accepted", "Difficulty Rejected",
|
|
+/// "Stale", and "Found Blocks". Returns `None` when none are present.
|
|
+pub fn parse_cgminer_share_summary(summary: &Value) -> Option<ShareSummary> {
|
|
+ let f = |k: &str| {
|
|
+ summary
|
|
+ .get(k)
|
|
+ .and_then(|v| v.as_f64())
|
|
+ .filter(|v| v.is_finite() && *v >= 0.0)
|
|
+ };
|
|
+ let u = |k: &str| summary.get(k).and_then(|v| v.as_u64());
|
|
+ let s = ShareSummary {
|
|
+ difficulty_accepted: f("Difficulty Accepted"),
|
|
+ difficulty_rejected: f("Difficulty Rejected"),
|
|
+ stale_shares: u("Stale"),
|
|
+ found_blocks: u("Found Blocks"),
|
|
+ };
|
|
+ (!s.is_empty()).then_some(s)
|
|
+}
|
|
|
|
/// Parse a share difficulty from a JSON value.
|
|
///
|
|
diff --git a/vendor/asic-rs-core/src/traits/miner.rs b/vendor/asic-rs-core/src/traits/miner.rs
|
|
index cfabb624..76344342 100644
|
|
--- a/vendor/asic-rs-core/src/traits/miner.rs
|
|
+++ b/vendor/asic-rs-core/src/traits/miner.rs
|
|
@@ -34,6 +34,7 @@ use crate::{
|
|
operating_state::OperatingState,
|
|
pool::PoolGroupData,
|
|
psu::PsuInfo,
|
|
+ share::ShareSummary,
|
|
},
|
|
traits::firmware::MinerFirmware,
|
|
traits::model::MinerModel,
|
|
@@ -291,6 +292,7 @@ impl<
|
|
let pools = self.parse_pools(&data);
|
|
let best_share = self.parse_best_share(&data);
|
|
let session_best_share = self.parse_session_best_share(&data);
|
|
+ let share_summary = self.parse_share_summary(&data);
|
|
let device_info = self.get_device_info();
|
|
|
|
// computed fields
|
|
@@ -388,6 +390,7 @@ impl<
|
|
pools,
|
|
best_share,
|
|
session_best_share,
|
|
+ share_summary,
|
|
}
|
|
}
|
|
}
|
|
@@ -914,6 +917,18 @@ pub trait GetBestShare: CollectData {
|
|
fn parse_best_share(&self, data: &HashMap<DataField, Value>) -> Option<f64> {
|
|
None
|
|
}
|
|
+ #[tracing::instrument(level = "debug")]
|
|
+ async fn get_share_summary(&self) -> Option<ShareSummary> {
|
|
+ let mut collector = self.get_collector();
|
|
+ let data = collector.collect(&[DataField::ShareSummary]).await;
|
|
+ self.parse_share_summary(&data)
|
|
+ }
|
|
+ /// Cumulative share statistics (difficulty accepted/rejected, stale, blocks).
|
|
+ /// Backends that expose them override this; others return None.
|
|
+ #[allow(unused_variables)]
|
|
+ fn parse_share_summary(&self, data: &HashMap<DataField, Value>) -> Option<ShareSummary> {
|
|
+ None
|
|
+ }
|
|
}
|
|
|
|
// Best share difficulty (this session / since boot)
|
|
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 63f819f8..71195737 100644
|
|
--- a/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs
|
|
+++ b/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs
|
|
@@ -21,6 +21,7 @@ use asic_rs_core::{
|
|
message::{MessageSeverity, MinerMessage},
|
|
miner::{MiningMode, TuningTarget},
|
|
pool::{PoolData, PoolGroupData, PoolURL},
|
|
+ share::{ShareSummary, parse_cgminer_share_summary},
|
|
},
|
|
traits::{miner::*, model::MinerModel},
|
|
};
|
|
@@ -509,6 +510,16 @@ impl GetDataLocations for AntMinerV2020 {
|
|
tag: None,
|
|
},
|
|
)],
|
|
+ // Cumulative share stats from cgminer summary (round 19 #10, T2);
|
|
+ // RPC_SUMMARY already fetched.
|
|
+ DataField::ShareSummary => vec![(
|
|
+ RPC_SUMMARY,
|
|
+ DataExtractor {
|
|
+ func: get_by_pointer,
|
|
+ key: Some("/SUMMARY/0"),
|
|
+ tag: None,
|
|
+ },
|
|
+ )],
|
|
// `total_rateideal`, by contrast, says nothing about its own
|
|
// scale, so carry STATS' `rate_unit` alongside it.
|
|
DataField::ExpectedHashrate => vec![
|
|
@@ -889,6 +900,10 @@ impl GetBestShare for AntMinerV2020 {
|
|
// (round 19 #10).
|
|
data.extract::<f64>(DataField::BestShare).filter(|&v| v > 0.0)
|
|
}
|
|
+ fn parse_share_summary(&self, data: &HashMap<DataField, Value>) -> Option<ShareSummary> {
|
|
+ data.get(&DataField::ShareSummary)
|
|
+ .and_then(parse_cgminer_share_summary)
|
|
+ }
|
|
}
|
|
impl GetSessionBestShare for AntMinerV2020 {}
|
|
|
|
@@ -1679,6 +1694,12 @@ mod tests {
|
|
algo: HashAlgorithm::SHA256,
|
|
}
|
|
);
|
|
+ // Cumulative share stats from cgminer summary (round 19 #10, T2).
|
|
+ let shares = miner_data.share_summary.expect("share summary");
|
|
+ assert_eq!(shares.difficulty_accepted, Some(1305083904.0));
|
|
+ assert_eq!(shares.difficulty_rejected, Some(2490368.0));
|
|
+ assert_eq!(shares.stale_shares, Some(1));
|
|
+ assert_eq!(shares.found_blocks, Some(0));
|
|
}
|
|
|
|
#[tokio::test]
|
|
diff --git a/vendor/asic-rs-firmwares-antminer/src/backends/v2023_07/mod.rs b/vendor/asic-rs-firmwares-antminer/src/backends/v2023_07/mod.rs
|
|
index 1ac2bad1..58e8a5c2 100644
|
|
--- a/vendor/asic-rs-firmwares-antminer/src/backends/v2023_07/mod.rs
|
|
+++ b/vendor/asic-rs-firmwares-antminer/src/backends/v2023_07/mod.rs
|
|
@@ -23,6 +23,7 @@ use asic_rs_core::{
|
|
message::{MessageSeverity, MinerMessage},
|
|
miner::{MiningMode, TuningTarget},
|
|
pool::{PoolData, PoolGroupData, PoolURL},
|
|
+ share::{ShareSummary, parse_cgminer_share_summary},
|
|
},
|
|
traits::{miner::*, model::MinerModel},
|
|
};
|
|
@@ -547,6 +548,16 @@ impl GetDataLocations for AntMinerV202307 {
|
|
tag: None,
|
|
},
|
|
)],
|
|
+ // Cumulative share stats from cgminer summary (round 19 #10, T2);
|
|
+ // RPC_SUMMARY already fetched.
|
|
+ DataField::ShareSummary => vec![(
|
|
+ RPC_SUMMARY,
|
|
+ DataExtractor {
|
|
+ func: get_by_pointer,
|
|
+ key: Some("/SUMMARY/0"),
|
|
+ tag: None,
|
|
+ },
|
|
+ )],
|
|
DataField::SessionBestShare => vec![(
|
|
RPC_SUMMARY,
|
|
DataExtractor {
|
|
@@ -955,6 +966,10 @@ impl GetBestShare for AntMinerV202307 {
|
|
// reports 0 when it has never found a share (round 17 R7).
|
|
data.extract::<f64>(DataField::BestShare).filter(|&v| v > 0.0)
|
|
}
|
|
+ fn parse_share_summary(&self, data: &HashMap<DataField, Value>) -> Option<ShareSummary> {
|
|
+ data.get(&DataField::ShareSummary)
|
|
+ .and_then(parse_cgminer_share_summary)
|
|
+ }
|
|
}
|
|
|
|
impl GetSessionBestShare for AntMinerV202307 {
|
|
diff --git a/vendor/asic-rs-firmwares-luxminer/src/backends/v1/mod.rs b/vendor/asic-rs-firmwares-luxminer/src/backends/v1/mod.rs
|
|
index a75a3f97..413f237a 100644
|
|
--- a/vendor/asic-rs-firmwares-luxminer/src/backends/v1/mod.rs
|
|
+++ b/vendor/asic-rs-firmwares-luxminer/src/backends/v1/mod.rs
|
|
@@ -20,6 +20,7 @@ use asic_rs_core::{
|
|
message::{MessageSeverity, MinerMessage},
|
|
miner::TuningTarget,
|
|
pool::{PoolData, PoolGroupData, PoolURL},
|
|
+ share::{ShareSummary, parse_cgminer_share_summary},
|
|
},
|
|
traits::{miner::*, model::MinerModel},
|
|
};
|
|
@@ -455,6 +456,16 @@ impl GetDataLocations for LuxMinerV1 {
|
|
tag: None,
|
|
},
|
|
)],
|
|
+ // Cumulative share stats from LuxOS summary (round 19 #10, T2);
|
|
+ // RPC_SUMMARY already fetched.
|
|
+ DataField::ShareSummary => vec![(
|
|
+ RPC_SUMMARY,
|
|
+ DataExtractor {
|
|
+ func: get_by_pointer,
|
|
+ key: Some("/SUMMARY/0"),
|
|
+ tag: None,
|
|
+ },
|
|
+ )],
|
|
DataField::SessionBestShare => vec![(
|
|
RPC_SUMMARY,
|
|
DataExtractor {
|
|
@@ -945,6 +956,10 @@ impl GetBestShare for LuxMinerV1 {
|
|
// LuxOS summary -> "Best Share" (all-time), round 16 / G9.
|
|
data.extract::<f64>(DataField::BestShare)
|
|
}
|
|
+ fn parse_share_summary(&self, data: &HashMap<DataField, Value>) -> Option<ShareSummary> {
|
|
+ data.get(&DataField::ShareSummary)
|
|
+ .and_then(parse_cgminer_share_summary)
|
|
+ }
|
|
}
|
|
impl GetSessionBestShare for LuxMinerV1 {
|
|
fn parse_session_best_share(&self, data: &HashMap<DataField, Value>) -> Option<f64> {
|
|
diff --git a/vendor/asic-rs-firmwares-whatsminer/src/backends/v1/mod.rs b/vendor/asic-rs-firmwares-whatsminer/src/backends/v1/mod.rs
|
|
index 584ae8d1..aacd1077 100644
|
|
--- a/vendor/asic-rs-firmwares-whatsminer/src/backends/v1/mod.rs
|
|
+++ b/vendor/asic-rs-firmwares-whatsminer/src/backends/v1/mod.rs
|
|
@@ -19,6 +19,7 @@ use asic_rs_core::{
|
|
miner::TuningTarget,
|
|
pool::{PoolData, PoolGroupData, PoolURL},
|
|
psu::PsuInfo,
|
|
+ share::{ShareSummary, parse_cgminer_share_summary},
|
|
},
|
|
traits::{miner::*, model::MinerModel},
|
|
};
|
|
@@ -264,6 +265,16 @@ impl GetDataLocations for WhatsMinerV1 {
|
|
tag: None,
|
|
},
|
|
)],
|
|
+ // Cumulative share stats from btminer summary (round 19 #10, T2);
|
|
+ // RPC_SUMMARY already fetched.
|
|
+ DataField::ShareSummary => vec![(
|
|
+ RPC_SUMMARY,
|
|
+ DataExtractor {
|
|
+ func: get_by_pointer,
|
|
+ key: Some("/SUMMARY/0"),
|
|
+ tag: None,
|
|
+ },
|
|
+ )],
|
|
DataField::ExpectedHashrate => vec![(
|
|
RPC_SUMMARY,
|
|
DataExtractor {
|
|
@@ -597,6 +608,10 @@ impl GetBestShare for WhatsMinerV1 {
|
|
fn parse_best_share(&self, data: &HashMap<DataField, Value>) -> Option<f64> {
|
|
data.extract::<f64>(DataField::BestShare).filter(|&v| v > 0.0)
|
|
}
|
|
+ fn parse_share_summary(&self, data: &HashMap<DataField, Value>) -> Option<ShareSummary> {
|
|
+ data.get(&DataField::ShareSummary)
|
|
+ .and_then(parse_cgminer_share_summary)
|
|
+ }
|
|
}
|
|
impl GetSessionBestShare for WhatsMinerV1 {}
|
|
impl GetOperatingState for WhatsMinerV1 {}
|
|
@@ -969,6 +984,14 @@ mod integration_tests {
|
|
assert_eq!(hr.unit, HashRateUnit::TeraHash);
|
|
assert!((hr.value - 67.43935249).abs() < 1e-6);
|
|
}
|
|
+ // Cumulative share stats from summary (round 19 #10, T2).
|
|
+ let shares = miner_data
|
|
+ .share_summary
|
|
+ .ok_or_else(|| anyhow::anyhow!("v1 should expose share summary"))?;
|
|
+ assert_eq!(shares.difficulty_accepted, Some(158334976.0));
|
|
+ assert_eq!(shares.difficulty_rejected, Some(0.0));
|
|
+ assert_eq!(shares.stale_shares, Some(0));
|
|
+ assert_eq!(shares.found_blocks, Some(0));
|
|
assert_eq!(miner_data.wattage, Some(Power::from_watts(3417f64)));
|
|
assert_eq!(
|
|
miner_data.tuning_target,
|
|
diff --git a/vendor/asic-rs-firmwares-whatsminer/src/backends/v2/mod.rs b/vendor/asic-rs-firmwares-whatsminer/src/backends/v2/mod.rs
|
|
index 5de37579..4cfcee19 100644
|
|
--- a/vendor/asic-rs-firmwares-whatsminer/src/backends/v2/mod.rs
|
|
+++ b/vendor/asic-rs-firmwares-whatsminer/src/backends/v2/mod.rs
|
|
@@ -21,6 +21,7 @@ use asic_rs_core::{
|
|
miner::{MiningMode, TuningTarget},
|
|
pool::{PoolData, PoolGroupData, PoolURL},
|
|
psu::PsuInfo,
|
|
+ share::{ShareSummary, parse_cgminer_share_summary},
|
|
},
|
|
traits::{miner::*, model::MinerModel},
|
|
util::is_expected_write_error,
|
|
@@ -265,6 +266,16 @@ impl GetDataLocations for WhatsMinerV2 {
|
|
tag: None,
|
|
},
|
|
)],
|
|
+ // Cumulative share stats from btminer summary (round 19 #10, T2);
|
|
+ // RPC_SUMMARY already fetched.
|
|
+ DataField::ShareSummary => vec![(
|
|
+ RPC_SUMMARY,
|
|
+ DataExtractor {
|
|
+ func: get_by_pointer,
|
|
+ key: Some("/SUMMARY/0"),
|
|
+ tag: None,
|
|
+ },
|
|
+ )],
|
|
DataField::ExpectedHashrate => vec![(
|
|
RPC_SUMMARY,
|
|
DataExtractor {
|
|
@@ -592,6 +603,10 @@ impl GetBestShare for WhatsMinerV2 {
|
|
fn parse_best_share(&self, data: &HashMap<DataField, Value>) -> Option<f64> {
|
|
data.extract::<f64>(DataField::BestShare).filter(|&v| v > 0.0)
|
|
}
|
|
+ fn parse_share_summary(&self, data: &HashMap<DataField, Value>) -> Option<ShareSummary> {
|
|
+ data.get(&DataField::ShareSummary)
|
|
+ .and_then(parse_cgminer_share_summary)
|
|
+ }
|
|
}
|
|
impl GetSessionBestShare for WhatsMinerV2 {}
|
|
impl GetOperatingState for WhatsMinerV2 {}
|