Running a steem witness node on MacOS Mojave - Part 1, The Build.

in stemgeeks •  14 days ago  (edited)

I've been wanted to get a Steem witness node running on my home iMac for a while for testing purposes and to provide me with the option of using it as a temporary backup for the @c-squared witness that I run if required.

With the option of MIRA I believed it was possible without having to upgrade to 64GB of memory but I have always had a problem building the code. Even though Mac OS is effectively a flavour of Unix, the instructions for building on Linux do not work. There are some old instructions for building on Mac OS but these don't work either, especially with RocksDB running MIRA. I'm not sure anyone has gotten this working, I've certainly not been able to find any published instructions. I have finally managed to get the code built with the following instructions.

Instructions

Let's start with the standard stuff to get things installed and compiled on Mac OS.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Initialise Homebrew
brew doctor
brew update

Now onto some steem specifics.....

  • Install steem dependencies
brew install \
    autoconf \
    automake \
    cmake \
    git \
    boost160 \
    libtool \
    openssl \
    snappy \
    zlib \
    bzip2 \
    python3 \
    doxygen
    
pip install --user jinja2

Now you will want to set up some environment variables before doing the build. Below are the versions that I know work. You may find that the default versions installed by brew are not the correct ones. It is worth finding the location of your Brew Cellar before you do this just so you can check what versions are installed. Mine is installed in /usr/local/Cellar

Marks-iMac:bin mark$ brew --prefix
/usr/local

Do the exports

export BOOST_ROOT=$(brew --prefix)/Cellar/[email protected]/1.60.0/
# doesnt work - export OPENSSL_ROOT_DIR=$(brew --prefix)/Cellar/[email protected]/1.1.1c/
export OPENSSL_ROOT_DIR=$(brew --prefix)/Cellar/openssl/1.0.2s
export SNAPPY_ROOT_DIR=$(brew --prefix)/Cellar/snappy/1.1.7_1
export ZLIB_ROOT_DIR=$(brew --prefix)/Cellar/zlib/1.2.11
export BZIP2_ROOT_DIR=$(brew --prefix)/Cellar/bzip2/1.0.6_1 

Note that the latest version of openssl did not work with steemd so i had to run

brew install [email protected]

To get a version that worked.

It's definitely worth going through the versions here and checking that the versions on the environment variable above match what you have downloaded with Homebrew, and if they aren't get the proper version.

The above builds fine, but when you get to the final stage in the process, the final linking operation throws a wobbly thanks to some restrictions on Mac OS with linking the OpenSSL libraries from the above. For that reason, you need to add the following export to the list (assuming this is the location of your Mac OS openssl library)

export LDFLAGS="-L/usr/local/opt/openssl/lib/"

Now for some standard steem manual build stuff to get the code from the repo, check out the right version and create the build folder.

git clone https://github.com/steemit/steem
git checkout v0.22.1
git submodule update --init --recursive
mkdir build && cd build

The next command is slightly different from standard as you need to specify the BOOST_ROOT parameter

cmake -DBOOST_ROOT="$BOOST_ROOT" -DENABLE_MIRA=ON -DLOW_MEMORY_NODE=ON -DCMAKE_BUILD_TYPE=Release ..

This next bit took me a while to work out. When i was building the MIRA version, i was getting a load of errors like this.

Undefined symbols for architecture x86_64:

This appears to be caused by some kind of missing symbols tables in RocksDB that steem is looking for.

So I found this in the RocksDB documentation and thought i'd give it a go

# * DEBUG_LEVEL=0; this is the debug level we use for release. If you're
# running rocksdb in production you most definitely want to compile RocksDB
# with debug level 0. 

So running make with the following command builds steemd.

DEBUG_LEVEL=0 make -j$(sysctl -n hw.logicalcpu) steemd

and of course, cli_wallet

DEBUG_LEVEL=0 make -j$(sysctl -n hw.logicalcpu) cli_wallet

Then copy the executables to a local folder of your choice

mkdir ~/bin
cp programs/steemd/steemd ~/bin
cp programs/cli_wallet/cli_wallet ~/bin

Then run steemd to check the version

~/bin/steemd --version

Screenshot 20190909 at 18.51.26.png

TA-DAAAA, steemd built and running on Mojave.


I'm currently downloading a recent block_log which takes a while on a home internet connection. Once this is done, im going to be trying to get this running. I suspect that the replay may take a few days and I am going to have to have a play with Mac OS ulimits as apparently they can be pretty hard to change properly and are probably worth a post on their own.

Hope this helps people with Mac OS to get a witness built and up and running. Of course, i wouldn't suggest that you run a witness 24/7 on a personal Mac, but its definitely good for experimentation and development at home and possibly a temporary backup.

If you have any problems when you try this, be sure to drop me a message on discord or in the comments below.

Mark


image.png

@c-squared runs a community focused witness node.
Please consider voting for us here if you would like to support our witness operations.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Curious, what machine.
Which device?

Screenshot 20190910 at 07.19.08.png

Interesting... cuz, it's not a packed, fully loaded one.
Imagine if it was a MacPro

interesting, well researched. i'd be worried about that vulnerable openssl thou no?

Quite possibly yeah. Tried a load of recent versions and none of them would work though :(.

The linked SSL libraries are the MacOS ones however, so.....

I don’t know what half of this means, but I’m still impressed. tips hat

It's the matrix and stuff.


This post was shared in the Curation Collective Discord community for curators, and upvoted and resteemed by the @c-squared community account after manual review.
@c-squared runs a community witness. Please consider using one of your witness votes on us here

cool hopefully the replay goes ok. Nice work

To listen to the audio version of this article click on the play image.

Brought to you by @tts. If you find it useful please consider upvoting this reply.