Witness failover script incl. SMS-Alerts powered by dsteem

in #steem-dev7 years ago

image.png
Ever since I became a Witness I had this uneasy feeling of not knowing if my node was alright or if I had missed any blocks.

GINA is amazing as notification in such an event - but it could easily get under in the sheer amount of notifications. And some of the other alternatives either weren't updated in quite some time or didn't seem to handle errors well.

Thats why I've been using the skills I learned in the last months to create a Witness-Failover script which uses dsteem and should handle errors very well.

It also uses NEXMO as a service to send SMS-Alerts. While this isn't as optimal as a service which would be only used for Witness-Alerts due to the problem not knowing if an incoming SMS is actually from the Witness-Server (unless you have a specific number for that) - an alternative might come in the next releases.

To sum it up:

Features of the Script
Watch for Missed Blocks
Switch to Backup-Node(s) and / or disable the witness
Alert the Witness via SMS of missed blocks
RPC-Failover in the event of RPC-Nodes not responding
Important
Now, since the script was just finished yesterday and due to the fact that block misses doesn't happen often and hopefully never - I wasn't able to test the actual missed block logics.

However, I've implented a testmode which can be used regardless if another script is getting used, as it only reports via console.log of events (e.g. missed blocks, send sms etc.)

My goal with this release is to get some tests going - but please keep in mind that I don't take any responsibility if the script isn't working as planned!

Nevertheless, SMS sending works!

Getting Started
I wrote a small guide on how it works and what has to be done to run it in the READ-ME of the project.

Which you will find here: https://github.com/therealwolf42/witness-failover

But I will go over the config real quick - to explain a few things:

{
"TEST_MODE": "DISABLED",
"RPC_NODES": [
"https://api.steemit.com",
"https://steemd.privex.io",
"https://gtg.steem.house:8090",
"https://rpc.buildteam.io",
"https://steemd.minnowsupportproject.org"
],
"WITNESS": "",
"BACKUP_KEYS": [
""
],
"MISSED_BLOCKS_THRESHOLD":2,
"INTERVAL":20,
"USE_SMS_ALERT":"ENABLED",
"SEND_AFTER_EVERY_MISSED":"ENABLED"
}
TEST_MODE => Test only logic but won't interact with the blockchain / send SMS => ENABLED / DISABLED

WITNESS => Witness Account Name

BACKUP_KEYS => Witness Public Keys

MISSED_BLOCKS_THRESHOLD => How many blocks can be missed until backup-node will be used or disabled if no-more nodes are available

INTERVAL => How often it should check for a missed block

USE_SMS_ALERT => Activate SMS Sending => ENABLED / DISABLED

SEND_AFTER_EVERY_MISSED => Send SMS in the case of a missed block - if DISABLED then SMS will only be send if THRESHOLD is breached => ENABLED / DISABLED

Now, there is also a .env file for the data which should never be uploaded to Github incl. your private active key.

But you will find all of that in the READ-ME of the repository.

Last but not least
It would be amazing if you could test it, even if only in test-mode.

Additionally, if you find any bugs in my code - please let me know (e.g. as issue)zmx6crlnvpvlixc18qwp.png

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.030
BTC 65353.52
ETH 2654.64
USDT 1.00
SBD 2.84