stratum-mining-litecoin icon indicating copy to clipboard operation
stratum-mining-litecoin copied to clipboard

help needed for PoS coin

Open feeleep75 opened this issue 11 years ago • 30 comments

Hi,

I am trying to modify the code and I am almost there but when I found a block I've got following error message:

2013-06-28 15:45:24,511 INFO template_registry # We found a block candidate! 000000004b1b0f30a6b9cc0b94444a60449e8cd1ffd217af81a4b6a455a556b9 2013-06-28 15:45:24,511 ERROR protocol # [Failure instance: Traceback: <type 'exceptions.AttributeError'>: 'BlockTemplate' object has no attribute 'scrypt' /home/pools/bot/stratum/stratum/protocol.py:192:dataReceived /home/pools/bot/stratum/stratum/protocol.py:238:lineReceived /home/pools/bot/stratum/stratum/services.py:13:_handle_event /home/pools/bot/stratum/stratum/services.py:81:call --- --- /usr/lib/python2.7/dist-packages/twisted/internet/defer.py:134:maybeDeferred /home/pools/bot/stratum/stratum/services.py:78:_run /root/bot/stratum-mining-litecoin-39e37e556c0bebdb1a03caaa024466b7628a291a/mining/service.py:100:submit /root/bot/stratum-mining-litecoin-39e37e556c0bebdb1a03caaa024466b7628a291a/lib/template_registry.py:258:submit_share /root/bot/stratum-mining-litecoin-39e37e556c0bebdb1a03caaa024466b7628a291a/lib/halfnode.py:228:is_valid /root/bot/stratum-mining-litecoin-39e37e556c0bebdb1a03caaa024466b7628a291a/lib/halfnode.py:215:calc_scrypt ] None

Any advise where to look for it?

feeleep75 avatar Jun 28 '13 14:06 feeleep75

@feeleep75 do you have a fork I can look at? I can help with the debugging.

From the backtrace it looks like you are missing import scrypt in lib/block_template.py

2013-06-28 15:45:24,511 ERROR protocol # [Failure instance: Traceback: : 'BlockTemplate' object has no attribute 'scrypt'

If you changed the import scrypt to import scrypt-jane or something similar, you would have to change any instance of scrypt. to scrypt-jane. and do on.

I am on freenode #mmcfe-ng channel right now if you want some help.

moopless avatar Jun 28 '13 14:06 moopless

no - it is not scrypt-jane (next in a queue :)) - this is Bottlecaps coin - fork of Novacoin. It use also scrypt but there is a few differences I have to made to start actually using it. this is stratum which works for Nova:

https://github.com/CryptoManiac/stratum-mining

but for BOT I would need to change it as well, however it has a bug that you fixed already with false positives.

feeleep75 avatar Jun 28 '13 14:06 feeleep75

Are you merging the changes into from that branch into this one? I tried looking at the stack trace, but our line numbers are not the same. My guess, with out being able to look at the code, is that either CBlock or BlockTemplate is missing a self.scrypt = none definition. It is more likely that you need the following.

diff --git a/lib/block_template.py b/lib/block_template.py
index ace3d27..1f26d54 100644
--- a/lib/block_template.py
+++ b/lib/block_template.py
@@ -30,6 +30,7 @@ class BlockTemplate(halfnode.CBlock):
         self.timedelta = 0
         self.curtime = 0
         self.target = 0
+       self.scrypt = None
         #self.coinbase_hex = None
         self.merkletree = None

moopless avatar Jun 28 '13 15:06 moopless

Did the adding of self.scrypt work to have it working? for BOT? or even more changes neccessary?

JohnDorien1 avatar Jun 29 '13 15:06 JohnDorien1

Try the PoS branch that I just committed. I think the changes that you were implementing were conflicting with what we had already done. We did not need to merge the changes from CryptoManiac, but rather the one commit 3429cb8a6d5858e0bc245b3a1471e42f1907d755 from https://github.com/TheSeven/stratum-mining/commit/3429cb8a6d5858e0bc245b3a1471e42f1907d755 as I had already change this into a scrypt coin.

@feeleep75 and @JohnDorien1 Please test the new branch. My testing shows that it works, but I can only hash at 6khash right now so it is not a good test.

git fetch
git checkout PoS

moopless avatar Jun 29 '13 15:06 moopless

I haven't tried the fork yet but I hacked in cryptomaniacs fork myself, looking at the fork it should work. I've confirmed it works for bottlecaps, tried with CosmosCoin but throws an exception "Block decode failed" and never accepts block finds so I need some help there

Notes:

  1. you need to generate a new public key and use that as the central wallet address instead of the regular address (whatervercoind getnewpubkey)
  2. it breaks the new blockexists function, the block_hex_hash seems to be different than the block hash generated
  3. bottlecaps and CosmosCoin is blocktemplate version 4

obigal avatar Jun 29 '13 20:06 obigal

@obigal good work!

  1. Found that one out the hard way :+1: . I updated the error messages to indicate that the CENTRAL_WALLET needs to be the pubkey. You can get if from getting your current address from coindaemon listbyreceivedaddress 0 true and then get the pubkey from coindaemon validateaddress address under pubkey. You can generate a new address/pubkey as well.
  2. @JohnDorien1 was doing some tests with the branch and it seems to be working with the blockexists for CryptoBullion. If it is not working for a coin, that means that they are not using a double sha256 to generate the block hash or they have changed the block header.
  3. Allowed for versions >1 in 68a47b2adc4fbc7b5bca233ea169cbc06eb2d0fe, so that should work now.

I went to take a quick look at the source (my c++ is very rusty) so here is what I think.

Calculate the hash in ProcessBlock https://github.com/cosmoscoin/cosmoscoin/blob/master/src/main.cpp#L2266

pblock is a CBlock object. So the GetHash is defined in that class. https://github.com/cosmoscoin/cosmoscoin/blob/master/src/main.h#L921

Which leads up to a scrypt_hash from scrypt. This, I believe indicates that they are using the scrypt hash for the block chain. So you can check it from the logs. Compare a share against the block hash to see if they are the same. Or apply this patch to see if it works.

 --- a/lib/template_registry.py
 +++ b/lib/template_registry.py
 @@ -261,7 +261,7 @@ class TemplateRegistry(object):

             # 7. Submit block to the network
             serialized = binascii.hexlify(job.serialize())
-            on_submit = self.bitcoin_rpc.submitblock(serialized, block_hash_hex)
+            on_submit = self.bitcoin_rpc.submitblock(serialized, scrypt_hash_hex)

             return (header_hex, scrypt_hash_hex, share_diff, on_submit)

moopless avatar Jun 29 '13 22:06 moopless

I am testing BOT now - will post results when I find a block :)

feeleep75 avatar Jun 30 '13 07:06 feeleep75

@feeleep75 Thanks! let me know what you find. I just pushed 15296fd for the patch I put in above. Let me know if the blocks are getting tagged correctly.

When I get my rig to stop crashing randomly, I'll test this myself.

moopless avatar Jun 30 '13 14:06 moopless

So here is another potential patch. Make sure that your branch is using submitblock and not getworktemplate. --- a/lib/bitcoin_rpc.py +++ b/lib/bitcoin_rpc.py @@ -45,7 +45,7 @@ class BitcoinRPC(object): #resp = (yield self._call('getblocktemplate', [{'mode': 'submit', 'data': block_hex}])) if json.loads(resp)['result'] == None: # make sure the block was created. - defer.returnValue((yield self.blockexists(block_hash_hex))) + defer.returnValue(True) else: defer.returnValue(False)

Anyone that is testing this, can you run it with:

twistd -ny launcher.tac -l debug.log

That should log it to debug.log. Can you send the debug.log? Or at least the sections around the "candidate" in that log and stratum.log?

moopless avatar Jun 30 '13 14:06 moopless

I think it works now with all patches:

2013-06-30 21:03:21,259 DEBUG protocol protocol.lineReceived # > {u'params': [u'feeleep.1', u'33', u'03000000', u'51d080d7', u'65200200'], u'id': 437, u'method': u'min$ 2013-06-30 21:03:21,260 INFO template_registry template_registry.submit_share # Yay, share with diff above 100000 2013-06-30 21:03:21,260 INFO template_registry template_registry.submit_share # We found a block candidate! 0000000035619a67c0479a6a6f545de026fa781447becc94e3a6b3e7c81$ 2013-06-30 21:03:21,261 INFO interfaces interfaces.on_submit_share # 0000000035619a67c0479a6a6f545de026fa781447becc94e3a6b3e7c81f9462 (314285) valid feeleep.1 2013-06-30 21:03:21,262 DEBUG protocol protocol.writeJsonResponse # < {"error": null, "id": 437, "result": true} 2013-06-30 21:03:21,725 INFO interfaces interfaces.on_submit_block # Block 0000000035619a67c0479a6a6f545de026fa781447becc94e3a6b3e7c81f9462 ACCEPTED 2013-06-30 21:03:21,726 INFO DBInterface DBInterface.found_block # Updating Found Block Share Record 2013-06-30 21:03:21,726 DEBUG DBInterface DBInterface.do_import # DBInterface.do_import called. force: yes, queue size: 11 2013-06-30 21:03:21,726 INFO DBInterface DBInterface.do_import # Inserting 11 Share Records 2013-06-30 21:03:21,727 DEBUG DB_Mysql DB_Mysql.import_shares # Importing Shares

feeleep75 avatar Jun 30 '13 19:06 feeleep75

Confirmed it works fine for cryptobullion.

On another note in the basic_share_limiter.py getdifficulty returns an array so that's going to need fixing.

obigal avatar Jul 01 '13 06:07 obigal

Thanks @obigal and @feeleep75.

Can you confirm what branch/patches you are on? I just pushed a fix for submitblock to all branches. Do PoS coins fail when block confirmation is enabled?

@obigal I'll have to fix that. Do you have a patch already written?

moopless avatar Jul 01 '13 21:07 moopless

I did a fix for PoS coins in the smarty globals of mmcfe-ng. Don't know python but maybe it still helps: $cDifficulty = $bitcoin->query('getdifficulty'); //} if (is_array($cDifficulty)) { $dDifficulty = $cDifficulty['proof-of-work']; } else { $dDifficulty = $cDifficulty; }

Going to test branches master and PoS today on CGB and a random scrypt PoW coin with low diff for fast block finding

JohnDorien1 avatar Jul 02 '13 07:07 JohnDorien1

I haven't checked out the latest commits yet, my cryptobullion pool is live and working well and I didn't want to break it but I will check it out locally soon. Block confirmation works just fine using the scrypt hash. This is what I have in basic_share_limiter.

dDiff = (yield Interfaces.template_registry.bitcoin_rpc.getdifficulty())
self.litecoin['difficulty'] = dDiff['proof-of-work']

obigal avatar Jul 02 '13 11:07 obigal

Has anyone gotten this to work with cosmoscoin?

flound1129 avatar Aug 14 '13 17:08 flound1129

The coin client won't accept submitted block candidates for me.

On Aug 14, 2013, at 2:13 PM, flound1129 [email protected] wrote:

Has anyone gotten this to work with cosmoscoin?

— Reply to this email directly or view it on GitHub.

nicoschtein avatar Aug 14 '13 21:08 nicoschtein

Anyone have the link for cosmoscoin? I'll see what needs to be done to the header to submit it.

moopless avatar Aug 14 '13 21:08 moopless

Same here, I get the following error in debug.log:

ThreadRPCServer method=submitblock

******* exception encountered ******* cosmoscoind[0x57009c] cosmoscoind[0x41ef9f] cosmoscoind[0x423e48] cosmoscoind[0x48fcb3] cosmoscoind[0x4c5f3f] cosmoscoind[0x51db88] cosmoscoind[0x4e33bb] cosmoscoind[0x4e5ad7] /usr/lib/libboost_thread.so.1.53.0(+0xcef9)[0x7fa300135ef9] /lib/x86_64-linux-gnu/libpthread.so.0(+0x7f8e)[0x7fa2ff33cf8e] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7fa2fe848e1d]

The main.cpp block code is near identical to CGB so I'm not really sure what the problem is. CGB works fine with stratum.

flound1129 avatar Aug 14 '13 21:08 flound1129

https://github.com/cosmoscoin/cosmoscoin

flound1129 avatar Aug 14 '13 21:08 flound1129

I tried changing the submit code to use block_hash_hex (scrypt_hash_hex in your code) but I still get the same error.

flound1129 avatar Aug 14 '13 21:08 flound1129

Anyone crack the code on CMC yet?

flound1129 avatar Aug 22 '13 08:08 flound1129

I'm trying to figure this out too! any word? Changes are needed for this to work for CMC philospherstone, diamond, star.

MarKus13 avatar Sep 09 '13 04:09 MarKus13

Nope, haven't heard anything. I think moopless has stopped working on it.

On Sun, Sep 8, 2013 at 9:32 PM, MarKus13 [email protected] wrote:

I'm trying to figure this out too! any word? Changes are needed for this to work for CMC philospherstone, diamond, star.

— Reply to this email directly or view it on GitHubhttps://github.com/moopless/stratum-mining-litecoin/issues/26#issuecomment-24039816 .

flound1129 avatar Sep 09 '13 04:09 flound1129

problems are on coins side not stratum server...

feeleep75 avatar Sep 11 '13 12:09 feeleep75

Agreed, but we should be able to work around it, I think. Pushpool seems to work. Coin devs seem clueless or unmotivated to fix it.

flound1129 avatar Sep 11 '13 16:09 flound1129

If coindevs are unmotivated to fix it, maybe it's time to question the coin in itself? :D Workarounds are not a proper solution, @moopless can't work around all issues that are coming from coind's core. Startum can be build around the limits given by coind devs but beyond that it's not stratums responsibility to fix their issues with workarounds.

That's my 2 cents on that, moopless might see that different of course.

PS: Pushpool uses getwork and not the work templates, that's why it works. Coin devs might not have looked at work templates hence they don't work.

TheSerapher avatar Sep 11 '13 16:09 TheSerapher

Hello. I'm new to stratum and i'm trying to set up a small pool for family members only. Any proceeds will be used to help fund our family picnic. We decided to go with Bottlecaps. I got as far as setting up Stratum following a guide. The problem is the guide was written for Vertcoin (git clone https://github.com/scr34m/vertcoin_scrypt) not bottlecaps and I think I need a bottlecaps_scrypt file to setup Stratum.

Many Google searches led me here. It looks like you guys are working on the scrypt file or at lest getting Stratum working for bottlecaps. Anyway I could get a link to the file I'm looking for?

Thanks!

Tmerlo avatar Aug 16 '14 22:08 Tmerlo

@flound1129 did you ever figure out a work around, or did the coin dev ever patch this?

doged avatar Sep 28 '15 13:09 doged

I'm pretty sure ahmed bodi's version works with PoS.

flound1129 avatar Sep 28 '15 16:09 flound1129