This originally was posted on zcash forum and the thread there has more Q&A's, so check out ... maybe you can find an answer to already asked questionshttps://forum.z.cash/t/set-up-your-own-private-stratum-pool/9043I thought I'd share with you all what I have learned in building a privet (or if you want public) zec pool. I pursued this in hope that maybe if can build my own farm, I will have it work on my own private pool, instead of using a public pool.
The core of the pool (and 90% of what I will write) is from eXtremal-ik7 work
https://github.com/eXtremal-ik7/pool_frontend_zcash, but I had a lot of help from the zog team, who helped me to get it to work (and I'm waiting for my first block to show my appreciation
)
I used ubuntu 16.04 server edition to set it up, and it has 4GB ram right now, and that's it.
If you think this was useful for you, you can always send a few to my ZEC addr: t1eYeHJKV6Ku9VzadpS8p1LDBeYXqQtRjvw
)))
So, here it goes:
- install ubuntu server and get it updated:
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
- install a few dependencies (mainly Zcash's)
sudo apt-get install cmake libssl-dev libsodium-dev libpcre3-dev libleveldb-dev libboost-all-dev libgmp-dev libprotobuf-dev protobuf-compiler libjansson-dev screen build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake
- create a dir for your installation, and lets assume you are in your home folder named <user>, so you should be now in /home/user, and you will create ZEC as your installation folder
now start with eXtremal-ik7 guide
git clone https://github.com/zcash/zcash
git clone https://github.com/config4star/config4cpp
git clone https://github.com/google/flatbuffers
git clone https://github.com/eXtremal-ik7/libp2p -b version/0.3
git clone https://github.com/eXtremal-ik7/poolcore
git clone https://github.com/eXtremal-ik7/pool_frontend_zcash
git clone https://github.com/eXtremal-ik7/poolrestapi
git clone https://github.com/eXtremal-ik7/ngxrest
git clone https://github.com/eXtremal-ik7/pooljs
wget https://nginx.org/download/nginx-1.11.5.tar.gz
tar -xzf nginx-1.11.5.tar.gz
- although it doesn't say so in the steps, but it seems that you need to compile zcash first before going forward, so you that :
- create zcash.conf file (put your rpcuser name instead of "user")
mkdir -p ~/.zcash
echo "addnode=mainnet.z.cash" >~/.zcash/zcash.conf
echo "rpcuser=user" >>~/.zcash/zcash.conf
echo "rpcpassword=head -c 32 /dev/urandom | base64" >>~/.zcash/zcash.conf
- then build zcash
cd zcash
./zcutil/fetch-params.sh
./zcutil/build.sh -j$(nproc)
- now move back and start configuring the rest of the parts (make sure you replace <user> with your user's home dir name):
cd ..
cd config4cpp
make -j4
cd ..
cd flatbuffers
mkdir build
cd build
cmake ..
make -j4
sudo make install
cd ../..
cd libp2p
mkdir x86_64-Linux
cd x86_64-Linux
cmake ../src
make -j4
cd ../..
cd poolcore
mkdir x86_64-Linux
cd x86_64-Linux
cmake ../src -DROOT_SOURCE_DIR=/home/user/ZEC -DZCASH_ENABLED=1
make -j4
cd ../..
cd pool_frontend_zcash
mkdir x86_64-Linux
cd x86_64-Linux
cmake ../src -DROOT_SOURCE_DIR=/home/user/ZEC
make -j4
cd ../..
cd poolrestapi
mkdir x86_64-Linux
cd x86_64-Linux
cmake ../src -DROOT_SOURCE_DIR=/home/user/ZEC
make -j4
cd ../..
- now you are back at /home/user, lets create the nginx folder and compile it
mkdir nginx
cd ZEC/nginx-1.11.5
./configure --prefix=/home/user/nginx --add-module=/home/user/ZEC/ngxrest
make -j4
make install
cd ..
- next you need to patch zcash and recompile it
cd zcash
patch -p0 < /home/user/ZEC/pool_frontend_zcash/pool.diff
- next you need to edit the Makefile in both zcash root folder & in zcash/src folder (i use nano to edit it)
- open each file and search (in nano its ctrl+w) for
- and replace it (or append to the end of the line) and save it (ctrl-x then y)
LIBZCASH_LIBS = -lsnark -lgmp -lgmpxx -lboost_system-mt -lcrypto -lsodium -fopenmp -L/home/user/ZEC/poolcore/x86_64-Linux/zcash -lpoolrpczcash -L/home/user/ZEC/libp2p/x86_64-Linux/p2p -lp2p -L/home/user/ZEC/libp2p/x86_64-Linux/asyncio -lasyncio-0.3 -lrt
- then build zcash again
- now comes the tricky parts
- you need to move some files into the right locations and to make things easy I put mine in the ./zcash folder </home/user/.zcash>
- so move into that folder and create the following:
cd /home/user/.zcash
nano poolrestapi.cfg
- add the following:
poolrestapi {
listenAddress = "cxxrestapi://127.0.0.1:19999";
coins = ["zec"];
}
zec {
frontends = ["p2p://127.0.0.1:13301"];
poolAppName = "pool_frontend_zcash";
}
- next file
- add the following: (add your own created z & t addr) i added 2 different t-addr for poolFeeAddr & pool_taddr
pool_frontend_zcash {
isMaster = "true";
poolFee = "1";
poolFeeAddr = "t1Lbnzr5Jtykyjvm8JRDAnUTxxxxxxxxxxxx";
walletAddrs = ["p2p://127.0.0.1:12201"];
localAddress = "p2p://127.0.0.1:13301";
walletAppName = "pool_rpc";
poolAppName = "pool_frontend_zcash";
requiredConfirmations = "10";
defaultMinimalPayout = "0.01";
dbPath = "/home/user/pool.zcash";
keepRoundTime = "3";
keepStatsTime = "2";
confirmationsCheckInterval = "7";
payoutInterval = "30";
balanceCheckInterval = "3";
statisticCheckInterval = "1";
zmqclientHost = "192.168.1.120";
zmqclientListenPort = "6668";
zmqclientWorkPort = "60200";
pool_zaddr = "zcG47QGy8g2md2uUg6dtQBKgT75hz4bJ1974rmdxxxxxxxxxxxxxxxxxxxxx";
pool_taddr = "t1UrNsXAQjrDKpwovMs5xxxxxxxxxxxx";
}
- also change the zmqclientHost to your local
- next file is the nginx config file so move to the nginx folder:
cd /home/user/nginx/conf
nano nginx.conf
- if the file exists, back it up and create a new one:
mv nginx.conf nginx.conf.back
nano nginx.conf
- add the following
worker_processes 4;
events {
worker_connections 10240;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
upstream api_backend {
server 127.0.0.1:19999;
keepalive 32;
}
server {
listen *:80 reuseport;
server_name pool;
location / {
root html;
index index.html index.htm;
expires 5s;
}
location /api {
cxxrest_pass api_backend;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
expires 3d; # 3 days
}
}
}
- now copy the actual frontend to its location in nginx
cd /home/user/ZEC/pooljs/coins-for-all/webapp
cp -r /home/user/ZEC/pooljs/coins-for-all/webapp/* /home/user/nginx/html
- edit the coins.json file
cd
nano /home/user/nginx/html/static/f/coins.json
- make it the following:
[
{
"title": "Z-Cash",
"code": "ZEC",
"desc": "Z-Cash Private Mining",
"icon_url": "static/i/zcash.png",
"block_url": "https://explorer.zcha.in/blocks/:hash",
"transaction_url": "https://explorer.zcha.in/transactions/:txid",
"power": {
"type": "SOLS",
"name": "sols/s",
"rate": "sols rate"
}
}
]
- rename or copy a few files to match the "ZEC" changes
mv /home/user/nginx/html/static/s/templates/zcash-description.html /home/user/nginx/html/static/s/templates/zec-description.html
mv /home/user/nginx/html/static/s/templates/zcash-mining.html /home/user/nginx/html/static/s/templates/zec-mining.html
mv /home/user/nginx/html/static/s/templates/zcash-servers.html /home/user/nginx/html/static/s/templates/zec-servers.html
- time to build the frontend
cd ZEC/pool_frontend_zcash
cd x86_64-Linux
make clean
cmake ../src -DROOT_SOURCE_DIR=/home/user/ZEC
make -j4
cd ../..
- and all you have to do is run it
- first run, you have to get zcash to sync all blocks, so do that
/usr/bin/screen -dmS "zecnode" ./ZEC/zcash/src/zcashd
- once updated and all synced ... stop zcashd and re-run everything
- i made a script to run all parts:
- add the following:(there was an error here because of the editor uses '#' as char for bold ... sorry )
#!/bin/bash
echo "starting up ZEC Pool"
echo "Starting ZEC node"
/usr/bin/screen -dmS "zecnode" ./ZEC/zcash/src/zcashd -p2pport=12201
echo "Starting Frontend"
/usr/bin/screen -dmS "zecpool" ./ZEC/pool_frontend_zcash/x86_64-Linux/pool_frontend_zcash ~/.zcash/zcash.cfg
echo "Starting Rest API"
/usr/bin/screen -dmS "zecapi" ./ZEC/poolrestapi/x86_64-Linux/poolrestapi ~/.zcash/poolrestapi.cfg
echo "Starting Nginx"
sudo nginx/sbin/nginx
and voila ... you should have a running zec stratum pool !!!
so if you find this all insightful and helpful, you can always show that to:
eXtremal:[by mining on his pool
http://coinsforall.io (i was trying to locate his zec addr !! or btc for that matter)
zogteam: also by mining their pool
http://zogpool.org/ or their newly luck / solo pool
http://luckpool.org or directly to t1PGgRgVQ14utsD7mp2dzGdykTDFUCKzPQ5
also they released a fork of eXtremal's - ZogPool Source
https://github.com/Zogpoolor
myself: t1eYeHJKV6Ku9VzadpS8p1LDBeYXqQtRjvw
in all cases, if i get anything off this guide, i will make sure to pass third & third to them
))
also, this thread has been going on for a few days on zcash forum
https://forum.z.cash/t/set-up-your-own-private-stratum-pool/9043 and you find more info there!!