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

Pool generate wrong coinbaseHash while using groestl #156

Closed
volbil opened this issue Jul 24, 2018 · 5 comments
Closed

Pool generate wrong coinbaseHash while using groestl #156

volbil opened this issue Jul 24, 2018 · 5 comments

Comments

@volbil
Copy link

volbil commented Jul 24, 2018

Hello, I'm trying to launch pool for my groestl (not myriad groestl) based coin. When I tried mining pool give me strange "We thought a block was found but it was rejected by the daemon" message. After some code researching and debug I found this piece of code in lib/jobManager.js file:

var coinbaseHasher = (function(){
    switch(options.coin.algorithm){
        case 'keccak':
        case 'blake':
        case 'fugue':
        case 'groestl':
            if (options.coin.normalHashing === true)
                return util.sha256d;
            else
                return util.sha256;
        default:
            return util.sha256d;
    }
})();

As you can see, while you using groestl pool use regular sha256 instead of sha256D for coinbase tx hashing which results to generating wrong Merkle Root (bad-txnmrklroot error if be more precise). I tried add normalHashing flag to coin config, and it start generating correct hash and merkle root, but it resulted to wrong block hash (it looks like that 98ae12ff1e3f61505da5d0cd705823c5a6f72be65da36c49a692c86d77b04dae).
I tried to figure out why it's happening on my own, but after week of googling and research I'm out of ideas, you my last hope @zone117x :D

@volbil
Copy link
Author

volbil commented Jul 24, 2018

By the way @foxer666 @devnull-ed any ideas?

@zone117x
Copy link
Owner

Check the source of the coin you're mining and see what hashing algorithms it uses for coinbase/transactions, block header hash, and full block hash.
See this comment about how they are often disjointed #154 (comment)

@volbil
Copy link
Author

volbil commented Jul 24, 2018

I'm developing my simple bitcoin-based proof of concept coin, and it pretty much works like pure bitcoin. For coinbase/transactions it uses default sha256D for but for header hash I use groestl algo.
I checked results given by pool and here is what I get:

With normalHashing flag false (it uses sha256 for coinbase hashing):

coinbaseBuffer = 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1f020702044db9575b0840000000000000000d2f6e6f64655374726174756d2f00000000030000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9b037b41d000000001976a914a2e35b2f3b6dede3b48a6c3d75fa6946702e1cec88ac502d1900000000001976a91464bb9cc52097859e0945f68368d812d8a8d6ef5388ac00000000

coinbaseHash = 5265d61b335195adb0049671bf2c807134ad52ea0b831f5fd25f41d8fb8a88ae
merkleRoot = ae888afbd8415fd25f1f830bea52ad3471802cbf719604b0ad9551331bd66552

headerBuffer = 000000208e427786b088c50ab4a38aeb03802d330374b7ce051878bac2cd9147b40500005265d61b335195adb0049671bf2c807134ad52ea0b831f5fd25f41d8fb8a88ae4db9575bffff0f1e80000eb9
headerHash = 3151c0f3afc8d1a2c887cfdf7d3b5dad152b4a5fd4fb4995362b52ef0b000000

blockHash = 0000000bef522b369549fbd45f4a2b15ad5d3b7ddfcf87c8a2d1c8aff3c05131

As you can see, it generate valid blockHash but because bitcoin use sha256D for transaction hashing, it produce invalid coinbase hash which result to invalid Merkle Root.

With normalHashing flag true (it uses sha256D for coinbase hashing):

coinbaseBuffer = 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1f02070204abb8575b0828000000000000000d2f6e6f64655374726174756d2f00000000030000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9b037b41d000000001976a914a2e35b2f3b6dede3b48a6c3d75fa6946702e1cec88ac502d1900000000001976a91464bb9cc52097859e0945f68368d812d8a8d6ef5388ac00000000

coinbaseHash = 2e0d327fbb576928f321cbceb851b4a713083dc858c7373624440a150e5ec3dc
merkleRoot = dcc35e0e150a44243637c758c83d0813a7b451b8cecb21f3286957bb7f320d2e

headerBuffer = 000000208e427786b088c50ab4a38aeb03802d330374b7ce051878bac2cd9147b40500002e0d327fbb576928f321cbceb851b4a713083dc858c7373624440a150e5ec3dcabb8575bffff0f1e0001b6da
headerHash = c5c366110143efd823255600cccc513a9216c7fcf872531d57119b75570ede07

blockHash = 07de0e57759b11571d5372f8fcc716923a51cccc00562523d8ef43011166c3c5

In this case pool produce correct coinbaseHash, but it result to invalid blockHash :(

I believe this issues (1, 2, 3) also caused by this bug.

P.s. just in case, solo mining works fine, thats why I think thats not coin but pool bug.
P.s.s. if you have any ideas or need debug logs just let me know :)

@zone117x
Copy link
Owner

You may need to implement another pool setting and associated js to specify which algo to use for blockHash specifically.

@volbil
Copy link
Author

volbil commented Aug 6, 2018

Hello again @zone117x just want let you know, that I managed to successfully launch your pool, problem was in my code (for some reason pool start working when I use diamond groestl lol). But anyway, thanks for your help, your pool is AWESOME :) !

@volbil volbil closed this as completed Aug 6, 2018
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

2 participants