pyasic icon indicating copy to clipboard operation
pyasic copied to clipboard

Error sending config

Open womj opened this issue 1 year ago • 15 comments

Describe the bug Error sending config Code below results in error Error: 'tuple' object has no attribute 'SerializeToString'

To Reproduce Steps to reproduce the behavior:

miner = await pyasic.get_miner(miner_ip)

        if miner is None:
            raise Exception("Miner not found")
        stop_mining_res = await miner.resume_mining()
        print(stop_mining_res)

        current_config: pyasic.MinerConfig = await miner.get_config()
        current_config.pools.groups[0].pools[0].url = "stratum+tcp://us1.ethermine.org:4444"
        print(current_config)
        mc = pyasic.MinerConfig(pools=current_config.pools, fan_mode=current_config.fan_mode, temperature=current_config.temperature, mining_mode=current_config.mining_mode)
        # mc = pyasic.MinerConfig()
        await miner.send_config(mc)

Expected behavior I expect the primary pool url to be changed to "stratum+tcp://us1.ethermine.org:4444"

Desktop (please complete the following information):

  • OS: POPOs 22.04
  • Version 22.04

Miner Information (If applicable):

  • Manufacturer: Antminer
  • Type: S19XP
  • Firmware Type: BOS
  • Firmware Version: 2024-12-03-0-f4c282cd-24.09.1-plus

womj avatar Mar 10 '25 15:03 womj

The error "Error: 'tuple' object has no attribute 'SerializeToString'" suggests there's an issue with how the pools configuration is being handled.

Try this approach:

  1. Make sure you're not accidentally converting the pools configuration to a tuple at any point.

  2. Try creating a deep copy of the current configuration first:

import copy
current_config = await miner.get_config()
new_config = copy.deepcopy(current_config)
new_config.pools.groups[0].pools[0].url = "stratum+tcp://us1.ethermine.org:4444"
await miner.send_config(new_config)

JAGADISHSUNILPEDNEKAR avatar Mar 11 '25 17:03 JAGADISHSUNILPEDNEKAR

Don't even need to do that much,

async def write_config(ip: str):
    miner = await pyasic.get_miner(ip)
    cfg = await miner.get_config()
    cfg.pools.groups[0].pools[0].url = "stratum+tcp://us1.ethermine.org:4444"
    await miner.send_config(cfg)

b-rowan avatar Mar 11 '25 19:03 b-rowan

The error indicates a serialization issue when trying to create a new MinerConfig object. My suggestion to use a deep copy was on the right track, but @b-rowan's more direct approach is even cleaner - simply modify the existing configuration object and send it back. This avoids any potential data type conversion problems during serialization.

Thank you @b-rowan

JAGADISHSUNILPEDNEKAR avatar Mar 12 '25 11:03 JAGADISHSUNILPEDNEKAR

Don't even need to do that much,

async def write_config(ip: str): miner = await pyasic.get_miner(ip) cfg = await miner.get_config() cfg.pools.groups[0].pools[0].url = "stratum+tcp://us1.ethermine.org:4444" await miner.send_config(cfg)

Same issue, this was the way it was originally tried. Thank you for the response.

womj avatar Mar 17 '25 13:03 womj

Ok, good to know. I'll take a look and see if I can figure out what is failing to serialize.

b-rowan avatar Mar 17 '25 13:03 b-rowan

Can you send the full config (you can redact username stuff etc)? Everything Ive tried seems to be working fine, so want to see if there is some parsing issue.

Basically

config = await miner.get_config()
print(config.model_dump())

b-rowan avatar Mar 17 '25 20:03 b-rowan

@b-rowan

{
  "pools": {
    "groups": [
      {
        "pools": [
          {
            "url": "***",
            "user": "***",
            "password": "***"
          },
          {
            "url": "***",
            "user": "***",
            "password": "***"
          },
          {
            "url": "***",
            "user": "***",
            "password": "***"
          }
        ],
        "quota": 1,
        "name": "Default"
      }
    ]
  },
  "fan_mode": {
    "mode": "manual",
    "speed": 99,
    "minimum_fans": 1
  },
  "temperature": {
    "target": None,
    "hot": None,
    "danger": None
  },
  "mining_mode": {
    "mode": "power_tuning",
    "power": 4400,
    "algo": {
      "mode": "standard"
    },
    "scaling": {
      "step": 200,
      "minimum": None,
      "shutdown": None
    }
  }
}

womj avatar Mar 18 '25 13:03 womj

Tracked down the error a little bit

sending key set_dps
sending message (SetDpsRequest(enable=True, enable_shutdown=None, shutdown_duration=None, target=DpsTarget(power_target=DpsPowerTarget(power_step=Power(watt=200), min_power_target=Power(watt=None)))),)
Error: 'tuple' object has no attribute 'SerializeToString'

It's in the miners/backends/braiins_os.py send_config method when sending the set_dps key

womj avatar Mar 20 '25 15:03 womj

Seems like that set_dps is a tuple, which makes no sense. Ill fix it.

b-rowan avatar Mar 20 '25 15:03 b-rowan

Thank you :)

womj avatar Mar 20 '25 15:03 womj

Error: gRPC command failed - <bound method PerformanceServiceStub.set_dps of <pyasic.web.braiins_os.boser.BOSMinerGRPCStub object at 0x7ab39943ea20>>

new error in the send_config method for the same miner

womj avatar Mar 20 '25 15:03 womj

(<Status.INVALID_ARGUMENT: 3>, 'unspecified save action', None)

womj avatar Mar 20 '25 16:03 womj

I'll get working and put up pr

womj avatar Mar 20 '25 16:03 womj

Added the Save action

boser_cfg[key] SetDpsRequest(save_action=SaveAction.SAVE_AND_APPLY, enable=True, enable_shutdown=None, shutdown_duration=None, target=DpsTarget(power_target=DpsPowerTarget(power_step=Power(watt=200), min_power_target=Power(watt=None))))

(<Status.INVALID_ARGUMENT: 3>, 'min power target [0W] is not in the allowed range [Some(1427)-Some(9900)]', None) Error: gRPC command failed - <bound method PerformanceServiceStub.set_dps of <pyasic.web.braiins_os.boser.BOSMinerGRPCStub object at 0x7f758cfda870>>

when we are getting the config from BOS miners I am guessing the miner is returning None because there is no value in the OS overriding the minimum of 1427. Even in the miner UI it is displayed as greyed out because we have not overridden the default. The minimum will be hardware specific I would imagine. So not sure how we can add the default in pyasic unless you have a list of the minimum power targets.

womj avatar Mar 20 '25 16:03 womj

Suspicion is correct

May need some guidance on where to find the default min power number. Or can perhaps omit the value from set config

raw grpc config {'poolGroups': [{'uid': '0', 'name': 'Default', 'pools': [{'uid': '1', 'url': 'stratum+tcp://stratum.braiins.com:3333', 'user': 'DMG2020.02fe52c844da', 'password': '123'}, {'uid': '2', 'url': 'stratum+tcp://stratum.braiins.com:3333', 'user': 'DMG2020.02fe52c844da', 'password': '123'}, {'uid': '3', 'url': 'stratum+tcp://stratum.braiins.com:3333', 'user': 'DMG2020.02fe52c844da', 'password': '123'}]}], 'temperature': {'manual': {'fanSpeedRatio': 99.0}}, 'tuner': {'enabled': True, 'tunerMode': TunerMode.POWER_TARGET, 'powerTarget': {'watt': 4400}}, 'dps': {'enabled': True, 'powerStep': {'watt': 200}}}

womj avatar Mar 20 '25 16:03 womj