Steemit mining - from zero to an optimized miner

in #steemd8 years ago

Earning steem is easy. Just post some content and get them. But can you also mine it?

Sure you can!

This introduction shows how to mine steem using steemd, and how to optimize mining performance.

Instructions are for Ubuntu 14.04 and above.


First step, install dependencies:

Update package list:

sudo apt-get update

Get required packages:

sudo apt-get install git cmake libssl-dev libncurses5-dev libreadline-dev doxygen build-essential dh-autoreconf lzip libbz2-dev


Steem requires Boost version 1.57 or newer. As Ubuntu only provides 1.55, we need to compile it ourself:

wget -O - http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz/download | tar -xz
cd boost_1_60_0
./bootstrap.sh --prefix=/usr/local
sudo ./b2 --with-iostreams -j 8 install

where 8 is the number of parallel tasks. Use your number of cores here.


Download and compile libgmp (This can also be installed using the package manager, but compiling yourself provides better performance):

cd
wget https://gmplib.org/download/gmp/gmp-6.1.1.tar.lz
lzip -d gmp-6.1.1.tar.lz ; tar -xf gmp-6.1.1.tar
cd gmp-6.1.1
./configure
sudo make -j 8 install


Get the steem repository:

cd
git clone https://github.com/steemit/steem


Get required submodules:

cd steem ; git submodule update --init --recursive


---

This is optional, but provides about 10% faster mining:


Apply miner patch:

wget -O - http://hastebin.com/raw/ikoqitolan | patch ./libraries/plugins/witness/witness.cpp


Apply GMP patch:

wget -O - http://hastebin.com/raw/femelanoga | patch libraries/fc/CMakeLists.txt

wget -O libraries/fc/CMakeModules/Findgmp.cmake http://hastebin.com/raw/efahohubim


---


Compile:

cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CONTENT_PATCHING=OFF -DLOW_MEMORY_NODE=OFF
make -j 8


Now run steemd and let it download the blockchain:

cd programs/steemd ; ./steemd --rpc-endpoint --seed-node="seed.steemed.net:2001" --seed-node="52.74.152.79:2001"


While it is downloading, start a second console and generate some keys:

cd; cd steem/programs/cli_wallet/
./cli_wallet


Depending on your cpu speed you need some keys, probably between 2 and 5. Generating more won't hurt.


suggest_brain_key
suggest_brain_key
..
suggest_brain_key
suggest_brain_key


until you have enough. Copy&paste them to some secure place.

What you'll need is the wif_priv_key.


When done, exit using Ctrl+C

Now edit ~/steem/programs/steemd/witness_node_data_dir/config.ini


What you need to add:

mining-threads = 8


(Depends on your total cpus/threads)


And add the keys you generated:

witness = "myLittleMiner0001"

miner = ["myLittleMiner0001","<wif_priv_key_1>"]

witness = "myLittleMiner0002"

miner = ["myLittleMiner0002","<wif_priv_key_2>"]

...


Save and restart steemd. Once the blockchain download is done, it will start mining.


Thats it! You are now mining VESTS.

Wait, what? I wanted to mine STEEM!


VESTS can be converted to STEEM, but they are converted over a 2 year period. For the conversion rate have a look at


https://steemd.com/


"steem_per_mvests"


Currently its 229.8, thats 229.8 STEEM per million VESTS.



Miner output explained:

1413275ms th_a       witness.cpp:426               on_applied_block     ] hash rate: 31431 hps  target: 30 queue: 105 estimated time to produce: 569 minutes


Your current hash rate is 31431 hashes/s. Difficulty is currently 30, that is a chance of 1/(2^30) to enter the mining queue. With my current hash rate thats on average on per 569 minutes.


The mining queue can be seen here:

https://steemd.com/witnesses


(Right side).


All those miners have generated a pow, once they do, they enter the mining queue at the bottom. When they reach top place, they are rewarded with VESTS.


Difficulty depends on the length of the mining queue. For every 4 miners difficulty raises by 1 (=doubles). Higher difficulty = less miners are able to enter, mining queue shrinks. This way it regulates itself.



Be aware that hardforks happen quite often. In this case you need to:

Stop steemd
cd ~/steem ; git pull
make -j 8
Start steemd


In case errors occur (can't append block, ...)

Try to add --replay-blockchain when starting steemd. This has always fixed it for me.


This is it. If you like please vote it up. I'll look here from time to time - if you have questions, feel free to ask.

Sort:  

The miner patch might also be useful for experienced miners. It provides some extra hashes on top of the gmp patch!

So this should work to get a Windows computer back up and mining? I got it mining a day before the back happened and haven't had any luck since. Just double checking to make sure this is still working?

This manual is for ubuntu, not sure if it will also work for windows. But yes, its still up to date, I'll update if something changes.

Awesome thank you. I'll see what I can get to work.

Thanks for doing this, but do you know if its working with 0.12.2?
Ive tried twice, but each time fails with:

--
collect2: error: ld returned 1 exit status
libraries/fc/CMakeFiles/all_tests.dir/build.make:505: recipe for target 'libraries/fc/all_tests' failed
make[2]: *** [libraries/fc/all_tests] Error 1
CMakeFiles/Makefile2:340: recipe for target 'libraries/fc/CMakeFiles/all_tests.dir/all' failed
make[1]: *** [libraries/fc/CMakeFiles/all_tests.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
--

Replying to me own question, the issue is Boost 1.60 and possibly the inclusion of "-with-iostreams" when making it. As your steps install it system wide, this also broke anything else I tried to compile which used boost. I really shouldnt have followed exactly what you wrote and continued building boost into its own folders and not /usr/local

Once I finally got around my now broken system boost libs everything started compiling again.

Congratulations @bu328284! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 3 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 64542.61
ETH 3460.20
USDT 1.00
SBD 2.51