Author

Topic: Mining info from pool (Read 618 times)

member
Activity: 102
Merit: 11
September 22, 2017, 07:02:18 AM
#3
its about the process in mining ......... get info from a pool.... select extranonce2...... build coinbase...... hash it.... add with merkle branch... calculate merkle_root....... make block header....hash it .... compare to target difficulty..... if less....... then Enjoy!! ....... You found a share......  Wink
The issue is...... info we get in the job from any pool...... some of them are in little endian and some are not........
I am specifically worried about merkle_root.... whose hash... is needed to build block header...
Anyway thanks
full member
Activity: 292
Merit: 100
Miningcore
September 21, 2017, 12:05:38 PM
#2
You've embarked on a journey of pain and suffering. I feel for you, I've been there.  Wink
member
Activity: 102
Merit: 11
September 16, 2017, 02:55:42 AM
#1
While getting my head around to understand the mining process and checking in python..... i am puzzled with which info from/to pool are in Little Endian.
Specifically For the merkle root .......do i need to reverse the bytes before/after
For example ............. response to mining.authorize gives me ..... job_id,prevhash,coinb1,coinb2,merkle_branch,version,nbits,ntime,clean_jobs =
Code:
{'id': None,
 'method': 'mining.notify',
 'params': ['59bc8dfc0000029f',
            '0eba48f47bc0ab4bb35b230849868bf1d79aeb19006eed460000000000000000',
            '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff35039a6807000404d5bc5904fc873d140c',
            '0a636b706f6f6c112f736f6c6f2e636b706f6f6c2e6f72672fffffffff03c4626c4e000000001976a914fc6123f4bfd3a840b4387ab90e9801e98fb17cf888acb1caca00000000001976a914f4cbe6c6bb3a8535c963169c22963d3a20e7686988ac0000000000000000266a24aa21a9edab3b87f3963e55a23f3cea5e4435bf6637328fd5e329bb8fdac7d31c3a01d26200000000',
            ['c251d18568d2cdb07c376d5f3304a2161e3d09d289d1a7e53737199171d73ae6',
             '4f9bcac3ec00fc8238db04b7758a1b673bdf38b93e48159678b60b51517dd563',
             '2aadad2c9c8e6df5c71264524b090cdf89830f12949527f7872c243bc1dc552c',
             '8c5edf39c0d85c9853308eef3ce6f9b71c8d6584ca4120d411bc75987bb2f254',
             '48751c2ae0ddc05f5d504a3d6039e7d5afb3d5f2a6aaac93bd5822e5f8efc328',
             '3e9b5c6b986c2ddc09bf8604eb2bd2a3b49b46f11042c282331a206dadb4296e',
             'c65f502b11b325abc0fac847e8fc5cd300169160e7244b29dd5acc3d0e4b8605',
             'afe7d2287020c4291f609a772adbeafc952a8de0ced38a7346acb6c7103bec6d',
             '0caa545ae63de39d47baea100ea15a18061235d7e1a372fbca88edf9ca5ac797',
             'c5bfff15b4dd64e7faac98f1bba118fb11990e4ff146cb45c7f4af6b93e2ea03',
             'a8805201e8152c1f5835c9aa024752fb34aeb7fa55dd3af0ae6109918f328dbb'],
            '20000000',
            '1801310b',
            '59bcd504',
            True]}

Based on the pool response....I can build the coinbase just by
Code:
coinbase = coinb1 + extranonce1 + extranonce2 + coinb2
coinbase_hash_bin = hashlib.sha256(hashlib.sha256(binascii.unhexlify(coinbase)).digest()).digest()
coinbase:01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff35039a6807000404d5bc5904fc873d140c2be5bc5900000000df9971c00a636b706f6f6c112f736f6c6f2e636b706f6f6c2e6f72672fffffffff03c4626c4e000000001976a914fc6123f4bfd3a840b4387ab90e9801e98fb17cf888acb1caca00000000001976a914f4cbe6c6bb3a8535c963169c22963d3a20e7686988ac0000000000000000266a24aa21a9edab3b87f3963e55a23f3cea5e4435bf6637328fd5e329bb8fdac7d31c3a01d26200000000
coinbase hash: '49f99aaf253e4535147c75fc9e8402c0528437dd09b4181939b28f47aee91c59'
Therefore my merkle_root will be
Code:
fb68998fe1dd4cc22fa1225c2592c27df5331d40d9b33ffce99b26c0aead8ef4
Is this correct ? Do i need to reverse it ? later / before ? for putting in block header and hashing.

Finally to submit a share we perhaps simply need...
Code:
payload = '{"params": ["'+address+'", "'+job_id+'", "'+extranonce2 +'", "'+ntime+'", "'+nonce+'"], "id": 1, "method": "mining.submit"}\n'
sock.sendall(payload.encode('utf-8'))

But i maybe wrong??
Jump to: