From 9e2b453eb5441122b0456d30ea772c8819d3b346 Mon Sep 17 00:00:00 2001 From: noah Date: Fri, 18 Sep 2026 15:01:42 -0600 Subject: [PATCH] GUI round 9 (#4 v2): WhatsMiner v2 power-limit now reports success on the apply-restart Follow-up to 3530d67a. Verified on the live fleet that the v2 (firmware < 2024-11-01) "adjust_power_limit" command DOES apply the new watt limit -- confirmed the set value settles via the read-only :4028 "Power Limit" after the miner restarts to re-tune. But the restart drops the connection mid-command, so the read times out; the code then reported that as a failure even though it applied. Both v2 and v3 set_power_limit now treat a transient RPC error after the command (is_expected_write_error -- read timeout / connection reset, the helper the pause/resume paths already use) as success. A genuine rejection is a StatusCheckFailed and still errors. v1 miners keep the "not supported" bail. Verified: v2 M30S+ (fw 20240930) set 3500 -> :4028 settles to 3500, restore 3600 -> settles to 3600 and the miner resumes hashing. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh --- ...-limit-v3-auth-and-error-propagation.patch | 92 +++++++++++-------- .../.cargo-checksum.json | 2 +- .../src/backends/v2/mod.rs | 17 +++- .../src/backends/v3/mod.rs | 15 ++- 4 files changed, 81 insertions(+), 45 deletions(-) diff --git a/thirdparty/asic-rs/patches/0001-whatsminer-power-limit-v3-auth-and-error-propagation.patch b/thirdparty/asic-rs/patches/0001-whatsminer-power-limit-v3-auth-and-error-propagation.patch index 19902813..58826aca 100644 --- a/thirdparty/asic-rs/patches/0001-whatsminer-power-limit-v3-auth-and-error-propagation.patch +++ b/thirdparty/asic-rs/patches/0001-whatsminer-power-limit-v3-auth-and-error-propagation.patch @@ -1,72 +1,90 @@ -Subject: [PATCH 0001] whatsminer set_power_limit: fix v3 auth/param + propagate errors +Subject: [PATCH 0001] whatsminer set_power_limit: v3 auth/param fix + restart-tolerant result -Round-9 #4 (WhatsMiner power-limit "doesn't apply properly"). Root-caused and -verified against the live fleet. +Round-9 #4 -- "the power-limit on the WhatsMiners doesn't apply properly" -- +root-caused and verified against the live fleet. v3 backend (WhatsMinerOS, firmware >= 2024-11-01, port 4433): the privileged -power-limit write authenticated against account "super" but hashed the token -with the WEB/admin password carried by `auth`, and sent the watt value as a -float. The miner rejected every such write with "invalid json or password is -wrong". Two fixes: - - set_auth: the "super" account's token password is a SEPARATE v3 credential - (factory default "super"), NOT the web/admin password; use "super". The web - password still drives the v2 (admin) path. - - set_power_limit: send the watts as a bare integer, not a float ("3000.0" - trips the firmware's "invalid json" parser). -Confirmed on a live M30S+ VH65 (fw 20241108, api 3.0.1): the fixed request -`{"cmd":"set.miner.power_limit","param":3000,"ts":..,"account":"super","token":..}` -returns {"code":0,"msg":"ok"}; asic-rs set_power_limit now returns Ok(true) and -the miner applies the limit (matches pyasic / HashSource whatsminer-api-3). +power-limit write authenticated the "super" account with the WEB/admin password +(a separate credential; the super account's factory default is "super") and sent +the watts as a float, so the miner rejected every write with "invalid json or +password is wrong". Fixes: v3 set_auth uses the super-account password ("super") +-- the web password still drives the v2 (admin) path; set_power_limit sends a +bare integer (a float trips the firmware's "invalid json" parser). -v2 + v3 backends: both wrote `Ok(data.is_ok())`, which swallowed any RPC failure -into Ok(false) and hid the miner's own status message. Propagate the error with -`?` and return Ok(true) on success (like the Braiins/Auradine/Proto backends), -so a genuine failure reaches the caller and the round-9 error indicator. +v2 backend (firmware < 2024-11-01, port 4028, "adjust_power_limit"): the command +DOES apply the new watt limit, but the miner restarts to re-tune and drops the +connection mid-command, so the read times out. Both v2 and v3 now treat a +transient RPC error after the command (is_expected_write_error -- read timeout / +connection reset, the same helper the pause/resume paths use) as success; a real +rejection is a StatusCheckFailed and still errors. + +Verified live: v3 (M30S+ fw 20241108) returns {"code":0,"msg":"ok"} and applies; +v2 (M30S+ fw 20240930) applies the changed value (confirmed via the read-only +:4028 "Power Limit" after the restart) and now returns Ok. All test miners were +returned to their prior configured limit. Matches the pyasic / HashSource +whatsminer-api-3 references. 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 c7b00e3b..11b07542 100644 +index c7b00e3b..096b2fcb 100644 --- a/vendor/asic-rs-firmwares-whatsminer/src/backends/v2/mod.rs +++ b/vendor/asic-rs-firmwares-whatsminer/src/backends/v2/mod.rs -@@ -637,11 +637,10 @@ impl SetFaultLight for WhatsMinerV2 { +@@ -637,11 +637,21 @@ impl SetFaultLight for WhatsMinerV2 { impl SetPowerLimit for WhatsMinerV2 { async fn set_power_limit(&self, limit: Power) -> anyhow::Result { let parameters = Some(json!({"power_limit": limit.as_watts().to_string()})); - let data = self -- .rpc -+ self.rpc ++ match self + .rpc .send_command("adjust_power_limit", true, parameters) - .await; - Ok(data.is_ok()) -+ .await?; -+ Ok(true) ++ .await ++ { ++ Ok(_) => Ok(true), ++ // adjust_power_limit makes the miner restart to re-tune, so it drops ++ // the connection / stops replying mid-command even though it accepted ++ // and applied the new limit (verified on the live fleet: the set value ++ // settles after the restart). A transient RPC error (read timeout / ++ // connection reset) after the command is therefore success; a genuine ++ // rejection surfaces as StatusCheckFailed and still errors. ++ Err(e) if is_expected_write_error(&e) => Ok(true), ++ Err(e) => Err(e), ++ } } fn supports_set_power_limit(&self) -> bool { true diff --git a/vendor/asic-rs-firmwares-whatsminer/src/backends/v3/mod.rs b/vendor/asic-rs-firmwares-whatsminer/src/backends/v3/mod.rs -index 77d724d5..34b7a7f8 100644 +index 77d724d5..c00c6d44 100644 --- a/vendor/asic-rs-firmwares-whatsminer/src/backends/v3/mod.rs +++ b/vendor/asic-rs-firmwares-whatsminer/src/backends/v3/mod.rs -@@ -669,12 +669,14 @@ impl SetFaultLight for WhatsMinerV3 { +@@ -669,12 +669,21 @@ impl SetFaultLight for WhatsMinerV3 { #[async_trait] impl SetPowerLimit for WhatsMinerV3 { async fn set_power_limit(&self, limit: Power) -> anyhow::Result { - let data = self -- .rpc -- .send_command("set.miner.power_limit", true, Some(json!(limit.as_watts()))) -- .await; + // WhatsMinerOS wants a BARE INTEGER watt value; a float ("3000.0") + // trips the firmware's "invalid json" parser (round-9 #4). + let watts = limit.as_watts().round() as u64; -+ self.rpc -+ .send_command("set.miner.power_limit", true, Some(json!(watts))) -+ .await?; - ++ match self + .rpc +- .send_command("set.miner.power_limit", true, Some(json!(limit.as_watts()))) +- .await; +- - Ok(data.is_ok()) -+ Ok(true) ++ .send_command("set.miner.power_limit", true, Some(json!(watts))) ++ .await ++ { ++ Ok(_) => Ok(true), ++ // A power-limit change restarts the miner to re-tune, so a transient ++ // RPC error after the command means it was accepted (as with v2), not ++ // rejected; a genuine rejection is a StatusCheckFailed and still errors. ++ Err(e) if is_expected_write_error(&e) => Ok(true), ++ Err(e) => Err(e), ++ } } fn supports_set_power_limit(&self) -> bool { true -@@ -806,8 +808,15 @@ impl HasDefaultAuth for WhatsMinerV3 { +@@ -806,8 +815,15 @@ impl HasDefaultAuth for WhatsMinerV3 { impl HasAuth for WhatsMinerV3 { fn set_auth(&mut self, auth: MinerAuth) { diff --git a/vendor/asic-rs-firmwares-whatsminer/.cargo-checksum.json b/vendor/asic-rs-firmwares-whatsminer/.cargo-checksum.json index da817e2e..8b9e7510 100644 --- a/vendor/asic-rs-firmwares-whatsminer/.cargo-checksum.json +++ b/vendor/asic-rs-firmwares-whatsminer/.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":"30f09ad063df45fdf223aff235fe2da15cb1a7e79e86d7012074153b91662fc4","Cargo.lock":"9d0886791db53421d3218ab72d964145b86cfbe9738eaf09aac5d3c89a1c0190","Cargo.toml":"8c2e9938436850f2e250e8268ed7b385fce903e2077923b207a0560ca3e3242c","Cargo.toml.orig":"891fcfa45e79d6bc4d838c4f3075618f791bd013c99231da48e752b987f409d5","src/backends/mod.rs":"0f5a0ae31d5443d0d0f41a2540def806196238c92d22761b3ad9843cb2e77f45","src/backends/v1/mod.rs":"80f3915f1e87c6f7483e9bd0e5b1fb5552f8d017634c82eea6150fe5134b171f","src/backends/v1/rpc.rs":"4cee9caeb9bc291c4efec04f4b7fc2b8eaead904a1f2d0f30e13236476d9aac5","src/backends/v2/mod.rs":"bb2018a1e2b6782df93b99f0d1454f9cb403b4df5f4061612baa129d18daaffa","src/backends/v2/rpc.rs":"b7afc5357d24de42350d4ec15a6b5a37698e4fd77b2c2cc8071f303ee62e957c","src/backends/v3/mod.rs":"51edd45ca2016316842109ac6ade6178d2d66546e5df9f6e75a96aae26504ba8","src/backends/v3/rpc.rs":"7a5f80aec4af1bcaa0d36e67345aa9acbbd8ead73c0be474f06305358b38e81b","src/error_codes.rs":"de85845f52b1d4e1a0bff73462cef00962b60fad8a3ed71c7bb083c02df3a413","src/firmware.rs":"6d002e481ce0a897c0485b9393b0382fcb25811164e893eb8eb67b2ff392ca0d","src/lib.rs":"710b46c9d934f26f900e1366ca1df5f872896e7d8da03569c0f159859e899cc9","src/test/json/mod.rs":"99760925ccfefc40d2455d3567fb1ecfc99e9e55e70478190ef372a954825909","src/test/json/v1/devs.json":"b4fd010f0bae3584efde93387cf2dab5933b499cc30a2dd7635fdc994b56c3b8","src/test/json/v1/get_psu.json":"8c11b6495e0bd5da496dd5c10ca53ec53b2d8fe9a3737f470ec9ce2c1aaf9d99","src/test/json/v1/get_version.json":"c43e947e654792ab191210d50c6f793ee0dd7af41e8cb59f0722b70f32a203bc","src/test/json/v1/mod.rs":"e79509eee78a1fef63735afe385299813726822c8259a02d1dcf5e8b4db9d04e","src/test/json/v1/pools.json":"b570808a3428a0773d7d2ee322150d8fd0794a33804af970300a7fef128a8a01","src/test/json/v1/status.json":"00ec38dd9f980b7ac0ffd6f815374afdbbed98d601bd8ef18bcf0f76ae0aa853","src/test/json/v1/summary.json":"d6e3e75654eb4019e1f479b3d9cf3097130f1afb85dd3338682c094fd4ab498a","src/test/json/v1/summary_with_errors.json":"1ba682f6ad5c43e41ae22a4069d0f52f04da3f07a18031bf4c07e07b3c59cc97","src/test/json/v2/devs.json":"2d203e41ef6ef337c0c81456b73d08730882c3167403c557c3c9776022a972d1","src/test/json/v2/get_error_code.json":"e90b702fd97bceb4f62dcb8228f75ff5ce930290355dca94eefd7192f7f57009","src/test/json/v2/get_error_code_with_errors.json":"6cb6038366eb3835684421c41be0b2b30ae8ce79a7ed51a85f4f52f70da9df16","src/test/json/v2/get_miner_info.json":"55d2af984833a692f502188ae4df4e41bdc10386b47f921c896a452ef1de9062","src/test/json/v2/get_psu.json":"b43086b65897061521d1f6611e200ef372a1724f9ea1876e347c03d5fb19b8f2","src/test/json/v2/get_version.json":"b17e3a81603b43186b2e15745e6822b6c82b3c6f5928b22f84e683d7728dbfcd","src/test/json/v2/mod.rs":"c847205d076323bbd9698e393d241b08f3cf75d32aae86f7058cf8748266b935","src/test/json/v2/pools.json":"926d34e8dae774473ebfec83d4a38e77ca73231708f07683763e212be7af0580","src/test/json/v2/status.json":"fc268cd23864ef99e84813dbf8eb916b2e6f339351a0ee5dab217cbe02569fc3","src/test/json/v2/summary.json":"4e4c01b986e2960893f58d0f1ea4dce23b8ef88db4985348f7f0183eb4818478","src/test/json/v3/get_device_info.json":"83ac22ea9a11adbceb4c963db80aa62d9a2aa50d019a372394dece817d924cda","src/test/json/v3/get_device_info_with_errors.json":"24cee4b7840e87e12147cbfddf6c361f3b378a15bb85330b339d3be9e17cdbd5","src/test/json/v3/get_miner_status_edevs.json":"2d831c06113f555e0988df994c2e602a053a4aea603dded0db8f0f80e191ca5a","src/test/json/v3/get_miner_status_pools.json":"cd65c2efd3a5ce80b57aae46c420298a34ca06df7ac7f8c36fd556217703d242","src/test/json/v3/get_miner_status_summary.json":"799a94ba13ef54aed0f81a3d041d6c1fa263d4183754b384c69ca12d85a8d3ba","src/test/json/v3/mod.rs":"7ea3a8ff1b81c7a5b0f44f7c12dda880a9aeac5b0e6b56ac4fff4f4a7cbfe451","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"c85da6325b62f061327dc5f7605dd3721c823a9e8a2cfd6a356363dfbc84d66e"} \ 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":"30f09ad063df45fdf223aff235fe2da15cb1a7e79e86d7012074153b91662fc4","Cargo.lock":"9d0886791db53421d3218ab72d964145b86cfbe9738eaf09aac5d3c89a1c0190","Cargo.toml":"8c2e9938436850f2e250e8268ed7b385fce903e2077923b207a0560ca3e3242c","Cargo.toml.orig":"891fcfa45e79d6bc4d838c4f3075618f791bd013c99231da48e752b987f409d5","src/backends/mod.rs":"0f5a0ae31d5443d0d0f41a2540def806196238c92d22761b3ad9843cb2e77f45","src/backends/v1/mod.rs":"80f3915f1e87c6f7483e9bd0e5b1fb5552f8d017634c82eea6150fe5134b171f","src/backends/v1/rpc.rs":"4cee9caeb9bc291c4efec04f4b7fc2b8eaead904a1f2d0f30e13236476d9aac5","src/backends/v2/mod.rs":"68fd8c1762b424a7785174fdb3ae4fede1d599632657808d4b7c76bcfbfb202c","src/backends/v2/rpc.rs":"b7afc5357d24de42350d4ec15a6b5a37698e4fd77b2c2cc8071f303ee62e957c","src/backends/v3/mod.rs":"f19e673c47c2cc366e2ff7782bca93daf750563d62221a12a043b3ee79a15251","src/backends/v3/rpc.rs":"7a5f80aec4af1bcaa0d36e67345aa9acbbd8ead73c0be474f06305358b38e81b","src/error_codes.rs":"de85845f52b1d4e1a0bff73462cef00962b60fad8a3ed71c7bb083c02df3a413","src/firmware.rs":"6d002e481ce0a897c0485b9393b0382fcb25811164e893eb8eb67b2ff392ca0d","src/lib.rs":"710b46c9d934f26f900e1366ca1df5f872896e7d8da03569c0f159859e899cc9","src/test/json/mod.rs":"99760925ccfefc40d2455d3567fb1ecfc99e9e55e70478190ef372a954825909","src/test/json/v1/devs.json":"b4fd010f0bae3584efde93387cf2dab5933b499cc30a2dd7635fdc994b56c3b8","src/test/json/v1/get_psu.json":"8c11b6495e0bd5da496dd5c10ca53ec53b2d8fe9a3737f470ec9ce2c1aaf9d99","src/test/json/v1/get_version.json":"c43e947e654792ab191210d50c6f793ee0dd7af41e8cb59f0722b70f32a203bc","src/test/json/v1/mod.rs":"e79509eee78a1fef63735afe385299813726822c8259a02d1dcf5e8b4db9d04e","src/test/json/v1/pools.json":"b570808a3428a0773d7d2ee322150d8fd0794a33804af970300a7fef128a8a01","src/test/json/v1/status.json":"00ec38dd9f980b7ac0ffd6f815374afdbbed98d601bd8ef18bcf0f76ae0aa853","src/test/json/v1/summary.json":"d6e3e75654eb4019e1f479b3d9cf3097130f1afb85dd3338682c094fd4ab498a","src/test/json/v1/summary_with_errors.json":"1ba682f6ad5c43e41ae22a4069d0f52f04da3f07a18031bf4c07e07b3c59cc97","src/test/json/v2/devs.json":"2d203e41ef6ef337c0c81456b73d08730882c3167403c557c3c9776022a972d1","src/test/json/v2/get_error_code.json":"e90b702fd97bceb4f62dcb8228f75ff5ce930290355dca94eefd7192f7f57009","src/test/json/v2/get_error_code_with_errors.json":"6cb6038366eb3835684421c41be0b2b30ae8ce79a7ed51a85f4f52f70da9df16","src/test/json/v2/get_miner_info.json":"55d2af984833a692f502188ae4df4e41bdc10386b47f921c896a452ef1de9062","src/test/json/v2/get_psu.json":"b43086b65897061521d1f6611e200ef372a1724f9ea1876e347c03d5fb19b8f2","src/test/json/v2/get_version.json":"b17e3a81603b43186b2e15745e6822b6c82b3c6f5928b22f84e683d7728dbfcd","src/test/json/v2/mod.rs":"c847205d076323bbd9698e393d241b08f3cf75d32aae86f7058cf8748266b935","src/test/json/v2/pools.json":"926d34e8dae774473ebfec83d4a38e77ca73231708f07683763e212be7af0580","src/test/json/v2/status.json":"fc268cd23864ef99e84813dbf8eb916b2e6f339351a0ee5dab217cbe02569fc3","src/test/json/v2/summary.json":"4e4c01b986e2960893f58d0f1ea4dce23b8ef88db4985348f7f0183eb4818478","src/test/json/v3/get_device_info.json":"83ac22ea9a11adbceb4c963db80aa62d9a2aa50d019a372394dece817d924cda","src/test/json/v3/get_device_info_with_errors.json":"24cee4b7840e87e12147cbfddf6c361f3b378a15bb85330b339d3be9e17cdbd5","src/test/json/v3/get_miner_status_edevs.json":"2d831c06113f555e0988df994c2e602a053a4aea603dded0db8f0f80e191ca5a","src/test/json/v3/get_miner_status_pools.json":"cd65c2efd3a5ce80b57aae46c420298a34ca06df7ac7f8c36fd556217703d242","src/test/json/v3/get_miner_status_summary.json":"799a94ba13ef54aed0f81a3d041d6c1fa263d4183754b384c69ca12d85a8d3ba","src/test/json/v3/mod.rs":"7ea3a8ff1b81c7a5b0f44f7c12dda880a9aeac5b0e6b56ac4fff4f4a7cbfe451","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"c85da6325b62f061327dc5f7605dd3721c823a9e8a2cfd6a356363dfbc84d66e"} \ No newline at end of file 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 11b07542..096b2fcb 100644 --- a/vendor/asic-rs-firmwares-whatsminer/src/backends/v2/mod.rs +++ b/vendor/asic-rs-firmwares-whatsminer/src/backends/v2/mod.rs @@ -637,10 +637,21 @@ impl SetFaultLight for WhatsMinerV2 { impl SetPowerLimit for WhatsMinerV2 { async fn set_power_limit(&self, limit: Power) -> anyhow::Result { let parameters = Some(json!({"power_limit": limit.as_watts().to_string()})); - self.rpc + match self + .rpc .send_command("adjust_power_limit", true, parameters) - .await?; - Ok(true) + .await + { + Ok(_) => Ok(true), + // adjust_power_limit makes the miner restart to re-tune, so it drops + // the connection / stops replying mid-command even though it accepted + // and applied the new limit (verified on the live fleet: the set value + // settles after the restart). A transient RPC error (read timeout / + // connection reset) after the command is therefore success; a genuine + // rejection surfaces as StatusCheckFailed and still errors. + Err(e) if is_expected_write_error(&e) => Ok(true), + Err(e) => Err(e), + } } fn supports_set_power_limit(&self) -> bool { true diff --git a/vendor/asic-rs-firmwares-whatsminer/src/backends/v3/mod.rs b/vendor/asic-rs-firmwares-whatsminer/src/backends/v3/mod.rs index 34b7a7f8..c00c6d44 100644 --- a/vendor/asic-rs-firmwares-whatsminer/src/backends/v3/mod.rs +++ b/vendor/asic-rs-firmwares-whatsminer/src/backends/v3/mod.rs @@ -672,11 +672,18 @@ impl SetPowerLimit for WhatsMinerV3 { // WhatsMinerOS wants a BARE INTEGER watt value; a float ("3000.0") // trips the firmware's "invalid json" parser (round-9 #4). let watts = limit.as_watts().round() as u64; - self.rpc + match self + .rpc .send_command("set.miner.power_limit", true, Some(json!(watts))) - .await?; - - Ok(true) + .await + { + Ok(_) => Ok(true), + // A power-limit change restarts the miner to re-tune, so a transient + // RPC error after the command means it was accepted (as with v2), not + // rejected; a genuine rejection is a StatusCheckFailed and still errors. + Err(e) if is_expected_write_error(&e) => Ok(true), + Err(e) => Err(e), + } } fn supports_set_power_limit(&self) -> bool { true