ethereum-mining / ethminer

Ethereum miner with OpenCL, CUDA and stratum support
GNU General Public License v3.0
5.97k stars 2.28k forks source link

EthereumStratum protocol is broken now! #1041

Closed Rom1kz closed 6 years ago

Rom1kz commented 6 years ago

long time i've used 0.14.0.dev1 version of ethminer and all was fine but after upgrade to the last version 0.14.0.rc6 or 0.15.0.dev5 i get problem with EthereumStratum protocol

this script is working ok with version 0.14.0.dev1:

ethminer -U -SP 2 -S s-eu.comining.io:9999 -O AGQZgM6jtuYmVxNenWabGF5.worker

pool trace (i'm pool operator and able to trace requests & pool-side logic):

channel 5 activated
channel 5 stratum data in '{"id": 1, "method": "mining.subscribe", "params": ["ethminer/0.14.0.dev1","EthereumStratum/1.0.0"]}'
channel 5 subscribed
stratum data out: {"id":1,"result":[["mining.notify","a105c2b9b42247bda90e09a7da80486a","EthereumStratum/1.0.0"],"0003"]}
channel 5 stratum data in '{"id": 2, "method": "mining.extranonce.subscribe", "params": []}'
stratum data out: {"id":2,"result":true}
channel 5 stratum data in '{"id": 3, "method": "mining.authorize", "params": ["AGQZgM6jtuYmVxNenWabGF5.worker","AGQZgM6jtuYmVxNenWabGF5.worker"]}'
channel 5 trying login 'AGQZgM6jtuYmVxNenWabGF5' worker 'worker' with stratum protocol
channel 5 worker 'worker' account 'AGQZgM6jtuYmVxNenWabGF5' logged
stratum data out: {"id":3,"result":true}
stratum data out: {"params":[1.1641354547009584],"id":0,"jsonrpc":"2.0","method":"mining.set_difficulty"}
stratum data out: {"params":["6235d42c492d42808792d262331445a1","0x5197b2a3898b31d4d8afb33e2216b2ef6e166b09122e514323701e9af3b09643","0x6893bc35d10b111d846116d71669b576b06ad5c61a15858ddfd1dea614a1408b",true],"id":0,"jsonrpc":"2.0","method":"mining.notify"}

looks good but lets try version 0.15.0.dev5

channel 6 activated
channel 6 stratum data in '{"id": 1, "method": "mining.subscribe", "params": ["ethminer/0.15.0.dev5","EthereumStratum/1.0.0"]}'
channel 6 subscribed
stratum data out: {"id":1,"result":[["mining.notify","9aac4f02644c473c983704cfeb246ec8","EthereumStratum/1.0.0"],"0004"]}
channel 6 stratum data in '{"id": 2, "method": "mining.extranonce.subscribe", "params": []}'
stratum data out: {"id":2,"result":true}

why ethminer wont send authorize request after mining.subscribe and mining.extranonce.subscribe ? the same result with version 0.14.0rc6 and no luck when i try new -P parameter instead of -SP + -S + -O

ethminer -U -P stratum2+tcp://AGQZgM6jtuYmVxNenWabGF5.worker@s-eu.comining.io:9999

still no authorize request is sent to the pool

miner side output:

./start.bash
  m  01:55:59|ethminer|  ethminer version 0.14.0rc6
  m  01:55:59|ethminer|  Build: linux / release +git. be77227
 cu  01:56:00|ethminer|  Using grid size 8192 , block size 128
  ℹ  01:56:00|ethminer|  Selected pool s-eu.comining.io:9999
  m  01:56:00|ethminer|  not-connected
  ℹ  01:56:00|stratum |  Trying s-eu.comining.io:9999 ...
  ℹ  01:56:00|stratum |  Connected to s-eu.comining.io  [46.4.84.35:9999]
  ℹ  01:56:00|stratum |  Spinning up miners...
  ℹ  01:56:00|cuda-0  |  No work. Pause for 3 s.
  ℹ  01:56:00|cuda-1  |  No work. Pause for 3 s.
  ℹ  01:56:00|cuda-2  |  No work. Pause for 3 s.
  ℹ  01:56:00|cuda-3  |  No work. Pause for 3 s.
  ℹ  01:56:00|cuda-4  |  No work. Pause for 3 s.
  ℹ  01:56:00|cuda-5  |  No work. Pause for 3 s.
  ℹ  01:56:00|stratum |  Extranonce set to 0003
  ℹ  01:56:03|cuda-0  |  No work. Pause for 3 s.
  ℹ  01:56:03|cuda-1  |  No work. Pause for 3 s.
  ℹ  01:56:03|cuda-2  |  No work. Pause for 3 s.
  ℹ  01:56:03|cuda-3  |  No work. Pause for 3 s.
  ℹ  01:56:03|cuda-4  |  No work. Pause for 3 s.
  ℹ  01:56:03|cuda-5  |  No work. Pause for 3 s.
Rom1kz commented 6 years ago

image

it seems like ethminer should send authorize in "case 2" statement or send it at the same time with mining.extranonce.subscribe (second way much better and corresponds to protocol specification)

SnowLeopard71 commented 6 years ago

In 0.14.0-dev1, around line 328 of libstratum/EthStratumClient.cpp mining.extranonce.subscribe is sent upon receiving the response to id 1 request, and also immediately sends the id 3 mining.authorize request without waiting for the response for id 2. Newer releases have been rewritten to libpoolprotocols/stratum/EthStratumClient.cpp The mining.authorize request probably also needs to be in case 2:, which is the response to the mining.extranonce.subscribe.
It looks like this only affects stratum2 and not stratum1, can you test and confirm?

Rom1kz commented 6 years ago

Yes, only stratum2 is affected but, by the specification, pool may not answering to mining.extranonce.subscribe at all in this case miner must send authorize without waiting for mining.extranonce.subscribe answer

AndreaLanfranchi commented 6 years ago

Problem is a little more complex. There has never been (in ethminer) a distinction between jsonrpc v1 and v2 : those two endorse a completely different way to implement positive vs negative responses.

Long story short: working on it. Keep an eye on Stratum branch,

Rom1kz commented 6 years ago

im looking forward to solution asap

thank you

smurfy commented 6 years ago

@AndreaLanfranchi your commit #ff4bd4f2dbd1f2d935c643a30b80b17d7cef1560 broke it within the method EthStratumClient::processReponse

Old logic: (working) Always send mining.authorize message except for ETHPROXY mode. Use something different there. IF EthStratumClient::ETHEREUMSTRATUM (stratum mode 2) it also sends mining.extranonce.subscribe

New logic: (not working) You wanted to optimize it, but you changed that only in normal stratum mode the mining.authorize is sent and in stratum mode 2 only mining.extranonce.subscribe is sent.

Hope i made myself clear :)

AndreaLanfranchi commented 6 years ago

Think I got it. Just for info ... is there any exhaustive documentation about ETHEREUMSTRATUM

Only I could find is this https://github.com/nicehash/Specifications/blob/master/EthereumStratum_NiceHash_v1.0.0.txt

Rom1kz commented 6 years ago

Yes. this is the only documentation i've used to implement the protocol on comining.io

chfast commented 6 years ago

That's actually the only Ethereum startum protocol documented :) But still has issues, see https://github.com/nicehash/Specifications/issues/5.

AndreaLanfranchi commented 6 years ago

Solved in