Alright so script has been updated. Until the latest pull request is approved it can be grabbed from
https://github.com/gileadmcgee/python-graphenlib/scripts/switch-keysI figured I would type up some documentation about it. All of this will undoubtedly change. I will try to remember to come back here and delete or update this when it does but I can't make any promises.
The script is designed to:
close any screens named witness or wallet #we dont want extra screen open
pkill witness_node # two wallets running off of the same config.ini == bad
open a detached screen with a witness_node running inside it ## with --replay-blockchain flag
wait 3 minutes for that witness to be ready to accept rpc calls
open a detached screen with a cli_wallet running inside it
unlock the wallet
watch for missed blocks and if your witness misses a block switch the signing key of the witness to a different key
keep track of how many blocks have been missed recently and switch to an emergency signing key if all primary keys miss two full rotations.
if emergency keys miss blocks switch back to primary keys
if emergency keys sign blocks still try to switch back every 600 blocks (roughly 30 minutes)
If your node crashes or witness production falls below 50% kill the screens and start over.
if three launches of witness_node --replay-blockchain doesn't fix your problem try a --resync-blockchain
restarting below 50% production has never been tested.
--resync-blockchain after three crashes does not appear to be currently working. It will just keep --replaying
You must launch with a config.py in the same directory as the switch.py programs. This is the current example-config.py
### this is very experimental code, it has barely been tested and I don't really even know what I am doing.
### Use it with caution and at your own risk. It seriously might not work right.
### It will kill any running instance of witness_node and relaunch witness_node in a new screen named witness
### there is a delay between launching the witness_node and launching the cli_wallet. This is to give your witness node enough time to open up and get ready to accept the connection
### from your cli_wallet. It is currently set to 3 minutes for a --replay and 5 minutes for a --resync. You can modify these wait times on lines 27 and 82 of switch.py
# the name of your witness as string
witnessname = "dele-puppy"
# the password of your wallet as string
wallet_password = "puppiesRkewl" # not really my password. Just left in so people can see how it should look.
# the public keys you would like to switch between must have at least two. Can list the same key twice if needed
publickeys = ("BTS6v1yYVgrvrMV8XsThUT6f7YtyoSxYaec1qcthbA6sU9Xtps7fi","BTS73UhnE6uD8Axdp3cU8EmvjjaFuiAAPRwARqrgRY1vZkJLFYo4u","BTS5gH5wokGkbhcZZpxLEc884xNby3HAkiEo39bMXZ4b2AvNuSWni")
# How many missed blocks to wait for until switching to new key.
# very little testing has been done with any value other than 1
strictness = 1
# public keys you would like to use in case of emergency. Set to 0 if you do not want to use emergency keys.
# if keys are used, must enter at least two. Can list the same key twice if needed.
emergencykeys = 0
# the full path to your witness_node binary including binary name
path_to_witness_node = "/home/user/src/bitshares-2/programs/witness_node/witness_node"
# The full path to your data directory
path_to_data_dir = "/home/user/src/bitshares-2/programs/witness_node/witness_node_data_dir"
# rpc host and port
rpc_port = "127.0.0.1:8092"
# the full path too your cli_wallet binary including binary
path_to_cli_wallet = "/home/user/src/bitshares-2/programs/cli_wallet/cli_wallet"
# the full path to your wallet json including json file.
path_to_wallet_json = "/home/user/src/bitshares-2/programs/cli_wallet/wallet.json"
I left my command in whenever possible so people could see what it should look like.
If you would like to run this on a single node for the crash and fork protection I would suggest launching your witness_node with only a single public private key pair and just using that public key twice in the config.py So for example if my witness signing key was BTS6v1yYVgrvrMV8XsThUT6f7YtyoSxYaec1qcthbA6sU9Xtps7fi my config.py could look like
publickeys = ("BTS6v1yYVgrvrMV8XsThUT6f7YtyoSxYaec1qcthbA6sU9Xtps7fi","BTS6v1yYVgrvrMV8XsThUT6f7YtyoSxYaec1qcthbA6sU9Xtps7fi")
The script will still attempt to switch between these keys when your witness misses a block, and there is a fee associated with that. I will find a way to turn different features on and off in the future.
Oh, and the witness node is not currently set to launch with any parameters outside of --replay-blockchain and the data directory. Everything else must be in your config.ini
Let me know if you have any questions, and I will try to answer them. If you have any feedback or advice I would appreciate it. I am just learning to script.