cryptonote-universal-pool/README.md

419 lines
16 KiB
Markdown
Raw Normal View History

2014-05-09 23:11:10 +02:00
node-cryptonote-pool
====================
High performance Node.js (with native C addons) mining pool for CryptoNote based coins such as Bytecoin, Monero, QuazarCoin, HoneyPenny, etc..
Comes with lightweight example front-end script which uses the pool's AJAX API.
#### Table of Contents
* [Features](#features)
* [Community Support](#community--support)
2014-05-19 18:18:03 +02:00
* [Pools Using This Software](#pools-using-this-software)
* [Usage](#usage)
* [Requirements](#requirements)
* [Downloading & Installing](#1-downloading--installing)
* [Configuration](#2-configuration)
2014-05-24 19:06:19 +02:00
* [Configure Easyminer](#3-optional-configure-cryptonote-easy-miner-for-your-pool)
2014-05-15 23:33:33 +02:00
* [Starting the Pool](#4-start-the-pool)
* [Host the front-end](#5-host-the-front-end)
* [Customizing your website](#6-customize-your-website)
* [Upgrading](#upgrading)
* [Setting up Testnet](#setting-up-testnet)
* [JSON-RPC Commands from CLI](#json-rpc-commands-from-cli)
* [Monitoring Your Pool](#monitoring-your-pool)
* [Donations](#donations)
* [Credits](#credits)
* [License](#license)
2014-05-12 05:49:57 +02:00
2014-05-14 02:41:28 +02:00
#### Features
* TCP (stratum-like) protocol for server-push based jobs
* Compared to old HTTP protocol, this has a higher hash rate, lower network/CPU server load, lower orphan
block percent, and less error prone
2014-05-14 02:41:28 +02:00
* IP banning to prevent low-diff share attacks
* Socket flooding detection
* Payment processing
* Splintered transactions to deal with max transaction size
* Minimum payment threshold before balance will be paid out
* Minimum denomination for truncating payment amount precision to reduce size/complexity of block transactions
2014-05-14 02:41:28 +02:00
* Detailed logging
2014-05-17 19:46:53 +02:00
* Ability to configure multiple ports - each with their own difficulty
* Variable difficulty / share limiter
* Share trust algorithm to reduce share validation hashing CPU load
2014-05-14 02:41:28 +02:00
* Clustering for vertical scaling
2014-05-17 19:23:39 +02:00
* Modular components for horizontal scaling (pool server, database, stats/API, payment processing, front-end)
* Live stats API (using AJAX long polling with CORS)
2014-05-12 09:52:22 +02:00
* Currency network/block difficulty
* Current block height
* Network hashrate
* Pool hashrate
* Each miners' individual stats (hashrate, shares submitted, pending balance, total paid, etc)
2014-05-12 09:52:22 +02:00
* Blocks found (pending, confirmed, and orphaned)
* An easily extendable, responsive, light-weight front-end using API to display data
2014-05-17 19:46:53 +02:00
* Worker login validation (make sure miners are using proper wallet addresses for mining)
2014-05-14 02:50:13 +02:00
2014-05-14 02:41:28 +02:00
### Community / Support
2014-05-12 09:52:22 +02:00
* [CryptoNote Forum](https://forum.cryptonote.org/)
* [Bytecoin Github](https://github.com/amjuarez/bytecoin)
* [Monero Github](https://github.com/monero-project/bitmonero)
2014-06-25 19:04:56 +02:00
* [Monero Announcement Thread](https://bitcointalk.org/index.php?topic=583449.0)
2014-05-16 20:12:49 +02:00
* IRC (freenode)
* Support / general discussion join #monero: https://webchat.freenode.net/?channels=#monero
* Development discussion join #monero-dev: https://webchat.freenode.net/?channels=#monero-dev
2014-05-12 09:52:22 +02:00
2014-05-19 18:18:03 +02:00
#### Pools Using This Software
2014-05-19 21:32:47 +02:00
* http://moneropool.com
* http://monero.farm
* http://extremehash.com
2014-05-19 18:18:03 +02:00
* http://extremepool.org
* http://hashinvest.net
* http://moneropool.com.br
* http://monerominers.net
* http://monero.crypto-pool.fr
* http://cryptonotepool.org.uk
* http://minexmr.com
* http://kippo.eu
* http://pool.cryptoescrow.eu
* http://coinmine.pl/xmr
* http://moneropool.org
2014-05-19 18:18:03 +02:00
2014-05-12 05:49:57 +02:00
Usage
===
#### Requirements
* Coin daemon(s) (find the coin's repo and build latest version from source)
* [Node.js](http://nodejs.org/) v0.10+ ([follow these installation instructions](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager))
* [Redis](http://redis.io/) key-value store v2.6+ ([follow these instructions](http://redis.io/topics/quickstart))
* libssl required for the node-multi-hashing module
* For Ubuntu: `sudo apt-get install libssl-dev`
2014-05-12 05:49:57 +02:00
##### Seriously
Those are legitimate requirements. If you use old versions of Node.js or Redis that may come with your system package manager then you will have problems. Follow the linked instructions to get the last stable versions.
2014-05-16 20:12:49 +02:00
[**Redis security warning**](http://redis.io/topics/security): be sure firewall access to redis - an easy way is to
include `bind 127.0.0.1` in your `redis.conf` file. Also it's a good idea to learn about and understand software that
you are using - a good place to start with redis is [data persistence](http://redis.io/topics/persistence).
2014-05-12 05:49:57 +02:00
2014-05-16 20:12:49 +02:00
#### 1) Downloading & Installing
2014-05-12 05:49:57 +02:00
2014-05-12 05:49:57 +02:00
Clone the repository and run `npm update` for all the dependencies to be installed:
```bash
git clone https://github.com/zone117x/node-cryptonote-pool.git pool
cd pool
npm update
```
#### 2) Configuration
2014-06-25 19:04:56 +02:00
*Warning for Cyrptonote coins other than Monero:* this software may or may not work with any given cryptonote coin.
Be wary of altcoins that change the number of minimum coin units because you will have to reconfigure several config
values to account for those changes. Unless you're offering a bounty reward - do not open an issue asking for help
getting a coin other than Monero working with this software.
Copy the `config_example.json` file to `config.json` then overview each options and change any to match your preferred setup.
2014-05-12 05:49:57 +02:00
Explanation for each field:
2014-05-14 02:49:32 +02:00
```javascript
2014-06-25 19:14:08 +02:00
/* Used for storage in redis so multiple coins can share the same redis instance. */
"coin": "monero",
2014-06-25 19:14:08 +02:00
/* Used for front-end display */
"symbol": "MRO",
2014-06-25 19:14:08 +02:00
"logging": {
2014-06-25 19:14:08 +02:00
"files": {
2014-05-14 02:41:28 +02:00
2014-06-25 19:14:08 +02:00
/* Specifies the level of log output verbosity. This level and anything
more severe will be logged. Options are: info, warn, or error. */
"level": "info",
2014-06-25 19:14:08 +02:00
/* Directory where to write log files. */
"directory": "logs",
2014-05-24 18:08:38 +02:00
2014-06-25 19:14:08 +02:00
/* How often (in seconds) to append/flush data to the log files. */
"flushInterval": 5
},
2014-06-25 19:14:08 +02:00
"console": {
"level": "info",
/* Gives console output useful colors. If you direct that output to a log file
then disable this feature to avoid nasty characters in the file. */
"colors": true
}
},
2014-06-25 19:14:08 +02:00
/* Modular Pool Server */
"poolServer": {
"enabled": true,
2014-06-25 19:14:08 +02:00
/* Set to "auto" by default which will spawn one process/fork/worker for each CPU
2014-06-25 19:22:13 +02:00
core in your system. Each of these workers will run a separate instance of your
pool(s), and the kernel will load balance miners using these forks. Optionally,
the 'forks' field can be a number for how many forks will be spawned. */
2014-06-25 19:14:08 +02:00
"clusterForks": "auto",
2014-06-25 19:14:08 +02:00
/* Address where block rewards go, and miner payments come from. */
"poolAddress": "4AsBy39rpUMTmgTUARGq2bFQWhDhdQNekK5v4uaLU699NPAnx9CubEJ82AkvD5ScoAZNYRwBxybayainhyThHAZWCdKmPYn"
2014-06-25 19:14:08 +02:00
/* Poll RPC daemons for new blocks every this many milliseconds. */
"blockRefreshInterval": 1000,
2014-06-25 19:14:08 +02:00
/* How many seconds until we consider a miner disconnected. */
"minerTimeout": 900,
2014-05-12 05:49:57 +02:00
2014-06-25 19:14:08 +02:00
"ports": [
{
"port": 3333, //Port for mining apps to connect to
"difficulty": 100, //Initial difficulty miners are set to
"desc": "Low end hardware" //Description of port
},
{
"port": 5555,
"difficulty": 2000,
"desc": "Mid range hardware"
},
{
"port": 7777,
"difficulty": 10000,
"desc": "High end hardware"
}
],
/* Variable difficulty is a feature that will automatically adjust difficulty for
individual miners based on their hashrate in order to lower networking and CPU
overhead. */
"varDiff": {
"minDiff": 2, //Minimum difficulty
2014-06-25 19:22:13 +02:00
"maxDiff": 100000,
2014-06-25 19:14:08 +02:00
"targetTime": 100, //Try to get 1 share per this many seconds
"retargetTime": 30, //Check to see if we should retarget every this many seconds
"variancePercent": 30, //Allow time to very this % from target without retargeting
2014-06-25 19:22:13 +02:00
"maxJump": 1000 //Limit diff increase/decrease in a single retargetting
2014-05-12 05:49:57 +02:00
},
2014-06-25 19:22:13 +02:00
/* Feature to trust share difficulties from miners which can
significantly reduce CPU load. */
2014-06-25 19:14:08 +02:00
"shareTrust": {
"enabled": true,
"min": 10, //Minimum percent probability for share hashing
2014-06-25 19:22:13 +02:00
"stepDown": 3, //Increase trust probability % this much with each valid share
2014-06-25 19:14:08 +02:00
"threshold": 10, //Amount of valid shares required before trusting begins
2014-06-25 19:22:13 +02:00
"penalty": 30 //Upon breaking trust require this many valid share before trusting
2014-05-12 05:49:57 +02:00
},
2014-06-25 19:14:08 +02:00
/* If under low-diff share attack we can ban their IP to reduce system/network load. */
"banning": {
"enabled": true,
"time": 600, //How many seconds to ban worker for
"invalidPercent": 25, //What percent of invalid shares triggers ban
"checkThreshold": 30 //Perform check when this many shares have been submitted
2014-05-12 05:49:57 +02:00
}
2014-06-25 19:14:08 +02:00
},
/* Module that sends payments to miners according to their submitted shares. */
"payments": {
"enabled": true,
"interval": 600, //how often to run in seconds
"maxAddresses": 50, //split up payments if sending to more than this many addresses
2014-06-25 19:22:13 +02:00
"transferFee": 5000000000, //fee to pay for each transaction
"minPayment": 100000000000, //miner balance required before sending payment
"denomination": 100000000000 //truncate to this precision and store remainder
2014-06-25 19:14:08 +02:00
},
2014-06-25 19:22:13 +02:00
/* Module that monitors the submitted block maturities and manages rounds. Confirmed
blocks mark the end of a round where workers' balances are increased in proportion
to their shares. */
2014-06-25 19:14:08 +02:00
"blockUnlocker": {
"enabled": true,
"interval": 30, //how often to check block statuses in seconds
2014-06-25 19:22:13 +02:00
/* Block depth required for a block to unlocked/mature. Found in daemon source as
the variable CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW */
"depth": 60,
"poolFee": 2, //2% pool fee
"devDonation": 0.1 //0.1% donation to send to pool dev - only works with Monero
2014-06-25 19:14:08 +02:00
},
/* AJAX API used for front-end website. */
"api": {
"enabled": true,
"hashrateWindow": 600, //how many second worth of shares used to estimate hash rate
"updateInterval": 3, //gather stats and broadcast every this many seconds
"port": 8117
},
/* Coin daemon connection details. */
"daemon": {
"host": "127.0.0.1",
"port": 18081
},
/* Wallet daemon connection details. */
"wallet": {
"host": "127.0.0.1",
"port": 8082
},
/* Redis connection into. */
"redis": {
"host": "127.0.0.1",
"port": 6379
2014-05-12 05:49:57 +02:00
}
2014-05-14 02:49:32 +02:00
```
2014-05-12 05:49:57 +02:00
2014-05-24 19:06:19 +02:00
#### 3) [Optional] Configure cryptonote-easy-miner for your pool
Your miners that are Windows users can use [cryptonote-easy-miner](https://github.com/zone117x/cryptonote-easy-miner)
which will automatically generate their wallet address and stratup multiple threads of simpleminer. You can download
it and edit the `config.ini` file to point to your own pool.
Inside the `easyminer` folder, edit `config.init` to point to your pool details
```ini
pool_host=example.com
pool_port=5555
```
Rezip and upload to your server or a file host. Then change the `easyminerDownload` link in your `config.json` file to
point to your zip file.
2014-05-12 05:49:57 +02:00
#### 4) Start the pool
2014-05-12 05:49:57 +02:00
```bash
node init.js
```
The file `config.json` is used by default but a file can be specified using the `-config=file` command argument, for example:
```bash
node init.js -config=config_backup.json
```
#### 5) Host the front-end
2014-05-14 02:49:32 +02:00
Simply host the contents of the `website` directory on file server capable of serving simple static files.
Edit the variables in `website/index.html` to use your pool's specific configuration. Variable explanations:
2014-05-14 02:49:32 +02:00
```html
<script>
2014-06-25 19:04:56 +02:00
/* Must point to the API setup in your config.json file. */
var api = "http://poolhost:8117";
/* Minimum units in a single coin, for Bytecoin its 100000000. */
var coinUnits = 1000000000000;
/* Pool server host to instruct your miners to point to. */
var poolHost = "cryppit.com";
/* IRC Server and room used for embedded KiwiIRC chat. */
var irc = "irc.freenode.net/#monero";
/* Contact email address. */
var email = "support@cryppit.com";
/* Market stat display params from https://www.cryptonator.com/widget */
var cryptonatorWidget = ["XMR-BTC", "XMR-USD", "XMR-EUR", "XMR-GBP"];
2014-05-14 02:49:32 +02:00
/* Download link to cryptonote-easy-miner for Windows users. */
var easyminerDownload = "https://github.com/zone117x/cryptonote-easy-miner/releases/";
2014-05-14 02:49:32 +02:00
/* Download link to simplewallet for your configured coin. */
var simplewalletDownload = "http://bit.ly/monero-starter-pack";
/* Used for front-end block links. For other coins it can be changed, for example with
Bytecoin you can use "https://minergate.com/blockchain/bcn/block/". */
var blockchainExplorer = "http://monerochain.info/block/";
</script>
2014-05-14 02:49:32 +02:00
```
#### 6) Customize your website
The following files are included so that you can customize your pool website without having to make significant changes
to `index.html` thus reducing the difficulty of merging updates to `index.html` with your own changes:
* `additional.css` for creating your own pool style
* `addtional.js` for changing the functionality of your pool website
* `info.html` for display news/updates/information on your site
Then simply serve the files via nginx, Apache, Google Drive, or anything that can host static content.
2014-05-12 05:49:57 +02:00
#### Upgrading
When updating to the latest code its important to not only `git pull` the latest from this repo, but to also update
the Node.js modules, and any config files that may have been changed.
* Inside your pool directory (where the init.js script is) do `git pull` to get the latest code.
* Remove the dependencies by deleting the `node_modules` directory with `rm -r node_modules`.
* Run `npm update` to force updating/reinstalling of the dependencies.
* Compare your `config.json` to the latest example ones in this repo or the ones in the setup instructions where each config field is explained. You may need to modify or add any new changes.
### Setting up Testnet
No cryptonote based coins have a testnet mode (yet) but you can effectively create a testnet with the following steps:
* Open `/src/p2p/net_node.inl` and remove lines with `ADD_HARDCODED_SEED_NODE` to prevent it from connecting to mainnet (Monero example: http://git.io/0a12_Q)
* Build the coin from source
* You now need to run two instance of the daemon and connect them to each other (without a connection to another instance the daemon will not accept RPC requests)
* Run first instance with `./coind --p2p-bind-port 28080 --allow-local-ip`
* Run second instance with `./coind --p2p-bind-port 5011 --rpc-bind-port 5010 --add-peer 0.0.0.0:28080 --allow-local-ip`
* You should now have a local testnet setup. The ports can be changes as long as the second instance is pointed to the first instance, obviously
*Credit to surfer43 for these instructions*
### JSON-RPC Commands from CLI
2014-05-17 01:15:08 +02:00
Documentation for JSON-RPC commands can be found here:
* Daemon https://wiki.bytecoin.org/wiki/Daemon_JSON_RPC_API
* Wallet https://wiki.bytecoin.org/wiki/Wallet_JSON_RPC_API
Curl can be used to use the JSON-RPC commands from command-line. Here is an example of calling `getblockheaderbyheight` for block 100:
```bash
2014-06-25 19:04:56 +02:00
curl 127.0.0.1:18081/json_rpc -d '{"method":"getblockheaderbyheight","params":{"height":100}}'
```
### Monitoring Your Pool
* To inspect and make changes to redis I suggest using [redis-commander](https://github.com/joeferner/redis-commander)
* To monitor server load for CPU, Network, IO, etc - I suggest using [New Relic](http://newrelic.com/)
* To keep your pool node script running in background, logging to file, and automatically restarting if it crashes - I suggest using [forever](https://github.com/nodejitsu/forever)
Donations
---------
* BTC: `1667jMt7NTZDaC8WXAxtMYBR8DPWCVoU4d`
* MRO: `48Y4SoUJM5L3YXBEfNQ8bFNsvTNsqcH5Rgq8RF7BwpgvTBj2xr7CmWVanaw7L4U9MnZ4AG7U6Pn1pBhfQhFyFZ1rL1efL8z`
2014-05-15 21:13:45 +02:00
Credits
===
* [LucasJones](//github.com/LucasJones) - Co-dev on this project; did tons of debugging for binary structures and fixing them. Pool couldn't have been made without him.
* [surfer43](//github.com/iamasupernova) - Did lots of testing during development to help figure out bugs and get them fixed
2014-06-25 19:04:56 +02:00
* [wallet42](http://moneropool.com) - Funded development of payment denominating and min threshold feature
2014-05-15 21:13:45 +02:00
* [Wolf0](https://bitcointalk.org/index.php?action=profile;u=80740) - Helped try to deobfuscate some of the daemon code for getting a bug fixed
* [Tacotime](https://bitcointalk.org/index.php?action=profile;u=19270) - helping with figuring out certain problems and lead the bounty for this project's creation
2014-05-12 05:49:57 +02:00
License
-------
Released under the GNU General Public License v2
http://www.gnu.org/licenses/gpl-2.0.html