Permalink
Browse files

Initial import

  • Loading branch information...
sammy007 committed Apr 9, 2016
0 parents commit a57371ac8a7a4658a93e7214e40f0211c1f429c9
Showing with 5,870 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +621 −0 LICENSE
  3. +291 −0 README.md
  4. +277 −0 api/server.go
  5. +3 −0 build.sh
  6. +93 −0 config.example.json
  7. +102 −0 main.go
  8. +135 −0 payouts/payer.go
  9. +460 −0 payouts/unlocker.go
  10. +308 −0 policy/policy.go
  11. +35 −0 proxy/api.go
  12. +116 −0 proxy/blocks.go
  13. +52 −0 proxy/config.go
  14. +68 −0 proxy/handlers.go
  15. +95 −0 proxy/miner.go
  16. +26 −0 proxy/proto.go
  17. +291 −0 proxy/proxy.go
  18. +251 −0 rpc/rpc.go
  19. +754 −0 storage/redis.go
  20. +28 −0 upstart.conf
  21. +44 −0 util/util.go
  22. +4 −0 www/.bowerrc
  23. +34 −0 www/.editorconfig
  24. +9 −0 www/.ember-cli
  25. +17 −0 www/.gitignore
  26. +33 −0 www/.jshintrc
  27. +23 −0 www/.travis.yml
  28. +3 −0 www/.watchmanconfig
  29. +53 −0 www/README.md
  30. +18 −0 www/app/app.js
  31. 0 www/app/components/.gitkeep
  32. +15 −0 www/app/components/active-li.js
  33. 0 www/app/controllers/.gitkeep
  34. +16 −0 www/app/controllers/account.js
  35. +66 −0 www/app/controllers/application.js
  36. +17 −0 www/app/controllers/index.js
  37. +18 −0 www/app/formats.js
  38. 0 www/app/helpers/.gitkeep
  39. +8 −0 www/app/helpers/format-balance.js
  40. +8 −0 www/app/helpers/format-date-locale.js
  41. +14 −0 www/app/helpers/format-hashrate.js
  42. +7 −0 www/app/helpers/format-tx.js
  43. +7 −0 www/app/helpers/seconds-to-ms.js
  44. +7 −0 www/app/helpers/string-to-int.js
  45. +35 −0 www/app/index.html
  46. 0 www/app/models/.gitkeep
  47. +30 −0 www/app/models/block.js
  48. +10 −0 www/app/models/payment.js
  49. +24 −0 www/app/router.js
  50. 0 www/app/routes/.gitkeep
  51. +25 −0 www/app/routes/account.js
  52. +22 −0 www/app/routes/application.js
  53. +32 −0 www/app/routes/blocks.js
  54. +11 −0 www/app/routes/index.js
  55. +22 −0 www/app/routes/payments.js
  56. +174 −0 www/app/styles/app.css
  57. +20 −0 www/app/templates/about.hbs
  58. +51 −0 www/app/templates/account.hbs
  59. +46 −0 www/app/templates/account/index.hbs
  60. +25 −0 www/app/templates/account/payouts.hbs
  61. +6 −0 www/app/templates/application-error.hbs
  62. +48 −0 www/app/templates/application.hbs
  63. +23 −0 www/app/templates/blocks.hbs
  64. +47 −0 www/app/templates/blocks/immature.hbs
  65. +47 −0 www/app/templates/blocks/index.hbs
  66. +29 −0 www/app/templates/blocks/pending.hbs
  67. 0 www/app/templates/components/.gitkeep
  68. +1 −0 www/app/templates/components/active-li.hbs
  69. +39 −0 www/app/templates/help.hbs
  70. +46 −0 www/app/templates/index.hbs
  71. +6 −0 www/app/templates/not-found.hbs
  72. +33 −0 www/app/templates/payments.hbs
  73. +16 −0 www/bower.json
  74. +3 −0 www/build.sh
  75. +54 −0 www/config/environment.js
  76. +33 −0 www/ember-cli-build.js
  77. +43 −0 www/package.json
  78. BIN www/public/bg.png
  79. +15 −0 www/public/crossdomain.xml
  80. BIN www/public/favicon.ico
  81. +3 −0 www/public/robots.txt
  82. +12 −0 www/testem.json
  83. +52 −0 www/tests/.jshintrc
  84. +11 −0 www/tests/helpers/resolver.js
  85. +18 −0 www/tests/helpers/start-app.js
  86. +33 −0 www/tests/index.html
  87. +26 −0 www/tests/integration/components/active-li-test.js
  88. +6 −0 www/tests/test-helper.js
  89. 0 www/tests/unit/.gitkeep
  90. +12 −0 www/tests/unit/controllers/account-test.js
  91. +12 −0 www/tests/unit/controllers/application-test.js
  92. +12 −0 www/tests/unit/controllers/blocks-test.js
  93. +12 −0 www/tests/unit/controllers/index-test.js
  94. +10 −0 www/tests/unit/helpers/format-balance-test.js
  95. +10 −0 www/tests/unit/helpers/format-date-locale-test.js
  96. +10 −0 www/tests/unit/helpers/format-date-test.js
  97. +10 −0 www/tests/unit/helpers/format-tx-test.js
  98. +10 −0 www/tests/unit/helpers/from-now-test.js
  99. +12 −0 www/tests/unit/models/block-test.js
  100. +12 −0 www/tests/unit/models/payment-test.js
  101. +11 −0 www/tests/unit/routes/about-test.js
  102. +11 −0 www/tests/unit/routes/application-test.js
  103. +11 −0 www/tests/unit/routes/blocks-test.js
  104. +11 −0 www/tests/unit/routes/blocks/index-test.js
  105. +11 −0 www/tests/unit/routes/blocks/pending-test.js
  106. +11 −0 www/tests/unit/routes/error-test.js
  107. +11 −0 www/tests/unit/routes/help-test.js
  108. +11 −0 www/tests/unit/routes/index-test.js
  109. +11 −0 www/tests/unit/routes/miner-test.js
  110. +11 −0 www/tests/unit/routes/payments-test.js
  111. +11 −0 www/tests/unit/routes/stats-payouts-test.js
  112. +11 −0 www/tests/unit/routes/stats/not-found-test.js
  113. +5 −0 www/translations/en-us.yaml
  114. 0 www/vendor/.gitkeep
@@ -0,0 +1,7 @@
.DS_Store
config.json
testnet.json
ether-pool
ether-pool.exe
logs
tools
621 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
291 README.md
@@ -0,0 +1,291 @@
# go-ethereum-pool
## High Performance Ethereum Mining Pool
![Miner's stats page](https://15254b2dcaab7f5478ab-24461f391e20b7336331d5789078af53.ssl.cf1.rackcdn.com/ethereum.vanillaforums.com/editor/pe/cf77cki0pjpt.png)
### Features
* Highly available mining endpoint module
* Payouts and block unlocking (maturity) module
* Configurable payouts period and balance threshold
* PROP payouts (miners are simply paid out when a block is found)
* Detailed block stats with luck percentage and full reward
* Failover geth instances: geth high availability built in
* Strict policy module (banning strategies using ipset/iptables)
* Designed for 100% distributed setup of all modules
* Modern beautiful Ember.js frontend
* Separate stats for workers: can highlight timed-out workers so miners can perform maintenance of rigs
* JSON-API for stats, miners can use for rigs maintenance automation (rig rebooting for example )
Also it's compatible with my *ether-proxy* solo/pool proxy solution.
*Written in Go it's a rocket highly concurrent and low RAM consuming piece of code*
### Building on Linux
Dependencies:
* go >= 1.4
* geth
* redis-server
* nodejs
* nginx
**I highly recommend to use Ubuntu 14.04 LTS.**
First of all you must install [go-ethereum](https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu).
Export GOPATH:
export GOPATH=$HOME/go
Install required packages:
go get github.com/ethereum/ethash
go get github.com/ethereum/go-ethereum/common
go get github.com/gorilla/mux
go get github.com/yvasiyarov/gorelic
Compile:
go build -o ether-pool main.go
Install redis-server and all software you need too.
Install nodejs, I suggest to use >= 4.x LTS version from https://github.com/nodesource/distributions or from your Linux distribution.
### Building on Windows
It's a little bit crazy to run production pool on this platform, but you can follow
[geth building instructions](https://github.com/ethereum/go-ethereum/wiki/Installation-instructions-for-Windows) and compile pool this way.
Use some cloud Redis provider or give a try to https://github.com/MSOpenTech/redis/releases.
### Building Frontend
Frontend is a single-page Ember.js application. It polls API of the pool
to render pool stats to miners.
cd www
Change <code>ApiUrl: '//example.net/'</code> to match your domain name.
npm install -g ember-cli@2.4.3
npm install -g bower
npm install
bower install
./build.sh
Configure nginx to serve API on <code>/api</code> subdirectory.
Configure your nginx instance to serve <code>www/dist</code> 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 <code>location /</code>:
location /api {
proxy_pass http://api;
}
You can customize layout and other stuff using built-in web server with live reload:
ember server --port 8082 --environment development
#### Customization
Check out <code>www/app/templates</code> directory and edit these templates
in order to add your own branding and contacts.
### Configuration
Configuration is actually simple, just read it twice and think twice before changing defaults.
**Don't copy config directly from this manual, use example config from package,
Otherwise you will get errors on start because JSON can't contain comments actually.**
```javascript
{
// Set to a number of CPU threads 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 mining endpoint to this IP:PORT
"listen": "0.0.0.0:8546",
// Allow only this header and body size of HTTP request from miners
"limitHeadersSize": 1024,
"limitBodySize": 256,
/* Use it if you are behind CloudFlare (bad idea) 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,
// Try to get new job from geth in this interval
"blockRefreshInterval": "120ms",
"stateUpdateInterval": "3s",
// Require this share difficulty from miners
"difficulty": 2000000000,
"hashrateExpiration": "30m",
/* 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,
"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
}
}
},
// Provides JSON data for frontend which is static website
"api": {
"enabled": true,
/* If you are running API node in a distributed environment where this module
is reading data from redis writeable slave, enable this option.
Only redis writeable slave will work properly if you are distributing using redis slaves.
Don't distribute!
*/
"purgeOnly": false,
"listen": "0.0.0.0:8080",
// Collect miners stats (hashrate, ...) in this interval
"statsCollectInterval": "5s",
// 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",
// Max number of payments to display in frontend
"payments": 50,
// Max numbers of blocks to display in frontend
"blocks": 50
},
// 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": 8,
"database": 0,
/* Generate and specify very strong password for in redis
configuration file and specify it here.
This is done using the requirepass directive in the configuration file.
*/
"password": "secret"
},
// This module periodically credits coins to miners
"unlocker": {
"enabled": false,
// Pool fee percentage
"poolFee": 1.0,
// Unlock only if this number of blocks mined back
"depth": 120,
// Simply don't touch this option
"immatureDepth": 20,
// 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"
},
// Paying out miners using this module
"payouts": {
"enabled": false,
// 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",
// Gas amount and price for payout tx
"gas": "21000",
"gasPrice": "50000000000",
// Seend payment only if miner's balance is >= 0.5 Ether
"threshold": 500000000
},
}
```
If you are distributing your pool deployment to several servers or processes,
create several configs and disable unneeded modules on each server.
This is very advanced, better don't distribute to several servers until you really need it.
I recommend this deployment strategy:
* Mining instance - 1x (it depends, you can run one node for EU, one for US, one for Asia)
* Unlocker and payouts instance - 1x each (strict!)
* API instance - 1x
### Notes
Unlocking and payouts are sequential, 1st tx go, 2nd waiting for 1st to confirm and so on.
You can disable that in code. Also, keep in mind that unlocking and payouts will be stopped in case of any backend or geth failure.
You must restart module if you see such errors with *suspended* word, so I recommend to run unlocker and payouts in a separate processes.
Don't run payouts and unlocker as part of mining node.
### Credits
Made by sammy007.
### Donations
* **ETH**: [0xb85150eb365e7df0941f0cf08235f987ba91506a](https://etherchain.org/account/0xb85150eb365e7df0941f0cf08235f987ba91506a)
* **BTC**: [1PYqZATFuYAKS65dbzrGhkrvoN9au7WBj8](https://blockchain.info/address/1PYqZATFuYAKS65dbzrGhkrvoN9au7WBj8)
Oops, something went wrong.

0 comments on commit a57371a

Please sign in to comment.