Snipa22 / nodejs-pool

Other
480 stars 423 forks source link

Payments cannot be paid automatically to miners #401

Closed fanmaomao closed 6 years ago

fanmaomao commented 6 years ago

I built a private testnet on my computer, it has three nodes, one of them provides service to the mine pool, then I set up two miners to connect to the pool, every service works well, but after a long time the mine pool did not pay to the miners, the payments service log is:

Database Worker: LMDB Env Initialized.
Setting the payment timer to: 20 minutes with a: 10 minute delay if the wallet is out of money
Loaded all payees into the system for processing

then I use DEBUG=* pm2 start init.js --name=payments --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=payments to restart the service, but the service automatically restarts again and again, the error log is:

Database Worker: LMDB Env Initialized.
  support JSON URI: http://127.0.0.1:28082/json_rpc Args: {"id":"0","jsonrpc":"2.0","method":"store","params":[]} +0ms
Setting the payment timer to: 20 minutes with a: 10 minute delay if the wallet is out of money
Loaded all payees into the system for processing
  payments Starting round for: {"id":1,"last_edited":"2018-04-23T06:02:55.000Z","payment_address":"9tYwxk2EBJ2Ct9eYEcwUhE1QQuxbGNM6mYVUC4ew6B73Agk9MWFVR9rDCif2reRm7NNSemFhr2mwND5hzpnqZvgqBmiEpBp","payment_id":null,"pool_type":"fees","bitcoin":0,"amount":117906406696125} +90ms
  payments Starting round for: {"id":2,"last_edited":"2018-04-23T06:02:55.000Z","payment_address":"A2Q5n5HEtHe9Wt43fiybAicDcBZneVminVUBJtUsP1R9KWv3bHXzo3sVoYBnnPMbwmAL8drmvwBVxSbMSTY63Mqv5ZGYKtS","payment_id":null,"pool_type":"fees","bitcoin":0,"amount":3762970426340} +6ms
  payments Starting round for: {"id":3,"last_edited":"2018-04-23T06:02:55.000Z","payment_address":"A2GiJXHVj6MBo3vi3L1nfsWANepdDa741Z44RmbHxSLiJ3eEM6JWo15XBoAYZTsqGehEfNRrvzL7o8p1MaKsuXWuRLZiMSE","payment_id":null,"pool_type":"fees","bitcoin":0,"amount":3762970426340} +2ms
  payments Starting round for: {"id":4,"last_edited":"2018-04-23T06:20:55.000Z","payment_address":"9zf7Ji3JU42LquuM8wdpkWgHVi5jp5MpLe7x1nM5dDED5TMftVcrcA1d7S35oqE6QyKFFYi62cqLvaWWDGFz9wC35ZjiptK","payment_id":null,"pool_type":"pplns","bitcoin":0,"amount":291266753295417} +0ms
  payments Starting round for: {"id":5,"last_edited":"2018-04-23T06:22:55.000Z","payment_address":"9wRbY3jqnMPMfdg6Yjdavk4MkRP5Sin5ZCC3gLV2Ms2xcNoNZtkGSJL7TcEtxiTpcSbLmcZZqdWFGA5G6yEE83n1Ejzczi9","payment_id":null,"pool_type":"pplns","bitcoin":0,"amount":600076433092734} +1ms
  payments Starting round for: {"id":6,"last_edited":"2018-04-23T06:30:55.000Z","payment_address":"9wzvo1zrqMENeBqJW7dPLiWXQXByUtVZXi5yyN4aXy8ffBpu2NiWU3ABKpFVtwsvyueGqpEJgBoPNLj45oU3wZwtHaYE5fQ","payment_id":null,"pool_type":"pplns","bitcoin":0,"amount":237547941552149} +0ms
  payments This is the fee address internal check for value +22ms
  payments Adding 9tYwxk2EBJ2Ct9eYEcwUhE1QQuxbGNM6mYVUC4ew6B73Agk9MWFVR9rDCif2reRm7NNSemFhr2mwND5hzpnqZvgqBmiEpBp to the list of people to pay (OG Address).  Payee balance: 107.906406 +0ms
  payments Went: 1 With: 1 Possible destinations and: 6 Rows +0ms
  payments Adding A2Q5n5HEtHe9Wt43fiybAicDcBZneVminVUBJtUsP1R9KWv3bHXzo3sVoYBnnPMbwmAL8drmvwBVxSbMSTY63Mqv5ZGYKtS to the list of people to pay (OG Address).  Payee balance: 3.76297 +14ms
  payments Went: 2 With: 2 Possible destinations and: 6 Rows +0ms
  payments Adding A2GiJXHVj6MBo3vi3L1nfsWANepdDa741Z44RmbHxSLiJ3eEM6JWo15XBoAYZTsqGehEfNRrvzL7o8p1MaKsuXWuRLZiMSE to the list of people to pay (OG Address).  Payee balance: 3.76297 +1ms
  payments Went: 3 With: 3 Possible destinations and: 6 Rows +0ms
  payments Adding 9zf7Ji3JU42LquuM8wdpkWgHVi5jp5MpLe7x1nM5dDED5TMftVcrcA1d7S35oqE6QyKFFYi62cqLvaWWDGFz9wC35ZjiptK to the list of people to pay (OG Address).  Payee balance: 291.266753 +0ms
  payments Went: 4 With: 4 Possible destinations and: 6 Rows +0ms
  payments Adding 9wRbY3jqnMPMfdg6Yjdavk4MkRP5Sin5ZCC3gLV2Ms2xcNoNZtkGSJL7TcEtxiTpcSbLmcZZqdWFGA5G6yEE83n1Ejzczi9 to the list of people to pay (OG Address).  Payee balance: 600.076433 +0ms
  payments Went: 5 With: 5 Possible destinations and: 6 Rows +0ms
  payments Adding 9wzvo1zrqMENeBqJW7dPLiWXQXByUtVZXi5yyN4aXy8ffBpu2NiWU3ABKpFVtwsvyueGqpEJgBoPNLj45oU3wZwtHaYE5fQ to the list of people to pay (OG Address).  Payee balance: 237.547941 +0ms
  payments Went: 6 With: 6 Possible destinations and: 6 Rows +0ms
Paying out: 5 people
Paying out: 1 people
  payments Making payment based on: {"destinations":[{"amount":107906406000000,"address":"9tYwxk2EBJ2Ct9eYEcwUhE1QQuxbGNM6mYVUC4ew6B73Agk9MWFVR9rDCif2reRm7NNSemFhr2mwND5hzpnqZvgqBmiEpBp"},{"amount":3762265316217,"address":"A2Q5n5HEtHe9Wt43fiybAicDcBZneVminVUBJtUsP1R9KWv3bHXzo3sVoYBnnPMbwmAL8drmvwBVxSbMSTY63Mqv5ZGYKtS"},{"amount":3762265316217,"address":"A2GiJXHVj6MBo3vi3L1nfsWANepdDa741Z44RmbHxSLiJ3eEM6JWo15XBoAYZTsqGehEfNRrvzL7o8p1MaKsuXWuRLZiMSE"},{"amount":291266753000000,"address":"9zf7Ji3JU42LquuM8wdpkWgHVi5jp5MpLe7x1nM5dDED5TMftVcrcA1d7S35oqE6QyKFFYi62cqLvaWWDGFz9wC35ZjiptK"},{"amount":600076433000000,"address":"9wRbY3jqnMPMfdg6Yjdavk4MkRP5Sin5ZCC3gLV2Ms2xcNoNZtkGSJL7TcEtxiTpcSbLmcZZqdWFGA5G6yEE83n1Ejzczi9"}],"priority":0,"mixin":4} +3ms
  support JSON URI: http://127.0.0.1:28082/json_rpc Args: {"id":"0","jsonrpc":"2.0","method":"transfer","params":{"destinations":[{"amount":107906406000000,"address":"9tYwxk2EBJ2Ct9eYEcwUhE1QQuxbGNM6mYVUC4ew6B73Agk9MWFVR9rDCif2reRm7NNSemFhr2mwND5hzpnqZvgqBmiEpBp"},{"amount":3762265316217,"address":"A2Q5n5HEtHe9Wt43fiybAicDcBZneVminVUBJtUsP1R9KWv3bHXzo3sVoYBnnPMbwmAL8drmvwBVxSbMSTY63Mqv5ZGYKtS"},{"amount":3762265316217,"address":"A2GiJXHVj6MBo3vi3L1nfsWANepdDa741Z44RmbHxSLiJ3eEM6JWo15XBoAYZTsqGehEfNRrvzL7o8p1MaKsuXWuRLZiMSE"},{"amount":291266753000000,"address":"9zf7Ji3JU42LquuM8wdpkWgHVi5jp5MpLe7x1nM5dDED5TMftVcrcA1d7S35oqE6QyKFFYi62cqLvaWWDGFz9wC35ZjiptK"},{"amount":600076433000000,"address":"9wRbY3jqnMPMfdg6Yjdavk4MkRP5Sin5ZCC3gLV2Ms2xcNoNZtkGSJL7TcEtxiTpcSbLmcZZqdWFGA5G6yEE83n1Ejzczi9"}],"priority":0,"mixin":4}} +0ms
  payments Payment made: {"bytesParsed":0,"code":"HPE_INVALID_CONSTANT"} +8ms
/home/sopays/nodejs-pool/lib/payment_systems/xmr.js:331
                console.log("Payment made out to multiple people, total fee: " + global.support.coinToDecimal(body.result.fee) + " XMR");
                                                                                                                          ^

TypeError: Cannot read property 'fee' of undefined
    at /home/sopays/nodejs-pool/lib/payment_systems/xmr.js:331:123
    at /home/sopays/nodejs-pool/lib/support.js:100:24
    at Object.parseBody (/home/sopays/nodejs-pool/node_modules/request-json/main.js:74:12)
    at Request._callback (/home/sopays/nodejs-pool/node_modules/request-json/main.js:148:26)
    at self.callback (/home/sopays/nodejs-pool/node_modules/request-json/node_modules/request/request.js:187:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.onRequestError (/home/sopays/nodejs-pool/node_modules/request-json/node_modules/request/request.js:813:8)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at Socket.socketOnData (_http_client.js:459:9)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)

These addresses are testnet address, and my monerod and monero-wallet-cli works well, and all nodes and miners are mining, but i use postman post a request to 127.0.0.1:28082/json_rpc cannot connection, I don't know where my problem is, hope to get your help, thanks!

bobbieltd commented 6 years ago

Are your pool wallet and fee wallet in testnet ? Put donations to ZERO (because donation addresses are not testnet addresses).

fanmaomao commented 6 years ago

I have considered your conjecture, the donations addresses are already testnet address.

I think my problem is that the rpc service has a bad response : {"bytesParsed":0,"code":"HPE_INVALID_CONSTANT"} I search this message, it seems like a network error.

So I recheck my services, I found that I only started the wallet cli service to mine and forget started the wallet rpc service ....... 😓

Then I encountered another problem ...

I use /usr/local/src/monero/monerod --testnet --data-dir ~/xmr_testnet/01/ --p2p-bind-port 28080 --rpc-bind-port 28081 --add-exclusive-node 127.0.0.1:38080 --add-exclusive-node 127.0.0.1:48080 to start the monerod and I use /usr/local/src/monero/monero-wallet-rpc --testnet --daemon-port 28081 --rpc-bind-port 28082 --wallet-file ~/xmr_testnet/wallets/pool_main.keys --password "******" to start the wallet rpc .

I can't start the wallet rpc service because the port(28082) is already in use. I use netstat -anp | grep 28082 and get this message: tcp 0 0 127.0.0.1:28082 0.0.0.0:* LISTEN 20262/monerod

It makes me very 🤔

bobbieltd commented 6 years ago

Not sure if it is the cause In testnet monero mode, uint16_t const ZMQ_RPC_DEFAULT_PORT = 28082; It is used by defaut with monero testnet.

bobbieltd commented 6 years ago

For undefined “fee” property, if you checked everything, restart that module + blockManager will fix it.

fanmaomao commented 6 years ago

I used --zmq-rpc-bind-port 28082 at first time, monerod also use 28082 port, I think this is a wrong usage, so I removed it

The property fee is undefined because body is {"bytesParsed":0,"code":"HPE_INVALID_CONSTANT"} on line 304 in /lib/payment_systems/xmr.js and because my monero-wallet-rpc is not running.

fanmaomao commented 6 years ago

I checked the v0.11.1.0 monerod, It didn't have --zmq-rpc-bind-port config, it didn't listen 28082.

I gave up running the monero-wallet-rpc service on port 28082, it is running on port 28083, it work well.

fanmaomao commented 6 years ago

After solving the rpc problem, I encountered a new trouble. 😫😫😫

new trouble: https://www.reddit.com/r/Monero/comments/8eq6mt/why_cant_i_put_a_large_amount_of_monero_to_an/

alexmateescu commented 6 years ago

how did you fix the rpc issue? i am seeing the same thing

fanmaomao commented 6 years ago

@alexmateescu I have no idea to fix this, I try to use the public testnet and tagenet, transfer works well.