Coder Social home page Coder Social logo

mining-pool's Introduction

Build

  1. install redis
  2. install alephium full node
  3. install node.js(>=14) and npm(>=8)

Or:

  1. deploy with Docker Compose

Run

configs explanation:

{
    "logPath": "./logs/",               // log path

    "connectionTimeout": 600,           // disconnect workers that haven't submitted shares for this many seconds
    "maxConnectionsFromSameIP": 10,     // limit number of connection from same IP address
    "whitelistIps": [],                 // whitelist IP address from 'maxConnectionsFromSameIP'
	
    "jobExpiryPeriod": 10,              // job expires after set period
	
    "banning": {
        "enabled": true,                // enabled by default
        "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
    },

    "diff1TargetNumZero": 30,           // diff1 target leading zero num
    "pool": {
        "port": 20032,                  // port which the server bind
        "diff": 64,                     // init difficulty
        "proxyProtocol": false,         // enable it to get real client IPs if you are behind a reverse proxy that uses Proxy Protocol v1  
        "varDiff": {
            "minDiff": 16,              // minimum difficulty
            "maxDiff": 4096,            // maximum difficulty
            "targetTime": 15,           // try to get 1 share per this many seconds
            "retargetTime": 90,         // check to see if we should retarget every this many seconds
            "variancePercent": 30       // allow time to very this % from target without retargeting
        }
    },

    "daemon": {
        "host": "127.0.0.1",            // alephium full node host
        "port": 12973,                  // alephium full node rest api port
        "apiKey": "xxx",                // alephium full node api key
        "minerApiPort": 10973           // alephium full node miner api port
    },

    "redis": {
        "host": "127.0.0.1",            // redis host
        "port": 6379                    // redis port
    },

    "withholdPercent": 0.005,           // coinbase reward withhold percent(0.5% by default), used for tx fee mainly
    "rewardEnabled": true,              // enabled by default
    "rewardInterval": 600,              // update miner balances every this many seconds
    "confirmationTime": 30600,          // 510m by default, you can decrease this if your payment addresses have enough balance

    "paymentEnabled": true,             // enabled by default
    "minPaymentCoins": "3.5",           // minimum number of coins that a miner must earn before sending payment
    "paymentInterval": 600,             // send payment every this many seconds
    "txConfirmations": {                // Check tx confirmations to remove/pay back balance after tx
        "chainConfirmations": 10,
        "fromGroupConfirmations": 5,
        "toGroupConfirmations": 5
    },

    "persistence": {                    // persistent shares and blocks
        "enabled": false,               // disabled by default
        "host": "127.0.0.1",            // postgresql ip
        "port": 5432,                   // postgresql port
        "user": "postgres",             // postgresql user
        "password": "postgres",         // postgresql password
        "database": "mining-pool"       // database name
    },
	
    "addresses": [],                    // 4 addresses(we have 4 groups) to where block rewards are given

    "wallet": {
        "name": "",                     // wallet name
        "password": "",                 // wallet password
        "mnemonicPassphrase": ""        // wallet mnemonic passphrase
    }
}

run:

npm install
npm run start

Docker:

The provided docker-compose file allows you to deploy Redis, Postgres and the Alephium mining pool in 2 simple steps:

Clone the repo and move to its folder:

git clone https://github.com/alephium/mining-pool.git && cd mining-pool
docker-compose up -d

(optional) Build different Docker image variants:

  1. From (modified) local sources:
docker build -t mining-pool:latest .
  1. From latest master branch code:
docker build -t mining-pool:latest https://github.com/alephium/mining-pool.git
  1. From latest release:
docker build -t mining-pool:latest -f Dockerfile-release .

The only prerequisites are a synced full node and Docker, and of course your own config file. For this kind of deployment the follliwng sections of the config file should be left unaltered:

    "redis": {
        "host": "redis",                // the "redis" host spawned by docker-compose
        "port": 6379                    // and its port
    },

    "persistence": {                    // persistent shares and blocks
        "enabled": false,               // disabled by default
        "host": "postgres",             // the "postgres" host spawned by docker-compose
        "port": 5432,                   // its port
        "user": "postgres",             // its user
        "password": "postgres",         // its password
        "database": "postgres"          // and its db name. All as defined in the Compose file.
    },

Lastly, for single-user setups these are suitable payout and reward settings:

    "pool": {
        "port": 20032,                  // port which the server binds to
        "diff": 8,                      // init difficulty

        "varDiff": {
            "minDiff": 1,               // minimum difficulty
            "maxDiff": 4096,            // maximum difficulty
            "targetTime": 10,           // try to get 1 share per this many seconds
            "retargetTime": 90,         // check to see if we should retarget every this many seconds
            "variancePercent": 30       // allow time to very this % from target without retargeting
        }
    },

    "withholdPercent": 0.005,           // Even for single-user pools, this is required to allow the pool to pay tx fees
    "rewardInterval": 600,              // This can be relaxed, but should still be lower than paymentInterval

    "minPaymentCoins": "10",            // Increases the min payout to 10 Alph
    "paymentInterval": 7200,            // Increased to 1 payment every 2 hours.

TLS configuration

...
    "pool": {
        "port": 20443,
        "tls": true,
        "privateKeyPath": "/path/to/pool.key",
        "publicCertPath": "/path/to/pool.pem",
        ...
    }

Generate a basic, self-signed TLS certificate

openssl req -newkey rsa:4096 \
            -x509 \
            -sha256 \
            -days 3650 \
            -nodes \
            -out pool.pem \
            -keyout pool.key

mining-pool's People

Contributors

aciddude avatar ahmedbodi avatar alex-oleshkevich avatar bart-is avatar bitbandi avatar bluecircle avatar bmatusiak avatar bolkin avatar bricecarpentier avatar chrisfranko avatar darcymei avatar dogui1718 avatar earlz avatar hashunlimited avatar jimmyhoffa avatar jonnybravo0311 avatar killerwhile avatar lbqds avatar lucasjones avatar mauroferra avatar mike8643 avatar minkcrypto avatar polarker avatar romanornr avatar stackout avatar suchpool avatar sven-hash avatar valera-rozuvan avatar vekexasia avatar zone117x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mining-pool's Issues

Payment Error

Hi I'm testing the mining-pool, I found 5 blocks, and the rewards are in the pool wallet balance.

When processing the payment I'm getting this error:

2022-12-30T20:08:53.042Z | error | Not enough utxo when transfer
2022-12-30T20:08:53.048Z | debug | Timestamp: 1672430933041, payment data: {"utxos":[{"ref":{"hint":-293566949,"key":"xxxxxxx"},"amount":"3051000000000000000","lockTime":1672458883919,"additionalData":"01030000018564878fcf"},{"ref":{"hint":-293566949,"key":"xxxxxx"},"amount":"3050000000000000000","lockTime":1672451044187,"additionalData":"010300000185640fefdb"}],"groupedBalances":[]}

Does anyone know what is it?

Thanks,

JVX

Performance

Sorry for the question I'm a neophyte. This pool totally in javascript what performance can it have? can it handle 200/500 miners? or is it better to use other programming languages. (Obviously with a good server).
Are there any performance tests that you can consult?
or it is for educational purposes only. Does anyone really use it? do you think written in javascript or python is equivalent as performance reachable?

Thanks in advance

clique is not ready

b

Node was run in a Windows environment, and the pool was Ubuntu. Is there a solution?

Frontend

any possibility of frontend? Or anyone made it anywhere else?

test BzMiner on pool

i tried BzMiner to mine on the pool
i had the following errors:

2022-01-31T06:21:30.165Z | info | Connected to alephium full node
2022-01-31T06:21:35.702Z | info | New miner connected: ::ffff:79.42.223.100:1538
2022-01-31T06:21:35.704Z | error | Unknown stratum method from ::ffff:XX.XX.XX.100:1538: mining.authorize
2022-01-31T06:21:35.809Z | error | Unknown stratum method from ::ffff:XX.XX.XXX.100:1538: alph_submitHashrate
2022-01-31T06:21:45.831Z | error | Unknown stratum method from ::ffff:XX.XX.XXX.100:1538: alph_submitHashrate
2022-01-31T06:21:51.048Z | info | Received share from 1F4Hd4Bv6NQB14uTxCYfVSfHbQVSLz1xfvZHNbzsS2XFa, jobId: e4, chainIndex: 0 -> 3, pool difficulty: 1, share difficulty: 1.9755859375, ip: ::ffff:79.42.223.100

below I also add redis
127.0.0.1:6379> KEYS *

  1. "0:0:shares:currentRound"
  2. "1:0:shares:currentRound"
  3. "2:3:shares:currentRound"
  4. "1:3:shares:currentRound"
  5. "3:2:shares:currentRound"
  6. "0:2:shares:currentRound"
  7. "1:2:shares:currentRound"
  8. "2:1:shares:currentRound"
  9. "1:1:shares:currentRound"
  10. "2:2:shares:currentRound"
  11. "2:0:shares:currentRound"
  12. "3:1:shares:currentRound"
  13. "0:3:shares:currentRound"
  14. "0:1:shares:currentRound"
  15. "3:3:shares:currentRound"
  16. "3:0:shares:currentRound"

Question: PostgreSQL table Shares and Blocks Timestamp

Hi, I'm in Brazil, and my server time zone is local time

I noticed the timestamp records inserted in the tables Shares and Blocks are America Central Time.

Maybe I'm doing something wrong. Is there any way to fix it?

Thanks,
JVX

Infinite loop - Prepare transaction error: not enough utxos for transfer

Pool would sometimes (often) start to print infinite numbers of errors if there is not enough alph for the transaction, instead just waiting for new payout round like this:

[{"address":"WALLET","amount":10.010913350754633}]
2022-06-17T13:15:53.275Z | error | Prepare transaction error: not enough utxos for transfer, will try to transfer later, group: 3, remain balances: [{"address":"WALLET","amount":10.010913350754633}]
2022-06-17T13:15:53.294Z | error | Prepare transaction error: not enough utxos for transfer, will try to transfer later, group: 3, remain balances: [{"address":"WALLET","amount":10.010913350754633}]
2022-06-17T13:15:53.314Z | error | Prepare transaction error: not enough utxos for transfer, will try to transfer later, group: 3, remain balances: [{"address":"WALLET","amount":10.010913350754633}]
2022-06-17T13:15:53.333Z | error | Prepare transaction error: not enough utxos for transfer, will try to transfer later, group: 3, remain balances:

This should be fixed because it uses extreme amount of storage and cpu usage for a bug!

Lots of data in the 'mining notify'

Hi, we would like to list Alph in our pool. We have built our own pool, but the pool is sending a lot of data in the mining notify field, and consuming very large bandwidth.

So I have just tried this nodejs pool, but got the same result.

Any idea what's wrong is it? Is there some config for the node we should modify?

Thanks

ERROR

npm install
npm ERR! code 1
npm ERR! path /home/pool/mining-pool/node_modules/bignum
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild

npm ERR! A complete log of this run can be found in:
npm ERR! /home/pool/.npm/_logs/2022-01-23T18_24_39_816Z-debug.log

Need Assistance with Mining Pool Configuration

Hello everyone,

I hope you're doing well. I'm currently setting up a mining pool on my system using Docker. I've successfully deployed all the necessary components, including Redis and Postgres, and they're all running on the same Docker network. However, I'm encountering an issue with the mining pool.

Whenever I start the mining pool, it logs an error message: "Clique is not ready." I've checked my configurations and ensured that all the services are up and connected to the same network, but I'm still unable to resolve this error.

I would greatly appreciate any guidance or suggestions to help me troubleshoot and resolve this issue. If you have any insights or recommendations, please feel free to share them with me. I'm eager to get my mining pool up and running successfully.

Thank you in advance for your assistance!

Best regards,

Question: How to Get the height of a Block

Hello,
I'd like to include the height of the block in PostgreSQL table blocks.

This is part of the code where blocks are persisted

if (share.foundBlock){
var shareId = result.rows[0].id;
db.query(
'INSERT INTO blocks(share_id, from_group, to_group, block_hash, worker, created_date, modified_date) VALUES($1, $2, $3, $4, $5, $6, $7)',
[shareId, share.job.fromGroup, share.job.toGroup, share.blockHash, share.workerAddress, new Date(), new Date()],

Thanks,
Jvx

Feature - Add MH in the report

Hi,
Can you support this strandard message for MH reporting ? (Bzminer)
Like this we can report the MH per miner. it would be great

alph_submitHashrate

example:
mining-pool_1 | 2022-01-20T10:51:49.736Z | error | Unknown stratum method from ::ffff:81.221.123.56:48960: alph_submitHashrate

Pool hasrate calculator

Hi,

Pool hasrate calculation seems wrong. We are mining with 19 Gh/s. Pool hasrate appears to be 14 Gh/s.

Please solve this problem.

Thank you.

Pool Fee

Pool fee is not calculated. How should we calculate this?

EXECABORT

| error | Handle share failed, error: ReplyError: EXECABORT Transaction discarded because of previous errors.

error when run npm install

idl@alephium:~/mining-pool-1.1.0$ npm install
npm ERR! code 1
npm ERR! path /home/idl/mining-pool-1.1.0/node_modules/bignum
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/idl/mining-pool-1.1.0/node_modules/bignum/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/idl/.cache/node-gyp/14.18.3/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/idl/.cache/node-gyp/14.18.3',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/idl/.cache/node-gyp/14.18.3/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/idl/mining-pool-1.1.0/node_modules/bignum',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: not found: make
npm ERR! gyp ERR! stack at getNotFoundError (/usr/lib/node_modules/npm/node_modules/which/which.js:10:17)
npm ERR! gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:57:18
npm ERR! gyp ERR! stack at new Promise ()
npm ERR! gyp ERR! stack at step (/usr/lib/node_modules/npm/node_modules/which/which.js:54:21)
npm ERR! gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:71:22
npm ERR! gyp ERR! stack at new Promise ()
npm ERR! gyp ERR! stack at subStep (/usr/lib/node_modules/npm/node_modules/which/which.js:69:33)
npm ERR! gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:80:22
npm ERR! gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/isexe/index.js:42:5
npm ERR! gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
npm ERR! gyp ERR! System Linux 5.4.0-96-generic
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/idl/mining-pool-1.1.0/node_modules/bignum
npm ERR! gyp ERR! node -v v14.18.3
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok

Load public key, unlock wallet failed, error: Invalid mnemonic passphrase

Hello, the error is what the title says basically.
I setup alephium full node and mining pool and setup the config.json created a wallet, and a miner wallet and I put the passphrase in there but it keeps saying Invalid passphrase even though I put it in the config.json, is there something else I'm supposed to do?

it says it connects to my full node but it says that error | error | Load public key, unlock wallet failed, error: Invalid mnemonic passphrase

Full log:


> [email protected] start
> node ./init.js

2022-02-07T15:41:49.604Z | info | Connected to alephium full node
2022-02-07T15:41:49.725Z | error | Load public key, unlock wallet failed, error: Invalid mnemonic passphrase
root@localhost:~/mining-pool# ```

| info | Clique is not read

Hi,
after start the pool i have the error:

2022-01-26T10:46:25.802Z | info | Clique is not ready.

in the config.json a don't have the api key

    "apiKey": "xxx",             // alephium full node api key

the problem is the key missing? in this case where do I get it from?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.