threefoldfoundation / node-status-bot

Telegram bot for ThreeFold nodes
Apache License 2.0
2 stars 1 forks source link

Upgrade bot data handling #16

Open scottyeager opened 22 hours ago

scottyeager commented 22 hours ago

Currently the bot uses PicklePersistence provided by the python-telegram-bot library to store bot data on disk. The data stored this way includes information about the subscribed users, nodes, and farmerbot related minting violations. If the data is lost, users stop getting the alerts they subscribed for and must subscribe again, some extra alerts regarding violations will likely fire, and overall it's a bad situation.

So far the deployment of the bot has included syncing this bot data file to remote storage as a backup. At least one recovery from the remotely synced file has been successful, but overall this approach is not so robust. Here's a summary of issues:

There are some alternatives, which are broadly:

When it comes to databases, there are further sub options:

In the case of a custom implementation, there's also the question of how to handle interfacing with the database, as well as what database to use:

scottyeager commented 22 hours ago

I built a persistent dictionary implementation that can be used more or less as a drop in for the dict(s) we store within bot data currently. A bit more work is needed to handle the inherently threaded nature of the bot library. Check the receipts handler in Peppermint for an idea of how to do this.