Wolf's Witness Essentials - Witness Watcher & Pricefeed

in #witness6 years ago (edited)

witness_essentials.png


Essentials Scripts for STEEM Witnesses - written in Typescript.


I'm very excited to introduce Wolf's Witness Essentials. A project containing scripts, which kind every Witness uses, brought to the next level!

Github: https://github.com/therealwolf42/witness-essentials


Witness Watcher

Witness Watcher is a script, that watches for missed blocks of your witness.

In case of a missed block, the witness signing-key gets changed in order to either fall-back to another server or to disable the witness.

Features

  • Active-Key can be saved in an encrypted format instead of plaintext inside .env (doesn't work with PM2, but with multiplexers - e.g. tmux)

  • Keys can be rotated for a number of rounds or endlessly. For example, if you have 3 different servers, if all of them fail after another, instead of disabling the witness, the first server gets chosen again - until the number of rounds have been reached, in that case the witness would be finally disabled.

  • You can enable alerts for missed blocks via SMS (NEXMO & TWILIO) and EMAIL (GMAIL).

  • RPC-Failover

  • Written in Typescript

  • [Good-To-Know] Disabling of the witness wasn't possible for many months due to a bug in the steem-js and dsteem node-modules. After @netuoso created a PR, which solved this problem - @drakos made me aware of this fix and I created a npm-module called steem-js-witness-fix, which supports disabling of the witness. For now, Witness Essentials will use that plugin until it gets implemented in the official steem-js release.


Pricefeed

Pricefeed is a script that gets the current STEEM-price of major exchanges and publishes the pricefeed for your witness.

Features

  • Active-Key can be saved in an encrypted format instead of plaintext inside .env (doesn't work with PM2, but with multiplexers - e.g. tmux)

  • 4 major exchanges supported - Bittrex, Binance, Huobi, Upbit.

  • RPC-Failover

  • Written in Typescript


Info

Both scripts have been tested and are working, but I'm taking no responsibilities for any bugs. Please review the source-code yourself.


Getting Started

Both scripts use the same config-files.

Setup

First off, make sure you have npm/yarn & node installed. Then:

1.) Clone Repository

git clone https://github.com/therealwolf42/witness-essentials.git
cd witness-essentials

2.) Install dependencies

yarn / npm i

3.) Copy config.json from config.example.json

cp config.example.json config.json

4.) Edit config.json

nano config.json

You will get notified if any required fields are missing when running the scripts.

{
  "RPC_NODES": [
    "https://api.steemit.com",
    "https://steemd.privex.io",
    "https://gtg.steem.house:8090",
    "https://rpc.buildteam.io",
    "https://steemd.minnowsupportproject.org"
  ],
  "WITNESS": "", // add your witness account-name here
  "TEST_MODE": false, // changing this to true, will result in no witness-update changes or alerts
  "ENABLE_ENCRYPTION": false, // Encryption doesn't work with PM2. Use tmux for that.
  "EXCHANGES": [
    "bittrex",
    "binance",
    "huboi",
    "upbit"
  ],
  "PEG": 1,
  "INTERVAL_FEED": 60,
  "INTERVAL_WATCHER": 10,
  "BACKUP_KEYS": [ // add your backup-keys here - e.g. "5JZ52MJF...","6TSF24FS..."
  ],
  "MISSED_BLOCKS_THRESHOLD": 1,
  "USE_SMS_ALERT": true,
  "SMS_PROVIDER": "nexmo|twilio", // choose nexmo or twilio
  "USE_EMAIL_ALERT":true,
  "EMAIL_TO":"",
  "EMAIL_FROM":"",
  "ALERT_AFTER_EVERY_MISSED": true,
  "ROTATE_KEYS": false, // rotate between your current signing & backup-keys
  "ROTATE_ROUNDS": 1 // -1 is endless
}

5.) Create an .env file (touch .env) with the following variables, but without the comments.

API_KEY= // API Key for NEXMO or TWILIO
API_SECRET= // API Secret for NEXMO or TWILIO
PHONE_NUMBER= // Incl. country-code: e.g. 49123456789 (+49 would be Germany) - required for both NEXMO and TWILIO
FROM_NUMBER= // Only required for TWILIO
ACTIVE_KEY= // Only required if you don't want to use the encryption feature
ENCRYPTED_ACTIVE_KEY= // You will get an encrypted key after you started either Witness Watcher or Pricefeed for the first time
GOOGLE_MAIL_ACCOUNT= // Email Account where emails are getting send from - required if you want to use Email Alerts with GMAIL
GOOGLE_MAIL_PASSWORD= // Same as above

Starting

Witness Watcher

yarn run watcher

Or with PM2 (keep in mind that encryption doesn't work with PM2 due to the missing functionality for readline)

pm2 start npm --name=watcher -- run watcher
pm2 save
pm2 logs watcher

Pricefeed

yarn run pricefeed

Or with PM2 (keep in mind that encryption doesn't work with PM2 due to the missing functionality for readline)

pm2 start npm --name=pricefeed -- run pricefeed
pm2 save
pm2 logs pricefeed

Test SMS

yarn run test_sms

Test EMAIL

yarn run test_email

Questions or Feedback?

Please let me know in the comments below if you have any questions or feedback!


Have you voted for me yet?

If you believe that I'm a trustworthy witness - then please consider voting for me. Either through a click on the image below or at: https://steemit.com/~witnesses

Sort:  

Thanks. It's great to know how other witnesses solve the same problems. :)

One quick note about utopian compatibility:

Your witness vote request at the end of post, almost takes all my screen on my Macbook.

Even though, this is not strictly forbidden, we have a note on our guidelines for this:

Asking for Steem witness votes in a disruptive way

Which we expect a small text or link for the self-witness promotion.

Other than that, thanks for the quality contribution.


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thanks @emrebeyler.

I've made the footer & text a bit smaller :)

The key rotation rounds are a nice touch; good work~

Thanks crimson!

i'm no witness but this is cool stuff :)
thanks for sharing.

Thanks man!

Thanks for this! I've been interested in starting up my own nodes and trawling through loads of specific guides and versions that don't contain some of the info you've got here.

You're welcome, even though there isn't so much knowledge in this post. It's more a guide on how to use the Witness Watcher & Pricefeed scripts.

Hey man,

Off topic but - I'm trying to setup my first witness server; there is very little help for someone doing it first time. Anyways I have learned heaps, this is my 9th attempt. I finally got it to sync with SteemD after pre-downloading the block_log. But silly me I decided to Ctrl_C before the Steemd --replay finished...now when I run I get this crazy message blocklog excetin cannot reindex an empty chain...Oh man I don't want to have to download the whole block_log and start again..any ideas how to save me? I'm asking around but so far no luck.. Cheers.

Hey @lordnigel,

I'm not sure where the problem is, but I've seen that you've asked for help on steem.chat. Hope everything turned out well!

Thanks mate - not easy business being a witness. I'll keep learning and working at it. Cheers

Hey @therealwolf
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

@therealwolf Hello there. I use Smart Steem just as much as everyone else. I was wondering if I could be part of this amazing team. I was actually thinking to implement various GIF banners for the referral process. I mean, We only have one option that is provided by the website right? Everyone is bored of seeing the same old animation over and over again. Moreover, I can help in implementing various graphics that can be used for posts and all. Check out my profile to see my work and the various items I offer for free like banners and page dividers. Moreover, I can help with any other thing that is related to Steemit. Do get back to me on Discord(@kayyam09) or on Facebook(Surfraz M Umar Kayyam).

plz fellow me and upvoting me