[Guide]: Setting up a Muse Witness Server

in #muse7 years ago (edited)

If you want to learn more about Muse Blockchain, click here!


HF1 of the Muse Blockchain is now around the corner! How about a guide to set up your own witness server? Parts of this guide were taken from the Muse Blockchain github page, some other parts were taken from @roelandp's instructions on Muse Slack and some other parts are my own while setting up my witness. Note: There are more optimal ways to config your witness. I'm writing this guide using a logical way, so it may take you a couple of minutes longer and a few more restarts.

Mistakes were made! :P I updated the rpc-endpoint part of the post, so take a look

Requirements

You need a big server to make it future proof. I would suggest getting one with at least 16GB of RAM. Right now HDD/CPU is somewhat irrelevant, but my server has a Quad Core Xeon L3426 @ 1.8Ghz and 2x1TB 15k Drives in RAID1. Of course, you need a great network speed with low latency!

You can get a VPS for starters, to familiarise yourself. You can even keep this VPS in production if you have dedicated CPU cores, but contact your provider first!

Also, do not log in as root! Disable root logins, change SSH port and make your server as secure as possible (if you don't know how, read my Basic Server Security series)

Operating System

Because we need a system that we will not be reformatting every now and then, we need a linux distro with long time security updates. Right now the way to go is Ubuntu 16.04 (for me. if you are familiar with rolling release distros, that's the way to go!)

Installing the needed packages

We will be compiling the Muse Blockchain Daemon (mused), that will be syncing & signing the blocks, so we have to install a basic set of utilities.

Let's start with updating our system to make sure we are 100% up to date!

sudo apt-get update
sudo apt-get upgrade

Then we install the basic set of utilities we will need to compile everything!

sudo apt-get install build-essential autotools-dev automake autoconf libtool make cmake checkinstall realpath gcc g++ clang flex bison doxygen gettext git qt5-default libqt5svg5-dev libreadline-dev libcrypto++-dev libgmp-dev libdb-dev libdb++-dev libssl-dev libncurses5-dev libboost-all-dev libcurl4-openssl-dev python-dev libicu-dev libbz2-dev screen

Ubuntu 16.04 comes with an incompatible version of BOOST (libboost), which will be installed while running the previous command. As soon as the installation finishes, we will remove it, and install a compatible version (which is 1.60).

Installing a compatible BOOST version (1.60)

First, we remove the old libboost version:

sudo apt-get remove libboost-all-dev
sudo apt-get autoremove

and then we download and compile the one we want:

mkdir -p ~/dev/third-party
cd ~/dev/third-party
rm -rf boost_1_60_0* boost-1.60.0*
wget https://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz
tar xvf boost_1_60_0.tar.gz
mkdir boost-1.60.0_prefix
cd boost_1_60_0
export BOOST_ROOT=$(realpath ../boost-1.60.0_prefix)
./bootstrap.sh --prefix=$BOOST_ROOT
./b2 install
cd ..
rm -rf boost_1_60_0 boost_1_60_0.tar.gz

This will take a while, so go grab a cup of coffee or tea.

Preparing the blockchain code

We have installed git on the first step and we will now use it to download the blockchain source code:

git clone https://github.com/themuseblockchain/Muse-Source.git --branch HF_1

Notice the HF_1 at the end. We will install the HF_1 version of Muse Blockchain. If we don't specify a branch, we will get the previous version

As soon as the source code is downloaded, we need to download all the dependencies. It's not hard, it's 2 commands for you:

cd Muse-Source/
git submodule update --init --recursive

When it finishes, we need to make a change in the source of a dependency. It took me a while to get this right the first time (because I couldn't find the file :P ), but it's easier than it seems.

nano libraries/fc/vendor/websocketpp/websocketpp/transport/asio/endpoint.hpp

Now, locate this line (it's on line 38):

#include <websocketpp/common/functional.hpp>

and just above it add the following line:

#include <websocketpp/common/asio.hpp>



Then locate this line (it's on line 95):

, m_listen_backlog(0)

and change it to read like this:

, m_listen_backlog(lib::asio::socket_base::max_connections)

Save and exit.

Compiling & configuring the Muse Blockchain source

Compile the code running these two lines:

cmake -DBOOST_ROOT="$BOOST_ROOT" -DBUILD_MUSE_TEST=OFF -DENABLE_CONTENT_PATCHING=OFF -DLOW_MEMORY_NODE=ON -DCMAKE_BUILD_TYPE=Release .
cmake --build . --target all -- -j$(nproc)

You need at least 4GB of RAM to make this happen! You've been warned!

Once again, it will take a while (a lot longer than in the Boost section).

Now, start the muse daemon to create the default config file:

cd programs/mused/
./mused

in a couple of seconds, just stop the daemon (by pressing Control+C). Now, open the config file:

nano witness_node_data_dir/config.ini

and at the top paste these lines:

# Muse Blockchain Seed Nodes
seed-node = muse.cervantes.one:33333
seed-node = 138.197.68.175:33333
seed-node = muse.roelandp.nl:33333
seed-node = muse-seed.altcap.io:33333
seed-node = muse.riverhead.ltd:33333
seed-node = 45.76.192.171:33333
seed-node = 104.199.134.87:33333
seed-node = seed.muse.blckchnd.com:33333
seed-node = muse-seed.lafona.net:33333
seed-node = 116.62.121.169:33333
seed-node = muse.thetimsaid.com:33333
seed-node = muse.agoric.systems:33333
seed-node = 45.79.206.79:33333
seed-node = 88.198.90.17:33333
seed-node = muse-seed.pt-kc.net:33333
seed-node = seed.musenodes.com:33333
seed-node = 5.9.18.213:33333

List taken from MuseNodes.com

Also, locate these lines:

# Endpoint for websocket RPC to listen on
# rpc-endpoint =

and change them to read like this:

# Endpoint for websocket RPC to listen on
rpc-endpoint = 127.0.0.1:8090

(find a local IP of your server, and replace 127.0.0.1 with it, although in 99% of the cases this will work)

save and exit.

Starting up Mused

We now have to start mused to sync the blockchain before configuring our witness details. We will be using "screen" to make it run even after we close our terminal instance and also while we work on our server. Issue these 2 commands one at a time (don't copy/paste altogether to save time, you may not have the result we need)

screen
./mused

When you get to the point where a message like this appears (the blocks number will be different), your witness server is fully synced:

1635731ms th_a main.cpp:186 main ] Started witness node on a chain with 2466202 blocks.

Press control+a and then control+d to detach the screen instance and allow the muse daemon run in the background while we add the final touches.

Configuring a wallet

Right now, if you followed my instructions line by line, you are in folder ~/dev/third-party/Muse-Source/programs/mused. Issue these commands to start a cli wallet instance:

cd ../cli_wallet
./cli_wallet

You will see lines like this coming up:

Logging RPC to file: logs/rpc/rpc.log
Starting a new wallet
2559524ms th_a main.cpp:159 main ] wdata.ws_server: ws://localhost:8090
2559525ms th_a main.cpp:164 main ] wdata.ws_user: wdata.ws_password:
2559526ms th_a websocket_api.cpp:88 on_message ] message: {"id":1,"result":true}
2559527ms th_a websocket_api.cpp:88 on_message ] message: {"id":2,"result":0}
2559528ms th_a websocket_api.cpp:88 on_message ] message: {"id":3,"result":2}
Please use the set_password method to initialize a new wallet before continuing
2559529ms th_a thread.cpp:95 thread ] name:getline tid:140496290703104
new >>>

You should password-protect your wallet, as it will be holding all your private keys.

set_password mysupersecurepassword
unlock mysupersecurepassword

Everytime we open our cli_wallet, we will have to type the "unlock ..." line to gain access, so don't forget this password

Now, type suggest_brain_key and you'll get this as a reply:

suggest_brain_key
{
"brain_priv_key": "REVEL TAYER DELIME JOYHOP UNIPOD SCALENE RADISH ANHIMA ROBERD KUTCHA BINGE HAGBORN FIBERED SITFAST CREPY INRING",
"wif_priv_key": "5JtGRN5gAdPAdpcqF76Ux1KD46a3cNWQYfkEqXY1qdsHQdFUfY7",
"pub_key": "MUSE7p3JEw6Zu7rRJjro62AQKEa2TgeQEfLiMAFo45f9QMMqTAtjUk"
}

Keep those somewhere safe, you'll need them!

Now, go to your Muse wallet at https://wallet.museblockchain.com, go to "Permissions" tab and get your active private key (starts with a 5...)

and on your cli_wallet import the key:

import_key 5...

Also, I had to import the "wif_priv_key" from the "suggest_brain_key" to make it work properly. Do it using the "import_key" command.

now type list_my_accounts. You should be seeing a few lines, and one stating your Muse blockchain username:

dimitrisp 0.000000 2.28.0 127669.031756 2.28.1 0.000000 2.28.2

You were successful in creating your witness wallet and associating with your blockchain account!

Final configuration

Now we have to make 2 final changes on our config.ini file. Follow these commands:

cd ../mused
nano witness_node_data_dir/config.ini

and locate these lines:

# name of witness controlled by this node (e.g. initwitness )
# witness =

# WIF PRIVATE KEY to be used by one or more witnesses or miners
# private-key =

On "witness" add your username at the end inside quotes. On private-key, enter the "wif_priv_key" from the "suggest_brain_key" command. Also, remove the hashtags from the beginning of those lines. So, in my example they have to look like this:

# name of witness controlled by this node (e.g. initwitness )
witness = "dimitrisp"

# WIF PRIVATE KEY to be used by one or more witnesses or miners
private-key = 5JtGRN5gAdPAdpcqF76Ux1KD46a3cNWQYfkEqXY1qdsHQdFUfY7

Save and exit nano.

Restarting the Muse Daemon to re-read our changes

We have the daemon running in the background. Now we need to restart it. First we have to attach our terminal to the screen instance our mused is running:

screen -r

and then press control+c to stop it. Then, we have to start it again:

./mused

As soon as you see


initminer public key: MUSE75fnamVHSMV67JaRPSKbCr8vDwGoCEDeDky8e78JJbNEYcbqv1
chain id: 1459ad9469d36835dbfda0d84ea7700fb6a3ee767c86c4f75de22fa0c40f6c61


...
87002ms th_a witness.cpp:94 plugin_initialize ] _witnesses: ["dimitrisp"]
87026ms th_a witness.cpp:109 plugin_initialize ] witness plugin: plugin_initialize() end
87026ms th_a main.cpp:169 main ] starting node
...
88574ms th_a witness.cpp:121 plugin_startup ] Launching block production for 1 witnesses.
88574ms th_a witness.cpp:132 plugin_startup ] witness plugin: plugin_startup() end
...
88574ms th_a main.cpp:186 main ] Started witness node on a chain with 2466885 blocks.

If you are not seeing block syncing messages, you are good to go! Control+A and then Control+D to send "screen" to the background.

Running update_witness

Now that everything is good to go, we should announce our intend to witness blocks to the network. We'll do it through cli_wallet (that's what I meant "more optimal ways". the final few steps could be "compressed", but I like having them seperated, more clarity for my OCD!)

cd ../cli_wallet
./cli_wallet
unlock mysupersecurepassword

Before we enter the command, let's take a look:

update_witness "username" "witness_url" "pub_key" {} true

this is the most basic format of the command. Substitute "username" with your username, "witness_url" with a page where people can learn more about you, and "pub_key" with the pub_key from "suggest_brain_key". In this example, the final format would be:

update_witness "dimitrisp" "https://steemit.com/muse/@dimitrisp/witness-declaration-dimitrisp-witnesses-muse-blockchain" "MUSE7p3JEw6Zu7rRJjro62AQKEa2TgeQEfLiMAFo45f9QMMqTAtjUk" {} true

Get witness votes

You now need people to give you witness votes from the Muse Blockchain Wallet! As soon as you get your votes, you should be signing blocks!


If you come across any errors, feel free to let me know, or ask the awesome people on the Muse Slack (there's a link in the Muse Wallet)


Other useful links:

Check your witness rank at muse-db.com
Create your Muse Wallet at wallet.museblockchain.com

Final step: Vote for me!

If you are a MUSE stakeholder or a MUSE witness and you found this guide helpful please consider casting your vote for dimitrisp

If you are voting in cli_wallet, vote_for_witness YOURACCOUNT dimitrisp true true

You can read my Muse Witness declaration here


Also, please consider voting me, dimitrisp, for a witness here on Steemit too!

You can read my Steemit witness declaration here

Sort:  

Good guide, I am curious however why the dependency for websocketio was changed in this guide and hasnt needed to be in the past.

I took that part from @roelandp's instructions. I tried to "ignore" it but it wouldn't compile for me (I was trying to avoid searching for the file, because reasons :P)

After changing the source it went through correctly. It might have been random though, I can't tell..

Yea I didnt need it for my compile you might be linking boost wierd that might be why.

This is only needed if you have a kernel version on your machine bigger than some version (i forgot is on the github). Which is causing any of the Graphene chains running on that machine to give Timer.expired errors when trying to connect to local websocket using the cli_wallet app. This code you manually overwrite here is fixed in future versions of websocketpp.

Note changing or not changing this is not of influence for compiling, so that certainly has been something else. Additionally I think a changed version of websocketpp might have been manually included already in the Mused github, but not sure.

Thank you so much! I updated my muse node!

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63061.76
ETH 2602.70
USDT 1.00
SBD 2.75