From 97fc25c90b1c0c1f174672bae15bcfe8c85bf36d Mon Sep 17 00:00:00 2001 From: joshuayabut Date: Wed, 16 Nov 2016 22:46:07 +0000 Subject: [PATCH] Initial Z-NOMP commit --- .gitignore | 2 +- README.md | 368 ++++---------------------------------------- config_example.json | 4 +- package.json | 9 +- 4 files changed, 36 insertions(+), 347 deletions(-) diff --git a/.gitignore b/.gitignore index b2f46e4..4a50d4a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ node_modules/ .idea/ config.json pool_configs/*.json -!pool_configs/litecoin_example.json +!pool_configs/zclassic_example.json diff --git a/README.md b/README.md index e27806e..814a278 100644 --- a/README.md +++ b/README.md @@ -1,122 +1,25 @@ -# NOMP ![NOMP Logo](http://zone117x.github.io/node-open-mining-portal/logo.svg "NOMP Logo") -#### Node Open Mining Portal +# Z-NOMP +#### Zclassic - Node Open Mining Portal + +This is a Zclassic mining pool based off of Node Open Mining Portal. -This portal is an extremely efficient, highly scalable, all-in-one, easy to setup cryptocurrency mining pool written -entirely in Node.js. It contains a stratum poolserver; reward/payment/share processor; and a (*not yet completed*) -responsive user-friendly front-end website featuring mining instructions, in-depth live statistics, and an admin center. #### Production Usage Notice -This is beta software. All of the following are things that can change and break an existing NOMP setup: functionality of any feature, structure of configuration files and structure of redis data. If you use this software in production then *DO NOT* pull new code straight into production usage because it can and often will break your setup and require you to tweak things like config files or redis data. +This is beta software. All of the following are things that can change and break an existing Z-NOMP setup: functionality of any feature, structure of configuration files and structure of redis data. If you use this software in production then *DO NOT* pull new code straight into production usage because it can and often will break your setup and require you to tweak things like config files or redis data. #### Paid Solution Usage of this software requires abilities with sysadmin, database admin, coin daemons, and sometimes a bit of programming. Running a production pool can literally be more work than a full-time job. -**Coin switching & auto-exchanging for payouts in BTC/LTC** to miners is a feature that very likely will not be included in this project. - - -#### Table of Contents -* [Features](#features) - * [Attack Mitigation](#attack-mitigation) - * [Security](#security) - * [Planned Features](#planned-features) -* [Community Support](#community--support) -* [Usage](#usage) - * [Requirements](#requirements) - * [Setting Up Coin Daemon](#0-setting-up-coin-daemon) - * [Downloading & Installing](#1-downloading--installing) - * [Configuration](#2-configuration) - * [Portal Config](#portal-config) - * [Coin Config](#coin-config) - * [Pool Config](#pool-config) - * [Setting Up Blocknotify](#optional-recommended-setting-up-blocknotify) - * [Starting the Portal](#3-start-the-portal) - * [Upgrading NOMP](#upgrading-nomp) -* [Donations](#donations) -* [Credits](#credits) -* [License](#license) - - - - -### Features - -* For the pool server it uses the highly efficient [node-stratum-pool](//github.com/zone117x/node-stratum-pool) module which -supports vardiff, POW & POS, transaction messages, anti-DDoS, IP banning, [several hashing algorithms](//github.com/zone117x/node-stratum-pool#hashing-algorithms-supported). - -* The portal has an [MPOS](//github.com/MPOS/php-mpos) compatibility mode so that the it can -function as a drop-in-replacement for [python-stratum-mining](//github.com/Crypto-Expert/stratum-mining). This -mode can be enabled in the configuration and will insert shares into a MySQL database in the format which MPOS expects. -For a direct tutorial see the wiki page [Setting up NOMP for MPOS usage](//github.com/zone117x/node-open-mining-portal/wiki/Setting-up-NOMP-for-MPOS-usage). - -* Multi-pool ability - this software was built from the ground up to run with multiple coins simultaneously (which can -have different properties and hashing algorithms). It can be used to create a pool for a single coin or for multiple -coins at once. The pools use clustering to load balance across multiple CPU cores. - -* For reward/payment processing, shares are inserted into Redis (a fast NoSQL key/value store). The PROP (proportional) -reward system is used with [Redis Transactions](http://redis.io/topics/transactions) for secure and super speedy payouts. -There is zero risk to the pool operator. Shares from rounds resulting in orphaned blocks will be merged into share in the -current round so that each and every share will be rewarded - -* This portal does not have user accounts/logins/registrations. Instead, miners simply use their coin address for stratum -authentication. A minimalistic HTML5 front-end connects to the portals statistics API to display stats from from each -pool such as connected miners, network/pool difficulty/hash rate, etc. - -* Coin-switching ports using coin-networks and crypto-exchange APIs to detect profitability. Miner's connect to these ports -with their public key which NOMP uses to derive an address for any coin needed to be paid out. - - -#### Attack Mitigation -* Detects and thwarts socket flooding (garbage data sent over socket in order to consume system resources). -* Detects and thwarts zombie miners (botnet infected computers connecting to your server to use up sockets but not sending any shares). -* Detects and thwarts invalid share attacks: - * NOMP is not vulnerable to the low difficulty share exploits happening to other pool servers. Other pool server - software has hardcoded guesstimated max difficulties for new hashing algorithms while NOMP dynamically generates the - max difficulty for each algorithm based on values founds in coin source code. - * IP banning feature which on a configurable threshold will ban an IP for a configurable amount of time if the miner - submits over a configurable threshold of invalid shares. -* NOMP is written in Node.js which uses a single thread (async) to handle connections rather than the overhead of one -thread per connection, and clustering is also implemented so all CPU cores are taken advantage of. - - -#### Security -NOMP has some implicit security advantages for pool operators and miners: -* Without a registration/login system, non-security-oriented miners reusing passwords across pools is no longer a concern. -* Automated payouts by default and pool profits are sent to another address so pool wallets aren't plump with coins - -giving hackers little reward and keeping your pool from being a target. -* Miners can notice lack of automated payments as a possible early warning sign that an operator is about to run off with their coins. - - -#### Planned Features - -* NOMP API - Used by the website to display stats and information about the pool(s) on the portal's front-end website, -and by the NOMP Desktop app to retrieve a list of available coins (and version-bytes for local wallet/address generation). - -* To reduce variance for pools just starting out which have little to no hashing power a feature is planned which will -allow your own pool to connect upstream to a larger pool server. It will request work from the larger pool then -redistribute the work to our own connected miners. - - ### Community / Support IRC -* Support / general discussion join #nomp: https://webchat.freenode.net/?channels=#nomp -* Development discussion join #nomp-dev: https://webchat.freenode.net/?channels=#nomp-dev +* Support / general discussion join: https://zclassic.herokuapp.com -Join our subreddit [/r/nomp](http://reddit.com/r/nomp)! +If your pool uses Z-NOMP let us know and we will list your website here. -*Having problems getting the portal running due to some module dependency error?* It's probably because you -didn't follow the instructions in this README. Please __read the usage instructions__ including [requirements](#requirements) and [downloading/installing](#1-downloading--installing). If you've followed the instructions completely and are still having problems then open an issue here on github or join our #nomp IRC channel and explain your problem :). +##### Some pools using Z-NOMP or node-stratum-module: +* //to be added -If your pool uses NOMP let us know and we will list your website here. - -##### Some pools using NOMP or node-stratum-module: -* http://clevermining.com -* http://suchpool.pw -* http://hashfaster.com -* http://miningpoolhub.com -* http://kryptochaos.com -* http://miningpools.tk -* http://umine.co.uk Usage ===== @@ -140,7 +43,7 @@ you are using - a good place to start with redis is [data persistence](http://re Follow the build/install instructions for your coin daemon. Your coin.conf file should end up looking something like this: ``` daemon=1 -rpcuser=litecoinrpc +rpcuser=zclassicrpc rpcpassword=securepassword rpcport=19332 ``` @@ -159,208 +62,16 @@ a good pool operator. For starters be sure to read: Clone the repository and run `npm update` for all the dependencies to be installed: ```bash -git clone https://github.com/zone117x/node-open-mining-portal.git nomp -cd nomp +sudo apt-get install build-essential libsodium-dev npm +sudo npm install n -g +sudo n 0.10.13 +git clone https://github.com/joshuayabut/node-open-mining-portal.git z-nomp +cd z-nomp npm update ``` -#### 2) Configuration - -##### Portal config -Inside the `config_example.json` file, ensure the default configuration will work for your environment, then copy the file to `config.json`. - -Explanation for each field: -````javascript -{ - /* Specifies the level of log output verbosity. Anything more severe than the level specified - will also be logged. */ - "logLevel": "debug", //or "warning", "error" - - /* By default NOMP logs to console and gives pretty colors. If you direct that output to a - log file then disable this feature to avoid nasty characters in your log file. */ - "logColors": true, - - - /* The NOMP CLI (command-line interface) will listen for commands on this port. For example, - blocknotify messages are sent to NOMP through this. */ - "cliPort": 17117, - - /* By default 'forks' is set to "auto" which will spawn one process/fork/worker for each CPU - 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. */ - "clustering": { - "enabled": true, - "forks": "auto" - }, - - /* Pool config file will inherit these default values if they are not set. */ - "defaultPoolConfigs": { - - /* Poll RPC daemons for new blocks every this many milliseconds. */ - "blockRefreshInterval": 1000, - - /* If no new blocks are available for this many seconds update and rebroadcast job. */ - "jobRebroadcastTimeout": 55, - - /* Disconnect workers that haven't submitted shares for this many seconds. */ - "connectionTimeout": 600, - - /* (For MPOS mode) Store the block hashes for shares that aren't block candidates. */ - "emitInvalidBlockHashes": false, - - /* This option will only authenticate miners using an address or mining key. */ - "validateWorkerUsername": true, - - /* Enable for client IP addresses to be detected when using a load balancer with TCP - proxy protocol enabled, such as HAProxy with 'send-proxy' param: - http://haproxy.1wt.eu/download/1.5/doc/configuration.txt */ - "tcpProxyProtocol": false, - - /* If under low-diff share attack we can ban their IP to reduce system/network load. If - running behind HAProxy be sure to enable 'tcpProxyProtocol', otherwise you'll end up - banning your own IP address (and therefore all workers). */ - "banning": { - "enabled": true, - "time": 600, //How many seconds to ban worker for - "invalidPercent": 50, //What percent of invalid shares triggers ban - "checkThreshold": 500, //Perform check when this many shares have been submitted - "purgeInterval": 300 //Every this many seconds clear out the list of old bans - }, - - /* Used for storing share and block submission data and payment processing. */ - "redis": { - "host": "127.0.0.1", - "port": 6379 - } - }, - - /* This is the front-end. Its not finished. When it is finished, this comment will say so. */ - "website": { - "enabled": true, - /* If you are using a reverse-proxy like nginx to display the website then set this to - 127.0.0.1 to not expose the port. */ - "host": "0.0.0.0", - "port": 80, - /* Used for displaying stratum connection data on the Getting Started page. */ - "stratumHost": "cryppit.com", - "stats": { - /* Gather stats to broadcast to page viewers and store in redis for historical stats - every this many seconds. */ - "updateInterval": 15, - /* How many seconds to hold onto historical stats. Currently set to 24 hours. */ - "historicalRetention": 43200, - /* How many seconds worth of shares should be gathered to generate hashrate. */ - "hashrateWindow": 300 - }, - /* Not done yet. */ - "adminCenter": { - "enabled": true, - "password": "password" - } - }, - - /* Redis instance of where to store global portal data such as historical stats, proxy states, - ect.. */ - "redis": { - "host": "127.0.0.1", - "port": 6379 - }, - - - /* With this switching configuration, you can setup ports that accept miners for work based on - a specific algorithm instead of a specific coin. Miners that connect to these ports are - automatically switched a coin determined by the server. The default coin is the first - configured pool for each algorithm and coin switching can be triggered using the - cli.js script in the scripts folder. - - Miners connecting to these switching ports must use their public key in the format of - RIPEMD160(SHA256(public-key)). An address for each type of coin is derived from the miner's - public key, and payments are sent to that address. */ - "switching": { - "switch1": { - "enabled": false, - "algorithm": "sha256", - "ports": { - "3333": { - "diff": 10, - "varDiff": { - "minDiff": 16, - "maxDiff": 512, - "targetTime": 15, - "retargetTime": 90, - "variancePercent": 30 - } - } - } - }, - "switch2": { - "enabled": false, - "algorithm": "scrypt", - "ports": { - "4444": { - "diff": 10, - "varDiff": { - "minDiff": 16, - "maxDiff": 512, - "targetTime": 15, - "retargetTime": 90, - "variancePercent": 30 - } - } - } - }, - "switch3": { - "enabled": false, - "algorithm": "x11", - "ports": { - "5555": { - "diff": 0.001 - } - } - } - }, - - "profitSwitch": { - "enabled": false, - "updateInterval": 600, - "depth": 0.90, - "usePoloniex": true, - "useCryptsy": true, - "useMintpal": true - } -} -```` - - -##### Coin config -Inside the `coins` directory, ensure a json file exists for your coin. If it does not you will have to create it. -Here is an example of the required fields: -````javascript -{ - "name": "Litecoin", - "symbol": "ltc", - "algorithm": "scrypt", - - /* Magic value only required for setting up p2p block notifications. It is found in the daemon - source code as the pchMessageStart variable. - For example, litecoin mainnet magic: http://git.io/Bi8YFw - And for litecoin testnet magic: http://git.io/NXBYJA */ - "peerMagic": "fbc0b6db", //optional - "peerMagicTestnet": "fcc1b7dc" //optional - - //"txMessages": false, //options - defaults to false - - //"mposDiffMultiplier": 256, //options - only for x11 coins in mpos mode -} -```` - -For additional documentation how to configure coins and their different algorithms -see [these instructions](//github.com/zone117x/node-stratum-pool#module-usage). - - ##### Pool config -Take a look at the example json file inside the `pool_configs` directory. Rename it to `yourcoin.json` and change the +Take a look at the example json file inside the `pool_configs` directory. Rename it to `zclassic.json` and change the example fields to fit your setup. Description of options: @@ -375,14 +86,10 @@ Description of options: /* Block rewards go to the configured pool wallet address to later be paid out to miners, except for a percentage that can go to, for examples, pool operator(s) as pool fees or or to donations address. Addresses or hashed public keys can be used. Here is an example - of rewards going to the main pool op, a pool co-owner, and NOMP donation. */ + of rewards going to the main pool op, a pool co-owner, and Z-NOMP donation. */ "rewardRecipients": { "n37vuNFkXfk15uFnGoVyHZ6PYQxppD3QqK": 1.5, //1.5% goes to pool op "mirj3LtZxbSTharhtXvotqtJXUY7ki5qfx": 0.5, //0.5% goes to a pool co-owner - - /* 0.1% donation to NOMP. This pubkey can accept any type of coin, please leave this in - your config to help support NOMP development. */ - "22851477d63a085dbc2398c8430af1c09e7343f6": 0.1 }, "paymentProcessing": { @@ -469,7 +176,7 @@ Description of options: "port": 3306, //MySQL db port "user": "me", //MySQL db user "password": "mypass", //MySQL db password - "database": "ltc", //MySQL db database name + "database": "zcl", //MySQL db database name /* Checks for valid password in database when miners connect. */ "checkPassword": true, @@ -482,22 +189,15 @@ Description of options: ```` -You can create as many of these pool config files as you want (such as one pool per coin you which to operate). -If you are creating multiple pools, ensure that they have unique stratum ports. - -For more information on these configuration options see the [pool module documentation](https://github.com/zone117x/node-stratum-pool#module-usage) - - - ##### [Optional, recommended] Setting up blocknotify 1. In `config.json` set the port and password for `blockNotifyListener` 2. In your daemon conf file set the `blocknotify` command to use: ``` node [path to cli.js] [coin name in config] [block hash symbol] ``` -Example: inside `dogecoin.conf` add the line +Example: inside `zclassic.conf` add the line ``` -blocknotify=node /home/nomp/scripts/cli.js blocknotify dogecoin %s +blocknotify=node /home/z-nomp/scripts/cli.js blocknotify zclassic %s ``` Alternatively, you can use a more efficient block notify script written in pure C. Build and usage instructions @@ -516,33 +216,23 @@ in case the master process crashes. * Use something like [redis-commander](https://github.com/joeferner/redis-commander) to have a nice GUI for exploring your redis database. * Use something like [logrotator](http://www.thegeekstuff.com/2010/07/logrotate-examples/) to rotate log -output from NOMP. -* Use [New Relic](http://newrelic.com/) to monitor your NOMP instance and server performance. +output from Z-NOMP. +* Use [New Relic](http://newrelic.com/) to monitor your Z-NOMP instance and server performance. -#### Upgrading NOMP -When updating NOMP to the latest code its important to not only `git pull` the latest from this repo, but to also update +#### Upgrading Z-NOMP +When updating Z-NOMP to the latest code its important to not only `git pull` the latest from this repo, but to also update the `node-stratum-pool` and `node-multi-hashing` modules, and any config files that may have been changed. -* Inside your NOMP directory (where the init.js script is) do `git pull` to get the latest NOMP code. +* Inside your Z-NOMP directory (where the init.js script is) do `git pull` to get the latest Z-NOMP code. * Remove the dependenices 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` and `pool_configs/coin.json` configurations 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. -Donations ---------- -To support development of this project feel free to donate :) - -* BTC: `1KRotMnQpxu3sePQnsVLRy3EraRFYfJQFR` -* LTC: `LKfavSDJmwiFdcgaP1bbu46hhyiWw5oFhE` -* VTC: `VgW4uFTZcimMSvcnE4cwS3bjJ6P8bcTykN` -* MAX: `mWexUXRCX5PWBmfh34p11wzS5WX2VWvTRT` -* QRK: `QehPDAhzVQWPwDPQvmn7iT3PoFUGT7o8bC` -* DRK: `XcQmhp8ANR7okWAuArcNFZ2bHSB81jpapQ` -* DOGE: `DBGGVtwAAit1NPZpRm5Nz9VUFErcvVvHYW` -* Cryptsy Trade Key: `254ca13444be14937b36c44ba29160bd8f02ff76` Credits ------- +* [Matthew Little / zone117x](https://github.com/zone117x) - developer of NOMP +* [Sammy Libre / sammy007](https://github.com/sammy007) - developer of Golang Equihash solution verification function * [Jerry Brady / mintyfresh68](https://github.com/bluecircle) - got coin-switching fully working and developed proxy-per-algo feature * [Tony Dobbs](http://anthonydobbs.com) - designs for front-end and created the NOMP logo * [LucasJones](//github.com/LucasJones) - got p2p block notify working and implemented additional hashing algos @@ -558,6 +248,4 @@ Credits License ------- -Released under the GNU General Public License v2 - -http://www.gnu.org/licenses/gpl-2.0.html +Released under the MIT License. See LICENSE file. diff --git a/config_example.json b/config_example.json index a801998..0dc267f 100644 --- a/config_example.json +++ b/config_example.json @@ -10,7 +10,7 @@ }, "defaultPoolConfigs": { - "blockRefreshInterval": 1000, + "blockRefreshInterval": 30, "jobRebroadcastTimeout": 55, "connectionTimeout": 600, "emitInvalidBlockHashes": false, @@ -40,7 +40,7 @@ "hashrateWindow": 300 }, "adminCenter": { - "enabled": true, + "enabled": false, "password": "password" } }, diff --git a/package.json b/package.json index f6467a2..e19002c 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "litecoin", "scrypt" ], - "homepage": "https://github.com/zone117x/node-open-mining-portal", + "homepage": "https://github.com/joshuayabut/node-open-mining-portal", "bugs": { - "url": "https://github.com/zone117x/node-open-mining-portal/issues" + "url": "https://github.com/joshuayabut/node-open-mining-portal/issues" }, "license": "GPL-2.0", "author": "Matthew Little", @@ -28,10 +28,10 @@ }, "repository": { "type": "git", - "url": "https://github.com/zone117x/node-open-mining-portal.git" + "url": "https://github.com/joshuayabut/node-open-mining-portal.git" }, "dependencies": { - "stratum-pool": "git://github.com/zone117x/node-stratum-pool.git", + "stratum-pool": "https://github.com/joshuayabut/node-stratum-pool.git", "dateformat": "*", "node-json-minify": "*", "redis": "*", @@ -52,3 +52,4 @@ "node": ">=0.10" } } +