stratum-mining-litecoin
stratum-mining-litecoin copied to clipboard
Yacoin support
I am trying to run it for Yacoin but I've got initial error message:
2013-06-30 09:44:18,107 INFO mining __init__.setup # Connecting to litecoind...
2013-06-30 09:44:18+0200 [-] Log opened.
2013-06-30 09:44:18+0200 [-] twistd 11.1.0 (/usr/bin/python 2.7.3) starting up.
2013-06-30 09:44:18+0200 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2013-06-30 09:44:18+0200 [HTTPPageGetter,client] Unhandled error in Deferred:
2013-06-30 09:44:18+0200 [HTTPPageGetter,client] Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 391, in errback
self._startRunCallbacks(fail)
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 458, in _startRunCallbacks
self._runCallbacks()
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 545, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1095, in gotResult
_inlineCallbacks(r, g, deferred)
--- <exception caught here> ---
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1037, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/usr/lib/python2.7/dist-packages/twisted/python/failure.py", line 382, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/root/yac/stratum-mining-litecoin/mining/__init__.py", line 53, in setup
if isinstance(json.loads(e[2])['error']['message'], str):
File "/usr/local/lib/python2.7/dist-packages/simplejson/__init__.py", line 488, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 389, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Any help appreciated
It looks like either yacoind is not up and running yet, it does not know how to do getblocktemplate, or its just returning some garbage/non default input.
File "/root/yac/stratum-mining-litecoin/mining/_init__.py", line 53, in setup
if isinstance(json.loads(e[2])['error']['message'], str):
So please try the following command and let me know what the output is.
yacoind getblocktemplate {}
That is what it is failing on in the code.
{
"version" : 3,
"previousblockhash" : "00000000f0f896a828171394ae7fe15789cd94dd75d76a265e0961670e78727e",
"transactions" : [
],
"coinbaseaux" : {
"flags" : "062f503253482f"
},
"coinbasevalue" : 25990000,
"target" : "0000000142e10000000000000000000000000000000000000000000000000000",
"mintime" : 1372620245,
"mutable" : [
"time",
"transactions",
"prevblock"
],
"noncerange" : "00000000ffffffff",
"sigoplimit" : 20000,
"sizelimit" : 1000000,
"curtime" : 1372620536,
"bits" : "1d0142e1",
"height" : 115049
}
this is the output
I tried again from the beginning and it works at least till the moment I am trying to connect yacminer through stratum. If I put in yacminer options stratum+tc://... then nothing is happening. When I dont specify protocol I've got this in debug window:
2013-07-01 11:48:46,854 DEBUG bitcoin_rpc_manager bitcoin_rpc_manager.check_height # Check Height -- Current Pool 0 : 115929
2013-07-01 11:48:47+0200 [stratum.socket_transport.SocketTransportFactory] 2013-07-01 11:48:47,598 INFO stats stats.print_stats # 1 peers connected, state changed 1 times
2013-07-01 11:48:47+0200 [stratum.socket_transport.SocketTransportFactory] 2013-07-01 11:48:47,598 DEBUG protocol protocol.connectionMade # Connected 184.105.182.85
2013-07-01 11:48:48+0200 [Protocol,4,184.105.182.85] 2013-07-01 11:48:48,213 ERROR protocol protocol.dataReceived # Processing of message failed
2013-07-01 11:48:48+0200 [Protocol,4,184.105.182.85] Traceback (most recent call last):
2013-07-01 11:48:48+0200 [Protocol,4,184.105.182.85] File "/usr/local/lib/python2.7/dist-packages/stratum/protocol.py", line 185, in dataReceived
2013-07-01 11:48:48+0200 [Protocol,4,184.105.182.85] self.lineReceived(line, request_counter)
2013-07-01 11:48:48+0200 [Protocol,4,184.105.182.85] File "/usr/local/lib/python2.7/dist-packages/stratum/protocol.py", line 216, in lineReceived
2013-07-01 11:48:48+0200 [Protocol,4,184.105.182.85] raise custom_exceptions.ProtocolException("Cannot decode message '%s'" % line)
'013-07-01 11:48:48+0200 [Protocol,4,184.105.182.85] ProtocolException: Cannot decode message 'POST / HTTP/1.1
2013-07-01 11:48:48+0200 [Protocol,4,184.105.182.85] 2013-07-01 11:48:48,214 INFO stats stats.print_stats # 0 peers connected, state changed 1 times
2013-07-01 11:48:49+0200 [stratum.socket_transport.SocketTransportFactory] 2013-07-01 11:48:49,229 INFO stats stats.print_stats # 1 peers connected, state changed 1 times
2013-07-01 11:48:49+0200 [stratum.socket_transport.SocketTransportFactory] 2013-07-01 11:48:49,229 DEBUG protocol protocol.connectionMade # Connected 184.105.182.85
2013-07-01 11:48:49+0200 [Protocol,5,184.105.182.85] 2013-07-01 11:48:49,608 INFO stats stats.print_stats # 0 peers connected, state changed 1 times
2013-07-01 11:48:51,844 INFO block_updater block_updater.run # Checking for new block.
2013-07-01 11:48:51,857 DEBUG bitcoin_rpc_manager bitcoin_rpc_manager.check_height # Check Height -- Current Pool 0 : 115929
2013-07-01 11:48:56,844 INFO block_updater block_updater.run # Checking for new block.
2013-07-01 11:48:56,854 DEBUG bitcoin_rpc_manager bitcoin_rpc_manager.check_height # Check Height -- Current Pool 0 : 115929
2013-07-01 11:48:58+0200 [stratum.socket_transport.SocketTransportFactory] 2013-07-01 11:48:58,533 INFO stats stats.print_stats # 1 peers connected, state changed 1 times
2013-07-01 11:48:58+0200 [stratum.socket_transport.SocketTransportFactory] 2013-07-01 11:48:58,533 DEBUG protocol protocol.connectionMade # Connected 184.105.182.85
2013-07-01 11:48:59+0200 [Protocol,6,184.105.182.85] 2013-07-01 11:48:59,234 ERROR protocol protocol.dataReceived # Processing of message failed
2013-07-01 11:48:59+0200 [Protocol,6,184.105.182.85] Traceback (most recent call last):
2013-07-01 11:48:59+0200 [Protocol,6,184.105.182.85] File "/usr/local/lib/python2.7/dist-packages/stratum/protocol.py", line 185, in dataReceived
2013-07-01 11:48:59+0200 [Protocol,6,184.105.182.85] self.lineReceived(line, request_counter)
2013-07-01 11:48:59+0200 [Protocol,6,184.105.182.85] File "/usr/local/lib/python2.7/dist-packages/stratum/protocol.py", line 216, in lineReceived
2013-07-01 11:48:59+0200 [Protocol,6,184.105.182.85] raise custom_exceptions.ProtocolException("Cannot decode message '%s'" % line)
'013-07-01 11:48:59+0200 [Protocol,6,184.105.182.85] ProtocolException: Cannot decode message 'POST / HTTP/1.1
2013-07-01 11:48:59+0200 [Protocol,6,184.105.182.85] 2013-07-01 11:48:59,235 INFO stats stats.print_stats # 0 peers connected, state changed 1 times
2013-07-01 11:49:00+0200 [stratum.socket_transport.SocketTransportFactory] 2013-07-01 11:49:00,351 INFO stats stats.print_stats # 1 peers connected, state changed 1 times
2013-07-01 11:49:00+0200 [stratum.socket_transport.SocketTransportFactory] 2013-07-01 11:49:00,351 DEBUG protocol protocol.connectionMade # Connected 184.105.182.85
2013-07-01 11:49:01+0200 [Protocol,7,184.105.182.85] 2013-07-01 11:49:01,049 ERROR protocol protocol.dataReceived # Processing of message failed
2013-07-01 11:49:01+0200 [Protocol,7,184.105.182.85] Traceback (most recent call last):
2013-07-01 11:49:01+0200 [Protocol,7,184.105.182.85] File "/usr/local/lib/python2.7/dist-packages/stratum/protocol.py", line 185, in dataReceived
2013-07-01 11:49:01+0200 [Protocol,7,184.105.182.85] self.lineReceived(line, request_counter)
2013-07-01 11:49:01+0200 [Protocol,7,184.105.182.85] File "/usr/local/lib/python2.7/dist-packages/stratum/protocol.py", line 216, in lineReceived
2013-07-01 11:49:01+0200 [Protocol,7,184.105.182.85] raise custom_exceptions.ProtocolException("Cannot decode message '%s'" % line)
'013-07-01 11:49:01+0200 [Protocol,7,184.105.182.85] ProtocolException: Cannot decode message 'POST / HTTP/1.1
2013-07-01 11:49:01+0200 [Protocol,7,184.105.182.85] 2013-07-01 11:49:01,052 INFO stats stats.print_stats # 0 peers connected, state changed 1 times
2013-07-01 11:49:01,698 DEBUG DBInterface DBInterface.run_import_thread # run_import_thread current size: 0
but then in yacminer log I've got this:
[2013-07-01 11:52:39] Pool 0 slow/down or URL or credentials invalid
[2013-07-01 11:53:17] No servers were found that could be used to get work from.
[2013-07-01 11:53:17] Please check the details from the list below of the servers you have input
[2013-07-01 11:53:17] Most likely you have input the wrong URL, forgotten to add a port, or have not set up workers
Any help in debugging the problem is appreciated
Nice catch. The most telling line is this one.
'013-07-01 11:48:48+0200 [Protocol,4,184.105.182.85] ProtocolException: Cannot decode message 'POST / HTTP/1.1
Something is sending HTTP requests instead of stratum requests. Does yacminer do stratum? It looks like it is looking for getwork. Can you try with stratum-proxy in front of yacminer?
heh - indeed - it is confirming shares now with stratum proxy :) - I will test it more and let you know
through stratum proxy shares are not really transferred to server... I think this is because it use scrypt not scrypt-jane...
Next update - yacminer do support stratum... but something is still wrong:
2013-07-01 15:02:54,477 DEBUG protocol protocol.lineReceived # > {u'params': [u'feeleep.1', u'4', u'02000000', u'51d17df5', u'000a0ec8'], u'id': 2, u'method': u'mining.submit'}
2013-07-01 15:02:54,477 ERROR protocol protocol.process_failure # [Failure instance: Traceback: <type 'exceptions.TypeError'>: function takes exactly 2 arguments (1 given)
/usr/local/lib/python2.7/dist-packages/stratum/protocol.py:185:dataReceived
/usr/local/lib/python2.7/dist-packages/stratum/protocol.py:230:lineReceived
/usr/local/lib/python2.7/dist-packages/stratum/services.py:13:_handle_event
/usr/local/lib/python2.7/dist-packages/stratum/services.py:81:call
--- <exception caught here> ---
/usr/lib/python2.7/dist-packages/twisted/internet/defer.py:134:maybeDeferred
/usr/local/lib/python2.7/dist-packages/stratum/services.py:78:_run
/home/pools/yac/stratum-mining-litecoin/mining/service.py:100:submit
/home/pools/yac/stratum-mining-litecoin/lib/template_registry.py:224:submit_share
]
None
What do you have on like 224 of template_registry.py?
/home/pools/yac/stratum-mining-litecoin/lib/template_registry.py:224
Basically what that stack trace is saying is that the function that does the PoW is expecting 2 arguments instead of 1. I am guessing that you changed the default line to be something with scrypt-jane:
hash_bin = ltc_scrypt.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
Check the scrypt-jane function to see what it requires.
It could also be the stratum-mining-proxy. It looks like it does not work with yacoin? http://yacointalk.com/index.php?topic=64.0. It could also be that their pool did not work for yacoin. I have not investigated it.
there is yac_scrypt which was compiled from here: https://github.com/cctvsmg/yacoin-p2pool/tree/master/yac_scrypt
And here is the code of function:
static PyObject *scrypt_getpowhash(PyObject *self, PyObject *args)
{
char *output;
int timestamp;
PyObject *value;
PyStringObject *input;
if (!PyArg_ParseTuple(args, "Si", &input, ×tamp))
return NULL;
Py_INCREF(input);
output = (char *)PyMem_Malloc(32);
memset(output, 0, 32);
scrypt_hash((char *)PyString_AsString((PyObject*) input), 80, (uint32_t *)output, GetNfactor(timestamp));
Py_DECREF(input);
value = Py_BuildValue("s#", output, 32);
PyMem_Free(output);
return value;
}
Whats the line on 224? It is sending in self, but it does not look to be sending anything else in. Can you print out the hash hex if you put it above that line?
This is my line 224:
hash_bin = yac_scrypt.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
but sorry for my ignorance but how can I "print out the hash hex"?
I figured out how to do some debugging and i put this code just before above line:
log.info("job_id '%s' " % job_id)
log.info("worker_name '%s' " % worker_name)
log.info("session '%s' " % session)
log.info("extranonce1_bin '%s' " % extranonce1_bin)
log.info("extranonce2 '%s' " % extranonce2)
log.info("ntime '%s' " % ntime)
log.info("nonce '%s' " % nonce)
log.info("difficulty '%s' " % difficulty)
log.info("coinbase_hash '%s' " % coinbase_hash)
log.info("header_bin '%s' " % header_bin)
and result is:
2013-07-02 15:59:44,340 INFO template_registry template_registry.submit_share # job_id '1'
2013-07-02 15:59:44,340 INFO template_registry template_registry.submit_share # worker_name 'feeleep.1'
2013-07-02 15:59:44,340 INFO template_registry template_registry.submit_share # session '{'difficulty': 31, 'extranonce1': '\xf8\x00\x00\x01', 'authorized': {u'feeleep.1': u'x'}, 'subscriptions': {'ae6812eb4cd7735a302a8a9dd95cf71f': <mining.subscription.MiningSubscription object at 0x30df790>}}'
2013-07-02 15:59:44,340 INFO template_registry template_registry.submit_share # extranonce1_bin 'ř'
2013-07-02 15:59:44,341 INFO template_registry template_registry.submit_share # extranonce2 '0c000000'
2013-07-02 15:59:44,341 INFO template_registry template_registry.submit_share # ntime '51d2dcb9'
2013-07-02 15:59:44,341 INFO template_registry template_registry.submit_share # nonce '00031891'
2013-07-02 15:59:44,341 INFO template_registry template_registry.submit_share # difficulty '31'
2013-07-02 15:59:44,341 INFO template_registry template_registry.submit_share # coinbase_hash 'HÂč÷ŕ+ď6;]GPâeIPˇśÎŠąŔYŹ'
2013-07-02 15:59:44,341 INFO template_registry template_registry.submit_share # header_bin 'ĄŠűnqÖľęYŢ9+=Źk ç§\ó^ @+1?MčÂH+ŕ];6ďâPGIeÎśˇPąŠŹYŔQŇÜš/Ľ'
EDIT:
I checked how it is implemented in p2pool (python as well) and here is the function:
POW_FUNC=lambda header: pack.IntType(256).unpack(__import__('yac_scrypt').getPoWHash(header, data.block_header_type.unpack(header)['timestamp'])),
maybe this can help to provide some help
Good catch. It does look like it takes two arguments. It needs the timestamp as well. Can you change the line to:
hash_bin = yac_scrypt.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]), ntime)
@feeleep75 Any update on this?
yep - here is the code I used:
hash_bin = yac_scrypt.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]), int(ntime, 16))
@feeleep75 Thank you for sharing. I'll try to get this integrated into the master branch
hash_bin = yac_scrypt.getPoWHash (''. join ([header_bin [i * 4: i * 4 +4] [:: -1] for i in range (0, 20)]), int (ntime, 16));
Modify the code, there was some mistakes:
root@ubuntu:/home/stpool/fec-sm# twistd -ny /home/stpool/fec-sm/launcher.tac
Unhandled error in Deferred:
Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/twisted/application/service.py", line 405, in loadApplication
application = sob.loadValueFromFile(filename, 'application', passphrase)
File "/usr/lib/python2.7/dist-packages/twisted/persisted/sob.py", line 210, in loadValueFromFile
exec fileObj in d, d
File "/home/stpool/fec-sm/launcher.tac", line 36, in
Looks like the python formatting is wrong. Check the indentations.
exceptions.IndentationError: unexpected indent (template_registry.py, line 225)
225 lines of code: hash_bin = yac_scrypt.getPoWHash (''. join ([header_bin [i * 4: i * 4 +4] [:: -1] for i in range (0, 20)]), int (ntime, 16));
Check that line for the incorrect indent. It is a good idea to use spaces instead of tabs with python as different interpreters can use 4 or 8 spaces for a tab. Can you verify that the line has spaces and is indented correctly?
@ kczuse
for fec
you should make some changes to yac_scrypt/scryptmodule.c before you install yac_scrypt
const unsigned char minNfactor = 6; const unsigned char maxNfactor = 32; int nChainStartTime = 1375801200;
.........
unsigned char GetNfactor(int nTimestamp) { int l = 0, s, n; unsigned char N;
if (nTimestamp <= nChainStartTime)
return 6; // return 6; here is the value as minNfactor
s = nTimestamp - nChainStartTime;
while ((s >> 1) > 3) {
l += 1;
s >>= 1;
}
.....
Collided with the same task. You would not be able to share a file configuration for stratum. I am a newbie and would very grateful for your help.
added support in https://github.com/ahmedbodi/stratum-mining