Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[daemon support] hashrate loss due to duplicate jobs received by workers from xmrig-proxy #377

Closed
ghost opened this issue Dec 31, 2019 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 31, 2019

Multiple instances of xmrig::DaemonClient may propogate exactly the same xmrig::Job.

Python script to reproduce error with xmrig-proxy that's listening on 127.0.0.1:3333 and connected to daemon+http://127.0.0.1:18081

import asyncio
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
import json
login_json = {
  'id': 1,
  'jsonrpc': '2.0',
  'method': 'login',
  'params': {
    'login': '00' * 32,
    'pass': 'x',
    'agent': '',
    'algo': ['rx/0']
    }
  }
login_json_buf = json.dumps(login_json) + '\n'
async def get_job():
    try:
        reader, writer = await asyncio.open_connection(host = '127.0.0.1', port = 3333)
        writer.write(login_json_buf.encode())
        await writer.drain()
        job_json_buf = await  reader.readline()
    except OSError:
        return None
    except asyncio.IncompleteReadError:
        return None
    try:
        writer.close()
        writer._protocol.connection_lost(None)
    except OSError:
        pass
    try:
      job_json = json.loads(job_json_buf)
      print(job_json)
    except json.JSONDecodeError:
      return None
    return job_json
g = asyncio.gather(*[get_job() for i in range(256 * 4)])
r = loop.run_until_complete(g)
received_jobs = sorted([e['result']['job']['blob'] for e in r if e != None], key = lambda e: [e[:79 ], e[79 + 8:], e[79:][:8]] )
uniq_jobs = set(received_jobs)
print({'uniq_jobs': len(uniq_jobs), 'received_jobs': len(received_jobs)})
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants