xmr-node-proxy icon indicating copy to clipboard operation
xmr-node-proxy copied to clipboard

Receiving jobs results in an TypeError by accessing non existent properties.

Open Alanz2223 opened this issue 7 years ago • 8 comments

I am stepping through the code for the proxy and everything seems to be working starting up correctly until a new job is received by the master process from the mining pool and the proxy tries to process this. I've tried different mining pools, even the one in the example config.json and the error still persists.

After the proxy logs into the pool successfully, the first thing received is this

{"id":1,"jsonrpc":"2.0","error":null,"result":{"id":"0c04f0d3-e1e3-4f39-8329-b4e22269ffb8","job":{"blob":"0606e8d1a5ce05e33f35c54bda22d94a8b5c8efce9b31ffc7c31b58a649c2651415ad0c646f8a7000000005dea02e93effbccf5a31f3c6ae7e554a047d2131115e1b683e901164fa6d39e507","job_id":"txOeVp2Y/FQ6o87EOk6guN1feI+D","target":"d96f0000","id":"0c04f0d3-e1e3-4f39-8329-b4e22269ffh8"},"status":"OK"}}

which is a new job from the pool, so what I don't understand is how the proxy is processing this.

Here is my stack trace

*TypeError: must start with number, buffer, array or string

  • at fromObject (buffer.js:139:11) *at new Buffer (buffer.js:58:10)
  • at new MasterBlockTemplate (xmr.js:88:19)
  • at handleNewBlockTemplate (proxy.js:737:32) *at handlePoolMessage (proxy.js:711:17) *at Socket. (proxy.js:671:17) *at emitOne (events.js:77:13) *at Socket.emit (events.js:169:7) *at readableAddChunk (_stream_readable.js:146:16) *at Socket.Readable.push (_stream_readable.js:110:10)

After some logic, handleNewBlockTemplate calls MasterBlockTemplate in xmr.js and passes the template along. The problem is that MasterBlockTemplate is accessing non-existent properties that the received job doesn't have such as blocktemplate_blob, difficulty, height, etc.. When all it contains is a blob, id, target, and job_id.

As much as I've tried to understand the problem I am still very new to the Stratum protocol and the only reference I have is this one https://slushpool.com/help/manual/stratum-protocol which was written for mining Bitcoin so I don't even know if those same properties apply. Is there another reference to go by for monero?

Alanz2223 avatar Sep 25 '17 20:09 Alanz2223

You're using a non-supported pool. Supported pools send over the raw BT along with several data paramaters about nonces.

Snipa22 avatar Sep 25 '17 21:09 Snipa22

@Snipa22

{ "pools": [{ "hostname": "pool.supportxmr.com", "port": 7777, "ssl": false, "allowSelfSignedSSL": false, "share": 100, "username": "42Afz4LLxgjAximu9TA8mHf3U5VPnrqamU4hGJChVQSXTwyW93j4R829VyqZaCA27p9QvoFC1NQhJZ3gkpY8QUFoBxmfAGe", "password": "pwd:[email protected]", "keepAlive": true, "coin": "xmr", "default": true } ], "listeningPorts": [ { "port": 8080, "ssl": false, "diff": 5000, "coin": "xmr" } ], "bindAddress": "0.0.0.0", "developerShare": 1, "daemonAddress": "127.0.0.1:18081", "coinSettings": { "xmr":{ "minDiff": 100, "maxDiff": 300000, "shareTargetTime": 15 } } }

its the same pool as the one used in the example config. Basically what the pool is sending me is "built" template data correct? Theoretically I could just redistribute this to my miners as is?

Alanz2223 avatar Sep 25 '17 21:09 Alanz2223

Weird, I just cloned the proxy and ran it with the same settings and it works as expected. Why would the first proxy be receiving a single job, yet the second instance receives the BT data as expected?

Alanz2223 avatar Sep 25 '17 21:09 Alanz2223

If you changed the user agent, this would break. The UA is used to identify inbound proxy connections.

Snipa22 avatar Sep 25 '17 21:09 Snipa22

@Snipa22 confirmed.

Alanz2223 avatar Sep 25 '17 21:09 Alanz2223

DOn Sep 26, 2017 4:45 AM, Alanz2223 [email protected] wrote:@Snipa22 confirmed.

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.

mhejek avatar Sep 26 '17 00:09 mhejek

@Snipa22 Hey could you explain to me why the proxy receives new jobs that seem to be identical (almost identical BT data except for job_id) about once per minute? It doesn't really seem like "normal" behavior since the proxy constantly has to broadcast the same data and miners go through state changes to mine the same blob. Is that normal?

Also I have a few questions but most importantly what were your references for the implementation of this proxy? For example where did you get the algo information for xmr.js? I also think it would be very helpful if you could draw a functional diagram or at least explain the proxies's components (like what the master and workers do) since it would tremendously help people who are looking to extend or contribute instead of having to figure it out (I've spent a day or two trying to piece together how everything works). Thanks.

Alanz2223 avatar Sep 26 '17 16:09 Alanz2223

Difficulty shifts by the upstream pool, which causes a new JobID. The blob doesn't change, but the difficulty target does, which causes downstream changes, as it would.

As for the implementation, I wrote the pool it connects to. As for diagramming, I have no particular interest in that, this project was written as a quick way to run a stratum proxy, and is slated to be replaced in the next few months by a backend written in C in regards to other projects I'm working on.

If you'd like more explanations, it's much easier to find me in IRC than in GH comments.

Snipa22 avatar Sep 26 '17 16:09 Snipa22