threefoldtech / minting_v3

minting code for grid v3, using v3 tokenomics
Apache License 2.0
0 stars 0 forks source link

Power state changes appear not to be logged #26

Closed scottyeager closed 1 year ago

scottyeager commented 1 year ago

While investigating issues where farmers believed their nodes under management of the farmerbot did not mint properly (https://github.com/threefoldtech/tf_support/issues/473, https://github.com/threefoldtech/tf_support/issues/546), I noticed the following potential cause.

In order for a node to be recognized as power managed and credited with uptime for it's sleep/standby time, the minting code looks for a state transition, from power state "Up" to power state "Down". However, the new state from the block event is never written to node_power.state. Compare to this line in the power target event handler above. I would expect to see something similar in the power state handler.

Thus, the only nodes that are credited for their standby time are nodes that had power state "Up" at the beginning of the minting period. Since the state is never updated, their previous state will always appear to be "Up", while nodes that were "Down" at the beginning of the period will never switch to "Up" to trigger the state transition.

This is consistent with reports from farmers, that their nodes mint properly for the first month they use farmerbot, but not in the second month. It could also explain why the issue did not appear in testing, assuming that the code was only tested against nodes that would actually be eligible to mint in the first cycle after farmerbot was activated on testnet.

LeeSmet commented 1 year ago

Seems the assignment was indeed removed at some point during development while setting up the trigger, iirc when fixing the fact that nodes can sometimes send an uptime report right after being set to down.