glambeth / zecProxy

Zcash Stratum Proxy
10 stars 6 forks source link

fails with multiple mining clients (at least for nheqminer) #6

Open aleqx opened 7 years ago

aleqx commented 7 years ago

It doesn't seem to work with multiple miners on different machines. I tried the nheqminer with CPU mining and the flypool pool.

In a normal miner->pool communication, the id field in the packets is incremented with every exchange of packets (excluding pool broadcasts). Your code alters the id field to be equal to the miner's id, essentially keeping it fixed for each miner. You also pass the same job to all miners. There are a number of problems that are happening:

It seems that your proxy hasn't really been tested with multiple miners, or with different mining software (see my other raised issue about EWBF). It would be nice if you looked into it.

aleqx commented 7 years ago

Looking closer at the code, it seems all this proxy does is relaying all messages back and forth between the pool and miners, and altering the id field to make it unique per miner. It fails to set the id back to the same value issued by the miner (breaking the JSON-RPC protocol). Many (all?) pools also reject multiple authorize requests on the same connections, causing miners to fail.

What's needed is a proper proxy that acts as a single miner to the pool, subscribing itself to the pool and dealing with the subscribe, authorize, set_target methods from the pool, then wait for miners to connect. Upon the latter, it should subscribe, authorize, set_target the miners directly (without relaying anything to the pool). It should also record/queue any job broadcasts from the pool for when miners connect. The only messages relayed between miners and pool should then be the job broadcasts from the pool and job submits from miners, making sure that the id field value of each miner's request is preserved when replying back to the miner.

A state machine is needed to implement the above. It's not a simple hack. You made a good start though.