create account

[steemtools] automatic failover for witness nodes by jesta

View this thread on: hive.blogpeakd.comecency.com
· @jesta · (edited)
$253.13
[steemtools] automatic failover for witness nodes
I was told "code or it didn't happen" when my node gracefully failed over about an hour ago, so here it is. I'm a bit tired, so I apologize if there's gaps in the documentation.

https://github.com/aaroncox/witness-failover

This script is something I've been tinkering with over the past few weeks as part of my infrastructure as a witness. **If you're planning on using this, I'm willing to answer questions, but I'm not willing to set this up for you**. You need a basic understanding of infrastructure, docker, and witness management to really be effective with this code. **I also make no claims that this will work in the future or on your system**, please use responsibly!

Either that or just use it to learn from - and build your own tools based on it's principals. 

## witness node configuration

This setup requires a 3 system setup as described below:

- Witness Node #1, with Signing Private Key #1
- Witness Node #2, with Signing Private Key #2
- This script, running someplace besides the witness nodes, potentially a workstation.

In this scenario, we're going to assume your account currently has Signing Key #1 active.

To enable the failover trap,

- Edit the `.env` file and fill out your witness account, the *active wif private key**, and all of your preferred witness properties.
- Put the public signing key of Witness Node #2 into the configuration as `steem_backup`.
- Check how many `total_missed` blocks you currently have, and +1 or +2 that number, and put that also in the `.env` file as `threshold`.

*Note*: Yes, this requires your private active key, which means you need to ensure this system is secure. This is a valid reason to use a 2nd account for witnessing or make sure all of your liquid funds are locked in savings accounts. (Originally I had linked from here to a post I made about feed_publish operations and permissions. I was tired, that had nothing to do with this)

## piston + steemtools + twilio

Once configured and running, this script performs the following actions every interval:

- Every 30 seconds, checks the defined witness to see how many `total_missed` blocks have been reported.
- If `total_missed >= threshold` (threshold is a number you set), the script triggers.
- Once triggered, it uses @furion's steemtools, built on @xeroc's piston, to issue a `witness_update` transaction to change your `signing_key` to a different key.
- It also then uses twilio (SMS Service, Paid) to send out an SMS message letting you know the trap has triggered. If you don't want to have to setup a twilio account, you can edit the code and remove the requirement. I'm very happily paying $0.0075 USD for it to notify me once in a blue moon of issues occurring :)

With the `witness_update` command triggered, it will broadcast a new signing key to your account (that of Witness Node #2 in this example), which will automatically fail your witness server over to the backup.

## It's a one-shot failover script that terminates itself

Think of it like a mouse trap - you start running it and once it's triggered, you're going to have to go in and reset the variables and start it again. This is not meant to be completely automated, though it could be taken that far over time. I haven't spent an incredible amount of time on that direction, as this works for now.

I'm releasing this code with [The Unlicense](http://unlicense.org/), so you're free to do whatever you want with this. I also make no claims as to this actually working, as there are many dependancies that could break along the way. If you're embarking on the "Adventure of Automatic Failover" for witnessing, please make sure you know what you're doing :)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 290 others
properties (23)
authorjesta
permlinksteemtools-automatic-failover-for-witness-nodes
categorywitness-category
json_metadata{"tags":["witness-category","tools"],"users":["furion","xeroc"],"links":["https://github.com/aaroncox/witness-failover","http://unlicense.org/"]}
created2016-09-24 08:23:36
last_update2016-09-25 06:28:03
depth0
children10
last_payout2016-10-25 10:23:33
cashout_time1969-12-31 23:59:59
total_payout_value238.812 HBD
curator_payout_value14.318 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,667
author_reputation140,605,453,893,072
root_title"[steemtools] automatic failover for witness nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id1,345,240
net_rshares78,202,919,331,161
author_curate_reward""
vote details (354)
@bitcoiner ·
If I ever reach the point where I'll need a backup witness node, I'll definitely use this script! Thanks, @jesta
properties (22)
authorbitcoiner
permlinkre-jesta-steemtools-automatic-failover-for-witness-nodes-20160924t083948139z
categorywitness-category
json_metadata{"tags":["witness-category"],"users":["jesta"]}
created2016-09-24 08:39:51
last_update2016-09-24 08:39:51
depth1
children0
last_payout2016-10-25 10:23:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length112
author_reputation28,017,014,641,958
root_title"[steemtools] automatic failover for witness nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id1,345,332
net_rshares0
@garethnelsonuk ·
Why not just put it in a loop to make it "reset"?
properties (22)
authorgarethnelsonuk
permlinkre-jesta-steemtools-automatic-failover-for-witness-nodes-20160924t083242635z
categorywitness-category
json_metadata{"tags":["witness-category"]}
created2016-09-24 08:32:42
last_update2016-09-24 08:32:42
depth1
children3
last_payout2016-10-25 10:23:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length49
author_reputation9,564,384,386,809
root_title"[steemtools] automatic failover for witness nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id1,345,282
net_rshares0
@jesta ·
You could, but who's to say that the other server would be online again if the backup went down? It might just ping-pong between two dead servers and spam `witness_update` operations until you pay attention to it. 

It could definitely be taken that direction though with a bit more effort. Effort that I haven't yet put in :)
👍  
properties (23)
authorjesta
permlinkre-garethnelsonuk-re-jesta-steemtools-automatic-failover-for-witness-nodes-20160924t083443167z
categorywitness-category
json_metadata{"tags":["witness-category"]}
created2016-09-24 08:34:42
last_update2016-09-24 08:34:42
depth2
children2
last_payout2016-10-25 10:23:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length326
author_reputation140,605,453,893,072
root_title"[steemtools] automatic failover for witness nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id1,345,291
net_rshares5,751,442,582
author_curate_reward""
vote details (1)
@garethnelsonuk ·
A better plan would be to have a script run on the witness server that actually checks for steemd running - or just open a port in the firewall and have the failover script check that it can connect.
properties (22)
authorgarethnelsonuk
permlinkre-jesta-re-garethnelsonuk-re-jesta-steemtools-automatic-failover-for-witness-nodes-20160924t084325162z
categorywitness-category
json_metadata{"tags":["witness-category"]}
created2016-09-24 08:43:24
last_update2016-09-24 08:43:24
depth3
children1
last_payout2016-10-25 10:23:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length199
author_reputation9,564,384,386,809
root_title"[steemtools] automatic failover for witness nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id1,345,352
net_rshares0
@goldmatters ·
Resteemed..... And tweeted!
👍  
properties (23)
authorgoldmatters
permlinkre-jesta-steemtools-automatic-failover-for-witness-nodes-20160924t082749826z
categorywitness-category
json_metadata{"tags":["witness-category"]}
created2016-09-24 08:27:48
last_update2016-09-24 08:27:48
depth1
children0
last_payout2016-10-25 10:23:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length27
author_reputation409,743,405,777,482
root_title"[steemtools] automatic failover for witness nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id1,345,259
net_rshares39,347,576,092
author_curate_reward""
vote details (1)
@l0k1 ·
The Unlicence! I am so pleased to see another user using this licence. Creative work is a highly speculative endeavour, copyright does not in fact help any up and coming artist, because they don't have the money to pay lawyers, which, even if they did, it is questionable what benefit this has to the economy as a whole. 

So the whole concept, in my opinion, should be scrapped. False attribution is the only crime that connects with this, it is clearly fraud.
properties (22)
authorl0k1
permlinkre-jesta-steemtools-automatic-failover-for-witness-nodes-20160924t094435282z
categorywitness-category
json_metadata{"tags":["witness-category"]}
created2016-09-24 09:44:36
last_update2016-09-24 09:44:36
depth1
children2
last_payout2016-10-25 10:23:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length461
author_reputation94,800,257,230,993
root_title"[steemtools] automatic failover for witness nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id1,345,632
net_rshares0
@jesta ·
> So the whole concept, in my opinion, should be scrapped. False attribution is the only crime that connects with this, it is clearly fraud.

The whole concept of licensing is what you're talking about right? 

I got a bit lost in your train of thought :)
👍  
properties (23)
authorjesta
permlinkre-l0k1-re-jesta-steemtools-automatic-failover-for-witness-nodes-20160924t165632003z
categorywitness-category
json_metadata{"tags":["witness-category"]}
created2016-09-24 16:56:30
last_update2016-09-24 16:56:30
depth2
children1
last_payout2016-10-25 10:23:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length255
author_reputation140,605,453,893,072
root_title"[steemtools] automatic failover for witness nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id1,348,133
net_rshares8,819,762,721
author_curate_reward""
vote details (1)
@l0k1 ·
It is predicated on a claim of exclusive rights distribution for something that costs practically nothing to reproduce, in a market where subjectivity dictates price more clearly. Art can be expensive to produce but worth nothing because nobody wants it. 

And more importantly, it does not benefit new artists who by definition are generally poor. Owning copyright is not bound to the creator, and this overly empowers them to suppress competition and which artists get access to their distribution system and by this allows censorship.

Thus, copyright is not for artists at all, but for curators. The internet renders the need for these distribution controllers. Artists do not depend on these businesses anymore and the privilege has been blatantly abused for political ends. In fact, this is why citation is such an integral component of Steem's architecture, and why the greatest amount of changes have been made to counter methods of exploiting it.
properties (22)
authorl0k1
permlinkre-jesta-re-l0k1-re-jesta-steemtools-automatic-failover-for-witness-nodes-20160924t165632003z-2016924t201814751z
categorywitness-category
json_metadata{"tags":"witness-category"}
created2016-09-24 17:18:18
last_update2016-09-24 17:18:18
depth3
children0
last_payout2016-10-25 10:23:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length955
author_reputation94,800,257,230,993
root_title"[steemtools] automatic failover for witness nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id1,348,318
net_rshares0
@liberosist ·
Thank you for sharing this! I'm sure this will help a lot of witnesses sleep well. :)
properties (22)
authorliberosist
permlinkre-jesta-steemtools-automatic-failover-for-witness-nodes-20160924t083913228z
categorywitness-category
json_metadata{"tags":["witness-category"]}
created2016-09-24 08:39:21
last_update2016-09-24 08:39:21
depth1
children0
last_payout2016-10-25 10:23:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length85
author_reputation177,167,275,265,899
root_title"[steemtools] automatic failover for witness nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id1,345,326
net_rshares0