HomeGuide

Setup Ethereum Mining Pool using open source ethereum pool

Setup Ethereum Mining Pool using open source ethereum pool

This a step by step guide on how to setup your own Ethereum Mining Pool. This guide is going over how to setup an ethereum pool using open source ethereum pool software. This is meant to setup a mining pool for a SINGLE CRYPTO CURRENCY. This is not a guide for a Multipool!!!!

If you want to see what it looks like before you set it all up, head to the http://myetherpool.org/ what to see more pool check this list

For this guide purpose we I will be using Ethereum Crypto Currency .

Requirements

 

Setup

At this point you should have your VPS started, putty up and running and your logged in as root.

 

Update Ubuntu

apt-get update
apt-get dist-upgrade

Setup SWAP

I am setting up a 4GB swap, which may be overkill but it’s the most common swap sized used in most guides so ill keep it at that.

 

dd if=/dev/zero of=/mnt/myswap.swap bs=1M count=4000
mkswap /mnt/myswap.swap
swapon /mnt/myswap.swap

 

Now let’s add it into fstab so it’ll activate at boot.

nano /etc/fstab

Add the following line at the end of the file.

/mnt/myswap.swap none swap sw 0 0

Ctrl+O to save, and Ctrl+X to exit the nano editor.

Now your swap is setup, you can modify the size in the future if you need more or less.

Install Required Packages

 

apt-get install git
apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev
apt-get install libboost-all-dev git npm nodejs nodejs-legacy libminiupnpc-dev redis-server
apt-get update
apt-get install libdb4.8-dev libdb4.8++-dev
apt-get install golang

 

Installing nginx

 

sudo apt-get update
sudo apt-get install nginx

Ethereum Daemon Setup (Wallet)

 

Now let’s setup the coin daemon, I will be using Ethereum.

We can install in 2 way her is guide ..

First>> Installing from PPA

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum

If you want to stay on the bleeding edge, install the ethereum-unstable package instead.

After installing, run geth account new to create an account on your node.

You should now be able to run geth and connect to the network.

Make sure to check the different options and commands with geth --help

You can alternatively install only the geth CLI with apt-get install geth if you don’t want to install the other utilities (bootnode, evm, disasm, rlpdump, ethtest).

Second>> Building from source

Clone the repository to a directory of your choosing:

git clone https://github.com/ethereum/go-ethereum

Install latest distribution of Golang (v1.7) if you don’t have it already:

Building geth requires Go and C compilers to be installed:

sudo apt-get install -y build-essential golang

Finally, build the geth program using the following command.

cd go-ethereum
make geth

You can now run build/bin/geth to start your node.

Mining Pool Setup

 

Clone & compile:

git config --global http.https://gopkg.in.followRedirects true
git clone https://github.com/sammy007/open-ethereum-pool.git
cd open-ethereum-pool
make

Running Pool

 

./build/bin/open-ethereum-pool config.json

You can use Ubuntu upstart – check for sample config in upstart.conf.

Building Frontend

 

The frontend is a single-page Ember.js application that polls the pool API to render miner stats.

cd www

Change ApiUrl: '//example.net/' in www/config/environment.js to match your domain name. Also don’t forget to adjust other options.

npm install -g ember-cli@2.9.1
npm install -g bower
npm install
bower install
./build.sh

Configure nginx to serve API on /api subdirectory. Configure nginx to serve www/dist as static website.

Serving API using nginx

Create an upstream for API:

upstream api {
server 127.0.0.1:8080;
}

and add this setting after location /:

location /api {
proxy_pass http://api;
}

Customization

You can customize the layout using built-in web server with live reload:

ember server --port 8082 --environment development

Don’t use built-in web server in production.

Check out www/app/templates directory and edit these templates in order to customise the frontend.

Configuration

 

Configuration is actually simple, just read it twice and think twice before changing defaults.

Don’t copy config directly from this manual. Use the example config from the package, otherwise you will get errors on start because of JSON comments.

{
// Set to the number of CPU cores of your server
“threads”: 2,
// Prefix for keys in redis store
“coin”: “eth”,
// Give unique name to each instance
“name”: “main”,

“proxy”: {
“enabled”: true,

// Bind HTTP mining endpoint to this IP:PORT
“listen”: “0.0.0.0:8888”,

// Allow only this header and body size of HTTP request from miners
“limitHeadersSize”: 1024,
“limitBodySize”: 256,

/* Set to true if you are behind CloudFlare (not recommended) or behind http-reverse
proxy to enable IP detection from X-Forwarded-For header.
Advanced users only. It’s tricky to make it right and secure.
*/
“behindReverseProxy”: false,

// Stratum mining endpoint
“stratum”: {
“enabled”: true,
// Bind stratum mining socket to this IP:PORT
“listen”: “0.0.0.0:8008”,
“timeout”: “120s”,
“maxConn”: 8192
},

// Try to get new job from geth in this interval
“blockRefreshInterval”: “120ms”,
“stateUpdateInterval”: “3s”,
// Require this share difficulty from miners
“difficulty”: 2000000000,

/* Reply error to miner instead of job if redis is unavailable.
Should save electricity to miners if pool is sick and they didn’t set up failovers.
*/
“healthCheck”: true,
// Mark pool sick after this number of redis failures.
“maxFails”: 100,
// TTL for workers stats, usually should be equal to large hashrate window from API section
“hashrateExpiration”: “3h”,

“policy”: {
“workers”: 8,
“resetInterval”: “60m”,
“refreshInterval”: “1m”,

“banning”: {
“enabled”: false,
/* Name of ipset for banning.
Check http://ipset.netfilter.org/ documentation.
*/
“ipset”: “blacklist”,
// Remove ban after this amount of time
“timeout”: 1800,
// Percent of invalid shares from all shares to ban miner
“invalidPercent”: 30,
// Check after after miner submitted this number of shares
“checkThreshold”: 30,
// Bad miner after this number of malformed requests
“malformedLimit”: 5
},
// Connection rate limit
“limits”: {
“enabled”: false,
// Number of initial connections
“limit”: 30,
“grace”: “5m”,
// Increase allowed number of connections on each valid share
“limitJump”: 10
}
}
},

// Provides JSON data for frontend which is static website
“api”: {
“enabled”: true,
“listen”: “0.0.0.0:8080”,
// Collect miners stats (hashrate, …) in this interval
“statsCollectInterval”: “5s”,
// Purge stale stats interval
“purgeInterval”: “10m”,
// Fast hashrate estimation window for each miner from it’s shares
“hashrateWindow”: “30m”,
// Long and precise hashrate from shares, 3h is cool, keep it
“hashrateLargeWindow”: “3h”,
// Collect stats for shares/diff ratio for this number of blocks
“luckWindow”: [64, 128, 256],
// Max number of payments to display in frontend
“payments”: 50,
// Max numbers of blocks to display in frontend
“blocks”: 50,

/* If you are running API node on a different server where this module
is reading data from redis writeable slave, you must run an api instance with this option enabled in order to purge hashrate stats from main redis node.
Only redis writeable slave will work properly if you are distributing using redis slaves.
Very advanced. Usually all modules should share same redis instance.
*/
“purgeOnly”: false
},

// Check health of each geth node in this interval
“upstreamCheckInterval”: “5s”,

/* List of geth nodes to poll for new jobs. Pool will try to get work from
first alive one and check in background for failed to back up.
Current block template of the pool is always cached in RAM indeed.
*/
“upstream”: [
{
“name”: “main”,
“url”: “http://127.0.0.1:8545”,
“timeout”: “10s”
},
{
“name”: “backup”,
“url”: “http://127.0.0.2:8545”,
“timeout”: “10s”
}
],

// This is standard redis connection options
“redis”: {
// Where your redis instance is listening for commands
“endpoint”: “127.0.0.1:6379”,
“poolSize”: 10,
“database”: 0,
“password”: “”
},

// This module periodically remits ether to miners
“unlocker”: {
“enabled”: false,
// Pool fee percentage
“poolFee”: 1.0,
// Pool fees beneficiary address (leave it blank to disable fee withdrawals)
“poolFeeAddress”: “”,
// Donate 10% from pool fees to developers
“donate”: true,
// Unlock only if this number of blocks mined back
“depth”: 120,
// Simply don’t touch this option
“immatureDepth”: 20,
// Keep mined transaction fees as pool fees
“keepTxFees”: false,
// Run unlocker in this interval
“interval”: “10m”,
// Geth instance node rpc endpoint for unlocking blocks
“daemon”: “http://127.0.0.1:8545”,
// Rise error if can’t reach geth in this amount of time
“timeout”: “10s”
},

// Pay out miners using this module
“payouts”: {
“enabled”: false,
// Require minimum number of peers on node
“requirePeers”: 25,
// Run payouts in this interval
“interval”: “12h”,
// Geth instance node rpc endpoint for payouts processing
“daemon”: “http://127.0.0.1:8545”,
// Rise error if can’t reach geth in this amount of time
“timeout”: “10s”,
// Address with pool balance
“address”: “0x0”,
// Let geth to determine gas and gasPrice
“autoGas”: true,
// Gas amount and price for payout tx (advanced users only)
“gas”: “21000”,
“gasPrice”: “50000000000”,
// Send payment only if miner’s balance is >= 0.5 Ether
“threshold”: 500000000,
// Perform BGSAVE on Redis after successful payouts session
“bgsave”: false
}
}

If you are distributing your pool deployment to several servers or processes, create several configs and disable unneeded modules on each server. (Advanced users)

I recommend this deployment strategy:

  1. Mining instance – 1x (it depends, you can run one node for EU, one for US, one for Asia)
  2. Unlocker and payouts instance – 1x each (strict!)
  3. API instance – 1x

 

Congratulations You have now your own Mining Pool Ready to Start

If you liked this guide, please donate to me as well!
BTC: 18xRnsa828YALPgbvjRXQuQ63QqikPbKxq

Comments (11)

  • Sorry I cannot get the website to display. geth is working and pool runs but there is an access error to the api i have tried numerous times to rebuild with this guide I think there is something wrong can you please post what exactly you changed in your enviroment.js along with your nginx config. as this is really puzzling and should not be difficult at all to get running.

    Reply
  • Activity: 14

    View Profile Email Personal Message (Online)
    Trust: 0: -0 / +0

    Re: [GUIDE] Setup your own Ethereum mining pool.
    Today at 05:40:38 AM

    Reply with quote Edit message Delete message #8
    Man im trying to follow your guide, after i have installed geth using
    sudo apt-get install software-properties-common
    sudo add-apt-repository -y ppa:ethereum/ethereum
    sudo apt-get update
    sudo apt-get install ethereum
    After that i just use putty to connect to my vps
    I run it with this command
    geth –fast –cache=512 console –rpcaddr 127.0.0.1 –rpcport 8983 –rpc –unlock COINBASEADDRESS
    the node start just fine

    Then i try to run the pool module (ALL IN ONE AT FIRST) and this is a log of what I get

    root@EPS:~/open-ethereum-pool# ./build/bin/open-ethereum-pool config.json

    2017/06/15 05:37:58 Loading config: /root/open-ethereum-pool/config.json
    2017/06/15 05:37:58 Running with 1 threads
    2017/06/15 05:37:58 Backend check reply: PONG
    2017/06/15 05:37:58 Starting payouts
    2017/06/15 05:37:58 Set payouts interval to 2h0m0s
    2017/06/15 05:37:58 No payees that have reached payout threshold
    2017/06/15 05:37:58 Policy state refresh complete
    2017/06/15 05:37:58 Set policy stats reset every 1h0m0s
    2017/06/15 05:37:58 Set policy state refresh every 1m0s
    2017/06/15 05:37:58 Running with 8 policy workers
    2017/06/15 05:37:58 Upstream: main => 127.0.0.1:8545
    2017/06/15 05:37:58 Upstream: backup => http://127.0.0.2:8545
    2017/06/15 05:37:58 Default upstream: main => 127.0.0.1:8545
    2017/06/15 05:37:58 Error while refreshing pending block on main: Post 127.0.0.1:8545: unsupported protocol scheme “”
    2017/06/15 05:37:58 Error while refreshing pending block on main: Post 127.0.0.1:8545: unsupported protocol scheme “”
    2017/06/15 05:37:58 Set block refresh every 120ms
    2017/06/15 05:37:58 Starting proxy on 127.0.0.1:8888
    2017/06/15 05:37:58 Starting API on 127.0.0.1:8080
    2017/06/15 05:37:58 Set stats collect interval to 5s
    2017/06/15 05:37:58 Set purge interval to 10m0s
    2017/06/15 05:37:58 Purged stale stats from backend, 0 shares affected, elapsed time 550.191µs
    2017/06/15 05:37:58 Stratum listening on 127.0.0.1:8008
    2017/06/15 05:37:58 Stats collection finished 3.454594ms
    2017/06/15 05:37:58 Error while refreshing pending block on main: Post 127.0.0.1:8545: unsupported protocol scheme “”
    2017/06/15 05:37:58 Error while refreshing pending block on main: Post 127.0.0.1:8545: unsupported protocol scheme “”

    If you wanna see my config file this is it
    {
    “threads”: 1,
    “coin”: “eth”,
    “name”: “main”,

    “proxy”: {
    “enabled”: true,
    “listen”: “127.0.0.1:8888”,
    “limitHeadersSize”: 1024,
    “limitBodySize”: 256,
    “behindReverseProxy”: false,
    “blockRefreshInterval”: “120ms”,
    “stateUpdateInterval”: “3s”,
    “difficulty”: 2000000000,
    “hashrateExpiration”: “3h”,

    “healthCheck”: true,
    “maxFails”: 100,

    “stratum”: {
    “enabled”: true,
    “listen”: “127.0.0.1:8008”,
    “timeout”: “120s”,
    “maxConn”: 8192
    },

    “policy”: {
    “workers”: 8,
    “resetInterval”: “60m”,
    “refreshInterval”: “1m”,

    “banning”: {
    “enabled”: false,
    “ipset”: “blacklist”,
    “timeout”: 1800,
    “invalidPercent”: 30,
    “checkThreshold”: 30,
    “malformedLimit”: 5
    },
    “limits”: {
    “enabled”: false,
    “listen”: “127.0.0.1:8008”,
    “timeout”: “120s”,
    “maxConn”: 8192
    },

    “policy”: {
    “workers”: 8,
    “resetInterval”: “60m”,
    “refreshInterval”: “1m”,

    “banning”: {
    “enabled”: false,
    “ipset”: “blacklist”,
    “timeout”: 1800,
    “invalidPercent”: 30,
    “checkThreshold”: 30,
    “malformedLimit”: 5
    },
    “limits”: {
    “enabled”: false,
    “limit”: 30,
    “grace”: “5m”,
    “limitJump”: 10
    }
    }
    },

    “api”: {
    “enabled”: true,
    “purgeOnly”: false,
    “purgeInterval”: “10m”,
    “listen”: “127.0.0.1:8080”,
    “statsCollectInterval”: “5s”,
    “hashrateWindow”: “30m”,
    “hashrateLargeWindow”: “3h”,
    “luckWindow”: [64, 128, 256],
    “payments”: 30,
    “blocks”: 50
    },

    “upstreamCheckInterval”: “5s”,
    “upstream”: [
    {
    “name”: “main”,
    “url”: “127.0.0.1:8545”,
    “timeout”: “10s”
    },
    {
    “name”: “backup”,
    “url”: “http://127.0.0.2:8545”,
    “timeout”: “10s”
    }
    ],

    “redis”: {
    “endpoint”: “127.0.0.1:6379”,
    “poolSize”: 10,
    “database”: 0,
    “password”: “”
    },

    “unlocker”: {
    {
    “name”: “main”,
    “url”: “127.0.0.1:8545”,
    “timeout”: “10s”
    },
    {
    “name”: “backup”,
    “url”: “http://127.0.0.2:8545”,
    “timeout”: “10s”
    }
    ],

    “redis”: {
    “endpoint”: “127.0.0.1:6379”,
    “poolSize”: 10,
    “database”: 0,
    “password”: “”
    },

    “unlocker”: {
    “enabled”: false,
    “poolFee”: 1.0,
    “poolFeeAddress”: “COINBASEADDRESS”,
    “donate”: true,
    “depth”: 120,
    “immatureDepth”: 20,
    “keepTxFees”: false,
    “interval”: “10m”,
    “daemon”: “127.0.0.1:8545”,
    “timeout”: “10s”
    },

    “payouts”: {
    “enabled”: true,
    “requirePeers”: 25,
    “interval”: “120m”,
    “daemon”: “127.0.0.1:8545”,
    “timeout”: “10s”,
    “address”: “0x0”,
    “gas”: “21000”,
    “gasPrice”: “50000000000”,
    “autoGas”: true,
    “threshold”: 100000000,
    “bgsave”: false
    },

    “newrelicEnabled”: false,
    “newrelicName”: “MyEtherProxy”,
    “newrelicKey”: “SECRET_KEY”,
    “newrelicVerbose”: false
    }

    Reply
  • Could you please tell me the command that would be used for claymore with port?

    Reply
  • Hello,

    Thanks a lof for the instalation guide… I’m trying go install it but I’m getting this error:

    2017/07/09 23:05:20 Upstream: main => http://127.0.0.1:8545
    2017/07/09 23:05:20 Upstream: backup => http://127.0.0.2:8545
    2017/07/09 23:05:20 Default upstream: main => http://127.0.0.1:8545
    2017/07/09 23:05:20 Error while refreshing pending block on main: Post http://127.0.0.1:8545: dial tcp 127.0.0.1:8545: getsockopt: connection refused
    2017/07/09 23:05:20 Error while refreshing pending block on main: Post http://127.0.0.1:8545: dial tcp 127.0.0.1:8545: getsockopt: connection refused
    2017/07/09 23:05:20 Set block refresh every 120ms

    Can you please help me to fix this problem?

    Thanks in advance

    Reply
  • I followed these instructions and when I reload the web page on the server, it just shows the default NGINX page. going to /api leads to a 404.

    Reply
  • Hi, can you help me to fix?

    cheers

    root@vps4239:~/open-ethereum-pool# ./build/bin/open-ethereum-pool config.example.json
    2017/08/11 23:39:42 Loading config: /root/open-ethereum-pool/config.example.json
    2017/08/11 23:39:42 Running with 2 threads
    2017/08/11 23:39:42 Backend check reply: PONG
    2017/08/11 23:39:42 Starting API on 0.0.0.0:8080
    2017/08/11 23:39:42 Set stats collect interval to 5s
    2017/08/11 23:39:42 Set purge interval to 10m0s
    2017/08/11 23:39:42 Policy state refresh complete
    2017/08/11 23:39:42 Set policy stats reset every 1h0m0s
    2017/08/11 23:39:42 Set policy state refresh every 1m0s
    2017/08/11 23:39:42 Running with 8 policy workers
    2017/08/11 23:39:42 Upstream: main => http://127.0.0.1:8545
    2017/08/11 23:39:42 Upstream: backup => http://127.0.0.2:8545
    2017/08/11 23:39:42 Default upstream: main => http://127.0.0.1:8545
    2017/08/11 23:39:42 Purged stale stats from backend, 0 shares affected, elapsed time 478.857µs
    2017/08/11 23:39:42 Stratum listening on 0.0.0.0:8008
    2017/08/11 23:39:42 Error while refreshing pending block on main: Post http://127.0.0.1:8545: dial tcp 127.0.0.1:8545: getsockopt: connection refused
    2017/08/11 23:39:42 Error while refreshing pending block on main: Post http://127.0.0.1:8545: dial tcp 127.0.0.1:8545: getsockopt: connection refused
    2017/08/11 23:39:42 Set block refresh every 120ms
    2017/08/11 23:39:42 Starting proxy on 0.0.0.0:8888
    2017/08/11 23:39:42 Stats collection finished 562.823µs
    2017/08/11 23:39:42 Error while refreshing pending block on main: Post http://127.0.0.1:8545: dial tcp 127.0.0.1:8545: getsockopt: connection refused
    2017/08/11 23:39:42 Error while refreshing pending block on main: Post http://127.0.0.1:8545: dial tcp 127.0.0.1:8545: getsockopt: connection refused

    Reply
  • This just happened and I’m not sure why but on payment interval:
    “Unable to process payouts: invalid argument 0: json: cannot unmarshal hex string of odd length into Go value of type common.Address”

    Using a Claymore miner against my test net

    Reply
  • I am having the same issue. I cannot start the pool.

    2017/08/17 20:50:34 Error while refreshing pending block on main: Post http://127.0.0.1:8545: dial tcp 127.0.0.1:8545: getsockopt: connection refused

    Reply
  • ./build/bin/open-ethereum-pool config.json

    First wrote that the catalog will not find, I went into it all the same, now he writes that the command is not found. what to do

    Reply
  • please start geth –rpc before ./build/bin/open-ethereum-pool config.example.json

    Reply
  • Is there any video for this?
    thanks

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *