Compare commits

..

15 Commits

Author SHA1 Message Date
Brett Rowan
ce288e472f version: bump version number. 2024-02-10 17:51:12 -07:00
Brett Rowan
02d8f25daf Merge pull request #108 from jpcomps/master
add ePIC UMC S21 support, fix HB generation by using capabilities
2024-02-10 17:50:37 -07:00
John-Paul Compagnone
a76d1c6149 add ePIC UMC S21 support, fix HB generation by using capabilities 2024-02-10 19:36:07 -05:00
Brett Rowan
17f5eade19 version: bump version number. 2024-02-10 16:45:49 -07:00
Brett Rowan
b6a2a5054b bug: fix goldshell sleep mode again. 2024-02-10 16:45:29 -07:00
Brett Rowan
5984338c64 version: bump version number. 2024-02-10 15:47:25 -07:00
Brett Rowan
07d1c48e33 bug: fix goldshell config/power modes. 2024-02-10 15:46:55 -07:00
Brett Rowan
d2abae947c version: bump version number. 2024-02-10 15:39:34 -07:00
Brett Rowan
e4a0f2451a Attempt to fix goldshell mode issues. 2024-02-10 15:39:00 -07:00
b-rowan
880c598b1a version: bump version number. 2024-02-10 14:26:09 -07:00
b-rowan
3632c2c4d8 feature: add support for goldshell shutdown. 2024-02-10 14:25:42 -07:00
b-rowan
09bc9686ae feature: add support for goldshell mode settings. 2024-02-10 14:23:17 -07:00
b-rowan
34584ab098 feature: add support for KDBoxPro and KDBoxII. 2024-02-10 13:56:00 -07:00
UpstreamData
554d99ca08 bug: update API unlocker format. 2024-02-09 14:25:14 -07:00
UpstreamData
5c5d688ffa Update api opener. 2024-02-09 13:39:48 -07:00
26 changed files with 258 additions and 40 deletions

View File

@@ -40,6 +40,7 @@ nav:
- Antminer X15: "miners/antminer/X15.md"
- Antminer X17: "miners/antminer/X17.md"
- Antminer X19: "miners/antminer/X19.md"
- Antminer X21: "miners/antminer/X21.md"
- Avalon 7X: "miners/avalonminer/A7X.md"
- Avalon 8X: "miners/avalonminer/A8X.md"
- Avalon 9X: "miners/avalonminer/A9X.md"

View File

@@ -54,9 +54,9 @@ class FanModeNormal(MinerConfigValue):
return {
"fans": {
"Auto": {
"Idle Speed": self.minimum_speed
if not self.minimum_speed == 0
else 100
"Idle Speed": (
self.minimum_speed if not self.minimum_speed == 0 else 100
)
}
}
}

View File

@@ -50,6 +50,9 @@ class MiningModeNormal(MinerConfigValue):
def as_epic(self) -> dict:
return {"ptune": {"enabled": False}}
def as_goldshell(self) -> dict:
return {"settings": {"level": 0}}
@dataclass
class MiningModeSleep(MinerConfigValue):
@@ -71,6 +74,9 @@ class MiningModeSleep(MinerConfigValue):
def as_epic(self) -> dict:
return {"ptune": {"algo": "Sleep", "target": 0}}
def as_goldshell(self) -> dict:
return {"settings": {"level": 3}}
@dataclass
class MiningModeLPM(MinerConfigValue):
@@ -89,6 +95,9 @@ class MiningModeLPM(MinerConfigValue):
def as_auradine(self) -> dict:
return {"mode": {"mode": "eco"}}
def as_goldshell(self) -> dict:
return {"settings": {"level": 1}}
@dataclass
class MiningModeHPM(MinerConfigValue):

View File

@@ -327,9 +327,11 @@ class PoolGroup(MinerConfigValue):
return cls(
pools=[Pool.from_boser(p) for p in grpc_pool_group["pools"]],
name=grpc_pool_group["name"],
quota=grpc_pool_group["quota"]["value"]
if grpc_pool_group.get("quota") is not None
else 1,
quota=(
grpc_pool_group["quota"]["value"]
if grpc_pool_group.get("quota") is not None
else 1
),
)
except LookupError:
return cls()

View File

@@ -94,9 +94,9 @@ class MinerData:
percent_expected_wattage: float = field(init=False)
nominal: bool = field(init=False)
config: MinerConfig = None
errors: List[
Union[WhatsminerError, BraiinsOSError, X19Error, InnosiliconError]
] = field(default_factory=list)
errors: List[Union[WhatsminerError, BraiinsOSError, X19Error, InnosiliconError]] = (
field(default_factory=list)
)
fault_light: Union[bool, None] = None
efficiency: int = field(init=False)
is_mining: bool = True

View File

@@ -0,0 +1,22 @@
# ------------------------------------------------------------------------------
# Copyright 2022 Upstream Data Inc -
# -
# Licensed under the Apache License, Version 2.0 (the "License"); -
# you may not use this file except in compliance with the License. -
# You may obtain a copy of the License at -
# -
# http://www.apache.org/licenses/LICENSE-2.0 -
# -
# Unless required by applicable law or agreed to in writing, software -
# distributed under the License is distributed on an "AS IS" BASIS, -
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
# See the License for the specific language governing permissions and -
# limitations under the License. -
# ------------------------------------------------------------------------------
from pyasic.miners.backends import ePIC
from pyasic.miners.models import S21
class ePICS21(ePIC, S21):
pass

View File

@@ -0,0 +1,19 @@
# ------------------------------------------------------------------------------
# Copyright 2022 Upstream Data Inc -
# -
# Licensed under the Apache License, Version 2.0 (the "License"); -
# you may not use this file except in compliance with the License. -
# You may obtain a copy of the License at -
# -
# http://www.apache.org/licenses/LICENSE-2.0 -
# -
# Unless required by applicable law or agreed to in writing, software -
# distributed under the License is distributed on an "AS IS" BASIS, -
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
# See the License for the specific language governing permissions and -
# limitations under the License. -
# ------------------------------------------------------------------------------
from .S21 import (
ePICS21,
)

View File

@@ -15,3 +15,4 @@
# ------------------------------------------------------------------------------
from .X19 import *
from .X21 import *

View File

@@ -51,7 +51,7 @@ EPIC_DATA_LOC = DataLocations(
"_get_hashboards",
[
WebAPICommand("web_summary", "summary"),
WebAPICommand("web_hashrate", "hashrate"),
WebAPICommand("web_capabilities", "capabilities"),
],
),
str(DataOptions.WATTAGE): DataFunction(
@@ -284,7 +284,7 @@ class ePIC(BaseMiner):
return fans
async def _get_hashboards(
self, web_summary: dict = None, web_hashrate: dict = None
self, web_summary: dict = None, web_capabilities: dict = None
) -> List[HashBoard]:
if web_summary is None:
try:
@@ -292,28 +292,25 @@ class ePIC(BaseMiner):
except APIError:
pass
if web_hashrate is not None:
if web_capabilities is not None:
try:
web_hashrate = await self.web.hashrate()
web_capabilities = await self.web.capabilities()
except APIError:
pass
hb_list = [
HashBoard(slot=i, expected_chips=self.expected_chips)
for i in range(self.expected_hashboards)
]
if web_summary.get("HBs") is not None:
for hb in web_summary["HBs"]:
for hr in web_hashrate:
if hr["Index"] == hb["Index"]:
num_of_chips = len(hr["Data"])
hashrate = hb["Hashrate"][0]
# Update the Hashboard object
hb_list[hr["Index"]].expected_chips = num_of_chips
hb_list[hr["Index"]].missing = False
hb_list[hr["Index"]].hashrate = round(hashrate / 1000000, 2)
hb_list[hr["Index"]].chips = num_of_chips
hb_list[hr["Index"]].temp = hb["Temperature"]
num_of_chips = web_capabilities["Performance Estimator"]["Chip Count"]
hashrate = hb["Hashrate"][0]
# Update the Hashboard object
hb_list[hb["Index"]].missing = False
hb_list[hb["Index"]].hashrate = round(hashrate / 1000000, 2)
hb_list[hb["Index"]].chips = num_of_chips
hb_list[hb["Index"]].temp = hb["Temperature"]
return hb_list
async def _is_mining(self, *args, **kwargs) -> Optional[bool]:

View File

@@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------
from typing import List
from pyasic.config import MinerConfig
from pyasic.config import MinerConfig, MiningModeConfig
from pyasic.data import HashBoard
from pyasic.errors import APIError
from pyasic.logger import logger
@@ -74,6 +74,8 @@ class GoldshellMiner(BFGMiner):
data_locations = GOLDSHELL_DATA_LOC
supports_shutdown = True
async def get_config(self) -> MinerConfig:
# get pool data
try:
@@ -96,13 +98,19 @@ class GoldshellMiner(BFGMiner):
)
self.config = config
cfg = config.as_goldshell(user_suffix=user_suffix)
# send them back 1 at a time
for pool in config.as_goldshell(user_suffix=user_suffix)["pools"]:
for pool in cfg["pools"]:
await self.web.newpool(
url=pool["url"], user=pool["user"], password=pool["pass"]
)
settings = await self.web.setting()
for idx, plan in enumerate(settings["powerplans"]):
if plan["level"] == cfg["settings"]["level"]:
settings["select"] = idx
await self.web.set_setting(settings)
async def _get_mac(self, web_setting: dict = None) -> str:
if web_setting is None:
try:
@@ -178,3 +186,25 @@ class GoldshellMiner(BFGMiner):
logger.error(self, rpc_devdetails)
return hashboards
async def stop_mining(self) -> bool:
settings = await self.web.setting()
mode = MiningModeConfig.sleep()
cfg = mode.as_goldshell()
level = cfg["settings"]["level"]
for idx, plan in enumerate(settings["powerplans"]):
if plan["level"] == level:
settings["select"] = idx
await self.web.set_setting(settings)
return True
async def resume_mining(self) -> bool:
settings = await self.web.setting()
mode = MiningModeConfig.normal()
cfg = mode.as_goldshell()
level = cfg["settings"]["level"]
for idx, plan in enumerate(settings["powerplans"]):
if plan["level"] == level:
settings["select"] = idx
await self.web.set_setting(settings)
return True

View File

@@ -461,9 +461,11 @@ class MinerProtocol(Protocol):
ip=str(self.ip),
make=self.make,
model=self.model,
expected_chips=self.expected_chips * self.expected_hashboards
if self.expected_chips is not None
else 0,
expected_chips=(
self.expected_chips * self.expected_hashboards
if self.expected_chips is not None
else 0
),
expected_hashboards=self.expected_hashboards,
hashboards=[
HashBoard(slot=i, expected_chips=self.expected_chips)

View File

@@ -342,6 +342,8 @@ MINER_CLASSES = {
"GOLDSHELL HS5": GoldshellHS5,
"GOLDSHELL KD5": GoldshellKD5,
"GOLDSHELL KDMAX": GoldshellKDMax,
"GOLDSHELL KDBOXII": GoldshellKDBoxII,
"GOLDSHELL KDBOXPRO": GoldshellKDBoxPro,
},
MinerTypes.BRAIINS_OS: {
None: BOSMiner,
@@ -390,6 +392,7 @@ MINER_CLASSES = {
"ANTMINER S19J PRO+": ePICS19jProPlus,
"ANTMINER S19K PRO": ePICS19kPro,
"ANTMINER S19 XP": ePICS19XP,
"ANTMINER S21": ePICS21,
},
MinerTypes.HIVEON: {
None: Hiveon,
@@ -668,7 +671,11 @@ class MinerFactory:
return MinerTypes.LUX_OS
if "ANTMINER" in upper_data and "DEVDETAILS" not in upper_data:
return MinerTypes.ANTMINER
if "INTCHAINS_QOMO" in upper_data:
if (
"INTCHAINS_QOMO" in upper_data
or "KDAMINER" in upper_data
or "BFGMINER" in upper_data
):
return MinerTypes.GOLDSHELL
if "AVALON" in upper_data:
return MinerTypes.AVALONMINER

View File

@@ -0,0 +1,25 @@
# ------------------------------------------------------------------------------
# Copyright 2022 Upstream Data Inc -
# -
# Licensed under the Apache License, Version 2.0 (the "License"); -
# you may not use this file except in compliance with the License. -
# You may obtain a copy of the License at -
# -
# http://www.apache.org/licenses/LICENSE-2.0 -
# -
# Unless required by applicable law or agreed to in writing, software -
# distributed under the License is distributed on an "AS IS" BASIS, -
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
# See the License for the specific language governing permissions and -
# limitations under the License. -
# ------------------------------------------------------------------------------
from pyasic.miners.backends import GoldshellMiner
from pyasic.miners.models import KDBoxII, KDBoxPro
class GoldshellKDBoxII(GoldshellMiner, KDBoxII):
pass
class GoldshellKDBoxPro(GoldshellMiner, KDBoxPro):
pass

View File

@@ -0,0 +1,16 @@
# ------------------------------------------------------------------------------
# Copyright 2022 Upstream Data Inc -
# -
# Licensed under the Apache License, Version 2.0 (the "License"); -
# you may not use this file except in compliance with the License. -
# You may obtain a copy of the License at -
# -
# http://www.apache.org/licenses/LICENSE-2.0 -
# -
# Unless required by applicable law or agreed to in writing, software -
# distributed under the License is distributed on an "AS IS" BASIS, -
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
# See the License for the specific language governing permissions and -
# limitations under the License. -
# ------------------------------------------------------------------------------
from .KDBox import GoldshellKDBoxII, GoldshellKDBoxPro

View File

@@ -14,4 +14,5 @@
# limitations under the License. -
# ------------------------------------------------------------------------------
from .X5 import *
from .XBox import *
from .XMax import *

View File

@@ -0,0 +1,23 @@
# ------------------------------------------------------------------------------
# Copyright 2022 Upstream Data Inc -
# -
# Licensed under the Apache License, Version 2.0 (the "License"); -
# you may not use this file except in compliance with the License. -
# You may obtain a copy of the License at -
# -
# http://www.apache.org/licenses/LICENSE-2.0 -
# -
# Unless required by applicable law or agreed to in writing, software -
# distributed under the License is distributed on an "AS IS" BASIS, -
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
# See the License for the specific language governing permissions and -
# limitations under the License. -
# ------------------------------------------------------------------------------
from pyasic.miners.makes import AntMinerMake
class S21(AntMinerMake):
raw_model = "S21"
expected_chips = 108
expected_fans = 4

View File

@@ -0,0 +1,19 @@
# ------------------------------------------------------------------------------
# Copyright 2022 Upstream Data Inc -
# -
# Licensed under the Apache License, Version 2.0 (the "License"); -
# you may not use this file except in compliance with the License. -
# You may obtain a copy of the License at -
# -
# http://www.apache.org/licenses/LICENSE-2.0 -
# -
# Unless required by applicable law or agreed to in writing, software -
# distributed under the License is distributed on an "AS IS" BASIS, -
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
# See the License for the specific language governing permissions and -
# limitations under the License. -
# ------------------------------------------------------------------------------
from .S21 import (
S21,
)

View File

@@ -20,3 +20,4 @@ from .X9 import *
from .X15 import *
from .X17 import *
from .X19 import *
from .X21 import *

View File

@@ -0,0 +1,30 @@
# ------------------------------------------------------------------------------
# Copyright 2022 Upstream Data Inc -
# -
# Licensed under the Apache License, Version 2.0 (the "License"); -
# you may not use this file except in compliance with the License. -
# You may obtain a copy of the License at -
# -
# http://www.apache.org/licenses/LICENSE-2.0 -
# -
# Unless required by applicable law or agreed to in writing, software -
# distributed under the License is distributed on an "AS IS" BASIS, -
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
# See the License for the specific language governing permissions and -
# limitations under the License. -
# ------------------------------------------------------------------------------
from pyasic.miners.makes import GoldshellMake
class KDBoxII(GoldshellMake):
raw_model = "KD Box II"
expected_chips = 36
expected_fans = 2
expected_hashboards = 1
class KDBoxPro(GoldshellMake):
raw_model = "KD Box Pro"
expected_chips = 16
expected_fans = 2
expected_hashboards = 1

View File

@@ -0,0 +1 @@
from .KDBox import KDBoxII, KDBoxPro

View File

@@ -14,4 +14,5 @@
# limitations under the License. -
# ------------------------------------------------------------------------------
from .X5 import *
from .XBox import *
from .XMax import *

View File

@@ -165,7 +165,7 @@ class BaseMinerRPCAPI:
for func in
# each function in self
dir(self)
if not func == "commands"
if not func in ["commands", "open_api"]
if callable(getattr(self, func)) and
# no __ or _ methods
not func.startswith("__") and not func.startswith("_") and

View File

@@ -349,7 +349,7 @@ class BTMinerRPCAPI(BaseMinerRPCAPI):
stage1_req = (
await c.post(
"https://wmt.pyasic.org/v1/stage1",
json={"ip": self.ip},
json={"ip": str(self.ip)},
follow_redirects=True,
)
).json()
@@ -359,13 +359,19 @@ class BTMinerRPCAPI(BaseMinerRPCAPI):
stage2_req = (
await c.post(
"https://wmt.pyasic.org/v1/stage2",
json={"ip": self.ip, "stage1_result": stage1_res.decode("utf-8")},
json={
"ip": str(self.ip),
"stage1_result": stage1_res.decode("utf-8"),
},
)
).json()
try:
await self._send_bytes(binascii.unhexlify(stage2_req), timeout=3, port=8889)
except asyncio.TimeoutError:
pass
for command in stage2_req:
try:
await self._send_bytes(
binascii.unhexlify(command), timeout=3, port=8889
)
except asyncio.TimeoutError:
pass
return True
#### PRIVILEGED COMMANDS ####

View File

@@ -73,7 +73,9 @@ class BOSMinerWebAPI(BaseWebAPI):
login = {"luci_username": self.username, "luci_password": self.pwd}
url = f"http://{self.ip}:{self.port}/cgi-bin/luci"
headers = {
"User-Agent": "BTC Tools v0.1", # only seems to respond if this user-agent is set
"User-Agent": (
"BTC Tools v0.1"
), # only seems to respond if this user-agent is set
"Content-Type": "application/x-www-form-urlencoded",
}
await session.post(url, headers=headers, data=login)

View File

@@ -138,5 +138,8 @@ class GoldshellWebAPI(BaseWebAPI):
async def setting(self) -> dict:
return await self.send_command("setting")
async def set_setting(self, values: dict):
await self.send_command("setting", **values)
async def status(self) -> dict:
return await self.send_command("status")

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyasic"
version = "0.51.1"
version = "0.53.0"
description = "A simplified and standardized interface for Bitcoin ASICs."
authors = ["UpstreamData <brett@upstreamdata.ca>"]
repository = "https://github.com/UpstreamData/pyasic"