threefoldtecharchive / farmerbot

ability to manage a farm
Apache License 2.0
4 stars 0 forks source link

Add pre-check for balance #56

Closed xmonader closed 1 year ago

xmonader commented 1 year ago

From the threefold chat


The logs mentioned the following...
2023-07-22 00:48:20 [ERROR] [POWERMANAGER] Job to power on node 576# failed: Error while calling set_node_power: Balance is not enough to apply an extrinsic
2023-07-22 00:48:20 [ERROR] [POWERMANAGER] Job to power off node 328# failed: Error while calling set_node_power: Balance is not enough to apply an extrinsic

Also I have node 576# that is reported to be in standby but I think it is running.
brandonpille commented 1 year ago

Can I get more information? When should we do the pre-check for balance?

xmonader commented 1 year ago

Sorry, I had to document the issue and forgot to elaborate more.

As a farmer I would assume as soon as my farmerbot starts, that all is fine and functional, but apparently if the linked account does have enough tokens it won't be able to manage the farm.

That's why I believe maybe it's the best to probably exit during start with a decent message for the user to top up the account

DylanVerstraete commented 1 year ago

We can maybe make the calls to change the power state free of any fee?

DylanVerstraete commented 1 year ago

https://github.com/threefoldtech/tfchain/issues/815

brandonpille commented 1 year ago

Sorry, I had to document the issue and forgot to elaborate more.

As a farmer I would assume as soon as my farmerbot starts, that all is fine and functional, but apparently if the linked account does have enough tokens it won't be able to manage the farm.

That's why I believe maybe it's the best to probably exit during start with a decent message for the user to top up the account

You mean if the account does not have enough tokens? Yes true the farmer won't be able to manage the farm but I fear adding the check at startup is not enough... What if the user has just enough for a couple of calls. Then after a couple of days it will fail. So we end up with the same issue. So either we check before every call and return a proper message or take the approach @DylanVerstraete proposes. I prefer the latter.

brandonpille commented 1 year ago

Actually I just had a discussion with Lee. Making the transaction free (no fee) would not solve the problem as there is still balance required to submit the transaction. That fee is then reimbursed after the call. @xmonader what solution would work for you then? Adding the check at startup or before every call to change the power state?

xmonader commented 1 year ago

IMHO, I believe we should add both, one to ensure the farmer is already not mislead into a having functional farmerbot even if it was just the start (and also while booting we show them a clear message they need to make sure to keep their account funded), and for every call and show a proper message that they need to fund the associated account (address). The farmer didn't understand that he needed to do that from the error message, so I believe there's some area of improvements there

brandonpille commented 1 year ago

Sure I'll add the check.