项目作者: Actinium-project

项目描述 :
Actinium - Mining Pool
高级语言: JavaScript
项目地址: git://github.com/Actinium-project/acm-pool.git
创建时间: 2018-04-27T21:26:23Z
项目社区:https://github.com/Actinium-project/acm-pool

开源协议:GNU General Public License v2.0

下载


This is a slightly modified version of the original Node Openi Mining Portal

" class="reference-link">NOMP NOMP Logo

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.

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

  • For the pool server it uses the highly efficient node-stratum-pool module which
    supports vardiff, POW & POS, transaction messages, anti-DDoS, IP banning, several hashing algorithms.

  • The portal has an MPOS compatibility mode so that the it can
    function as a drop-in-replacement for python-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.

  • 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 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

Join our subreddit /r/nomp!

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 and 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 :).

If your pool uses NOMP let us know and we will list your website here.

Some pools using NOMP or node-stratum-module:

Usage

Requirements

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.

Redis security warning: 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.

0) Setting up coin daemon

Follow the build/install instructions for your coin daemon. Your coin.conf file should end up looking something like this:

  1. daemon=1
  2. rpcuser=litecoinrpc
  3. rpcpassword=securepassword
  4. rpcport=19332

For redundancy, its recommended to have at least two daemon instances running in case one drops out-of-sync or offline,
all instances will be polled for block/transaction updates and be used for submitting blocks. Creating a backup daemon
involves spawning a daemon using the -datadir=/backup command-line argument which creates a new daemon instance with
it’s own config directory and coin.conf file. Learn about the daemon, how to use it and how it works if you want to be
a good pool operator. For starters be sure to read:

1) Downloading & Installing

Clone the repository and run npm update for all the dependencies to be installed:

  1. git clone https://github.com/zone117x/node-open-mining-portal.git nomp
  2. cd nomp
  3. 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:

  1. {
  2. /* Specifies the level of log output verbosity. Anything more severe than the level specified
  3. will also be logged. */
  4. "logLevel": "debug", //or "warning", "error"
  5. /* By default NOMP logs to console and gives pretty colors. If you direct that output to a
  6. log file then disable this feature to avoid nasty characters in your log file. */
  7. "logColors": true,
  8. /* The NOMP CLI (command-line interface) will listen for commands on this port. For example,
  9. blocknotify messages are sent to NOMP through this. */
  10. "cliPort": 17117,
  11. /* By default 'forks' is set to "auto" which will spawn one process/fork/worker for each CPU
  12. core in your system. Each of these workers will run a separate instance of your pool(s),
  13. and the kernel will load balance miners using these forks. Optionally, the 'forks' field
  14. can be a number for how many forks will be spawned. */
  15. "clustering": {
  16. "enabled": true,
  17. "forks": "auto"
  18. },
  19. /* Pool config file will inherit these default values if they are not set. */
  20. "defaultPoolConfigs": {
  21. /* Poll RPC daemons for new blocks every this many milliseconds. */
  22. "blockRefreshInterval": 1000,
  23. /* If no new blocks are available for this many seconds update and rebroadcast job. */
  24. "jobRebroadcastTimeout": 55,
  25. /* Disconnect workers that haven't submitted shares for this many seconds. */
  26. "connectionTimeout": 600,
  27. /* (For MPOS mode) Store the block hashes for shares that aren't block candidates. */
  28. "emitInvalidBlockHashes": false,
  29. /* This option will only authenticate miners using an address or mining key. */
  30. "validateWorkerUsername": true,
  31. /* Enable for client IP addresses to be detected when using a load balancer with TCP
  32. proxy protocol enabled, such as HAProxy with 'send-proxy' param:
  33. http://haproxy.1wt.eu/download/1.5/doc/configuration.txt */
  34. "tcpProxyProtocol": false,
  35. /* If under low-diff share attack we can ban their IP to reduce system/network load. If
  36. running behind HAProxy be sure to enable 'tcpProxyProtocol', otherwise you'll end up
  37. banning your own IP address (and therefore all workers). */
  38. "banning": {
  39. "enabled": true,
  40. "time": 600, //How many seconds to ban worker for
  41. "invalidPercent": 50, //What percent of invalid shares triggers ban
  42. "checkThreshold": 500, //Perform check when this many shares have been submitted
  43. "purgeInterval": 300 //Every this many seconds clear out the list of old bans
  44. },
  45. /* Used for storing share and block submission data and payment processing. */
  46. "redis": {
  47. "host": "127.0.0.1",
  48. "port": 6379
  49. }
  50. },
  51. /* This is the front-end. Its not finished. When it is finished, this comment will say so. */
  52. "website": {
  53. "enabled": true,
  54. /* If you are using a reverse-proxy like nginx to display the website then set this to
  55. 127.0.0.1 to not expose the port. */
  56. "host": "0.0.0.0",
  57. "port": 80,
  58. /* Used for displaying stratum connection data on the Getting Started page. */
  59. "stratumHost": "cryppit.com",
  60. "stats": {
  61. /* Gather stats to broadcast to page viewers and store in redis for historical stats
  62. every this many seconds. */
  63. "updateInterval": 15,
  64. /* How many seconds to hold onto historical stats. Currently set to 24 hours. */
  65. "historicalRetention": 43200,
  66. /* How many seconds worth of shares should be gathered to generate hashrate. */
  67. "hashrateWindow": 300
  68. },
  69. /* Not done yet. */
  70. "adminCenter": {
  71. "enabled": true,
  72. "password": "password"
  73. }
  74. },
  75. /* Redis instance of where to store global portal data such as historical stats, proxy states,
  76. ect.. */
  77. "redis": {
  78. "host": "127.0.0.1",
  79. "port": 6379
  80. },
  81. /* With this switching configuration, you can setup ports that accept miners for work based on
  82. a specific algorithm instead of a specific coin. Miners that connect to these ports are
  83. automatically switched a coin determined by the server. The default coin is the first
  84. configured pool for each algorithm and coin switching can be triggered using the
  85. cli.js script in the scripts folder.
  86. Miners connecting to these switching ports must use their public key in the format of
  87. RIPEMD160(SHA256(public-key)). An address for each type of coin is derived from the miner's
  88. public key, and payments are sent to that address. */
  89. "switching": {
  90. "switch1": {
  91. "enabled": false,
  92. "algorithm": "sha256",
  93. "ports": {
  94. "3333": {
  95. "diff": 10,
  96. "varDiff": {
  97. "minDiff": 16,
  98. "maxDiff": 512,
  99. "targetTime": 15,
  100. "retargetTime": 90,
  101. "variancePercent": 30
  102. }
  103. }
  104. }
  105. },
  106. "switch2": {
  107. "enabled": false,
  108. "algorithm": "scrypt",
  109. "ports": {
  110. "4444": {
  111. "diff": 10,
  112. "varDiff": {
  113. "minDiff": 16,
  114. "maxDiff": 512,
  115. "targetTime": 15,
  116. "retargetTime": 90,
  117. "variancePercent": 30
  118. }
  119. }
  120. }
  121. },
  122. "switch3": {
  123. "enabled": false,
  124. "algorithm": "x11",
  125. "ports": {
  126. "5555": {
  127. "diff": 0.001
  128. }
  129. }
  130. }
  131. },
  132. "profitSwitch": {
  133. "enabled": false,
  134. "updateInterval": 600,
  135. "depth": 0.90,
  136. "usePoloniex": true,
  137. "useCryptsy": true,
  138. "useMintpal": true
  139. }
  140. }
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:

  1. {
  2. "name": "Litecoin",
  3. "symbol": "ltc",
  4. "algorithm": "scrypt",
  5. /* Magic value only required for setting up p2p block notifications. It is found in the daemon
  6. source code as the pchMessageStart variable.
  7. For example, litecoin mainnet magic: http://git.io/Bi8YFw
  8. And for litecoin testnet magic: http://git.io/NXBYJA */
  9. "peerMagic": "fbc0b6db", //optional
  10. "peerMagicTestnet": "fcc1b7dc" //optional
  11. //"txMessages": false, //options - defaults to false
  12. //"mposDiffMultiplier": 256, //options - only for x11 coins in mpos mode
  13. }

For additional documentation how to configure coins and their different algorithms
see these instructions.

Pool config

Take a look at the example json file inside the pool_configs directory. Rename it to yourcoin.json and change the
example fields to fit your setup.

Description of options:

  1. {
  2. "enabled": true, //Set this to false and a pool will not be created from this config file
  3. "coin": "litecoin.json", //Reference to coin config file in 'coins' directory
  4. "address": "mi4iBXbBsydtcc5yFmsff2zCFVX4XG7qJc", //Address to where block rewards are given
  5. /* Block rewards go to the configured pool wallet address to later be paid out to miners,
  6. except for a percentage that can go to, for examples, pool operator(s) as pool fees or
  7. or to donations address. Addresses or hashed public keys can be used. Here is an example
  8. of rewards going to the main pool op, a pool co-owner, and NOMP donation. */
  9. "rewardRecipients": {
  10. "n37vuNFkXfk15uFnGoVyHZ6PYQxppD3QqK": 1.5, //1.5% goes to pool op
  11. "mirj3LtZxbSTharhtXvotqtJXUY7ki5qfx": 0.5, //0.5% goes to a pool co-owner
  12. /* 0.1% donation to NOMP. This pubkey can accept any type of coin, please leave this in
  13. your config to help support NOMP development. */
  14. "22851477d63a085dbc2398c8430af1c09e7343f6": 0.1
  15. },
  16. "paymentProcessing": {
  17. "enabled": true,
  18. /* Every this many seconds get submitted blocks from redis, use daemon RPC to check
  19. their confirmation status, if confirmed then get shares from redis that contributed
  20. to block and send out payments. */
  21. "paymentInterval": 30,
  22. /* Minimum number of coins that a miner must earn before sending payment. Typically,
  23. a higher minimum means less transactions fees (you profit more) but miners see
  24. payments less frequently (they dislike). Opposite for a lower minimum payment. */
  25. "minimumPayment": 0.01,
  26. /* This daemon is used to send out payments. It MUST be for the daemon that owns the
  27. configured 'address' that receives the block rewards, otherwise the daemon will not
  28. be able to confirm blocks or send out payments. */
  29. "daemon": {
  30. "host": "127.0.0.1",
  31. "port": 19332,
  32. "user": "testuser",
  33. "password": "testpass"
  34. }
  35. },
  36. /* Each pool can have as many ports for your miners to connect to as you wish. Each port can
  37. be configured to use its own pool difficulty and variable difficulty settings. varDiff is
  38. optional and will only be used for the ports you configure it for. */
  39. "ports": {
  40. "3032": { //A port for your miners to connect to
  41. "diff": 32, //the pool difficulty for this port
  42. /* Variable difficulty is a feature that will automatically adjust difficulty for
  43. individual miners based on their hashrate in order to lower networking overhead */
  44. "varDiff": {
  45. "minDiff": 8, //Minimum difficulty
  46. "maxDiff": 512, //Network difficulty will be used if it is lower than this
  47. "targetTime": 15, //Try to get 1 share per this many seconds
  48. "retargetTime": 90, //Check to see if we should retarget every this many seconds
  49. "variancePercent": 30 //Allow time to very this % from target without retargeting
  50. }
  51. },
  52. "3256": { //Another port for your miners to connect to, this port does not use varDiff
  53. "diff": 256 //The pool difficulty
  54. }
  55. },
  56. /* More than one daemon instances can be setup in case one drops out-of-sync or dies. */
  57. "daemons": [
  58. { //Main daemon instance
  59. "host": "127.0.0.1",
  60. "port": 19332,
  61. "user": "testuser",
  62. "password": "testpass"
  63. }
  64. ],
  65. /* This allows the pool to connect to the daemon as a node peer to receive block updates.
  66. It may be the most efficient way to get block updates (faster than polling, less
  67. intensive than blocknotify script). It requires the additional field "peerMagic" in
  68. the coin config. */
  69. "p2p": {
  70. "enabled": false,
  71. /* Host for daemon */
  72. "host": "127.0.0.1",
  73. /* Port configured for daemon (this is the actual peer port not RPC port) */
  74. "port": 19333,
  75. /* If your coin daemon is new enough (i.e. not a shitcoin) then it will support a p2p
  76. feature that prevents the daemon from spamming our peer node with unnecessary
  77. transaction data. Assume its supported but if you have problems try disabling it. */
  78. "disableTransactions": true
  79. },
  80. /* Enabled this mode and shares will be inserted into in a MySQL database. You may also want
  81. to use the "emitInvalidBlockHashes" option below if you require it. The config options
  82. "redis" and "paymentProcessing" will be ignored/unused if this is enabled. */
  83. "mposMode": {
  84. "enabled": false,
  85. "host": "127.0.0.1", //MySQL db host
  86. "port": 3306, //MySQL db port
  87. "user": "me", //MySQL db user
  88. "password": "mypass", //MySQL db password
  89. "database": "ltc", //MySQL db database name
  90. /* Checks for valid password in database when miners connect. */
  91. "checkPassword": true,
  92. /* Unregistered workers can automatically be registered (added to database) on stratum
  93. worker authentication if this is true. */
  94. "autoCreateWorker": false
  95. }
  96. }

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

  1. In config.json set the port and password for blockNotifyListener
  2. In your daemon conf file set the blocknotify command to use:
    1. node [path to cli.js] [coin name in config] [block hash symbol]
    Example: inside dogecoin.conf add the line
    1. blocknotify=node /home/nomp/scripts/cli.js blocknotify dogecoin %s

Alternatively, you can use a more efficient block notify script written in pure C. Build and usage instructions
are commented in scripts/blocknotify.c.

[Running as Daemon] with systemd

  1. [Unit]
  2. Description=Stratum Server Daemon
  3. After=network.target
  4. [Service]
  5. WorkingDirectory=/PATH_TO_NOMP
  6. User=root
  7. Group=root
  8. Type=simple
  9. ExecStart=node /PATH_TO_NOMP/init.js
  10. Restart=on-failure
  11. RestartSec=5s
  12. PrivateTmp=true
  13. [Install]
  14. WantedBy=multi-user.target

3) Start the portal

  1. node init.js
Optional enhancements for your awesome new mining pool server setup:
  • Use something like forever to keep the node script running
    in case the master process crashes.
  • Use something like redis-commander to have a nice GUI
    for exploring your redis database.
  • Use something like logrotator to rotate log
    output from NOMP.
  • Use New Relic to monitor your 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
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.
  • 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

License

Released under the GNU General Public License v2

http://www.gnu.org/licenses/gpl-2.0.html