-
Notifications
You must be signed in to change notification settings - Fork 347
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
Invalid height in coinbase bug #349
Comments
I've just noticed, the coinbase starts 010d (height is 1 byte, then heigh in little endian 0d = 13) which is correct for the block height.. I'll double check the Bitmark code, just in case the bitcoin dev's have hard coded 03 in their as they expect it to be 3 bytes on the bitcoin network. |
So, this only happens when the block height is 16 or below, and only with stratum mining. After 0 code changes to stratum-mining and bitmark, it works from above block 17 onwards. I've reset the blockchain and tried again, rejects all the way to 16 and then fine. Very strange. Consider it fixed I think, I'll make a note in my own repo |
hmm thats weird then |
I can confirm this is a bug particular to stratum-mining, replicated it 3 times. Perhaps the block height is encoded incompatibly when below 17, since in hex it is a single char instead of two? |
I am wondering if this has been figured out? Is it because it was hard coded to 3 bytes? import binascii
def ser_number(n, min_size = 1):
# Little Endian
# For encoding nHeight into coinbase
s = bytearray(b'\1')
while n > 127:
s[0] += 1
s.append(n % 256)
n //= 256
s.append(n)
# Satisify Minumim Length
if min_size < 1:
min_size = 1
while len(s) < min_size + 1:
s.append(0)
s[0] += 1
return bytes(s)
print "Encoded 17: %s" % binascii.hexlify(ser_number(17))
print "Encoded 16: %s" % binascii.hexlify(ser_number(16)) Result
Even forcing 3 bytes, it still rejects blocks until 17
|
Also seeing this issue with a new PIVX clone. Trying to test if it fixes itself after block 16. which i'm guessing it does. before block 16 it appends a dummy script to the coinbase mentioned here |
also talked about here as well. qtumproject/qtum#15 Which makes me think its coin related. I've attempted the changes described there but pivx has no consensus.bip34height or consensus.bip34hash that I can find. and adding the simple "00 >> " to the genesis block scriptsig and re creating didn't work for me. EDIT: mining with the internal miner past block 16 then starting stratum-mining worked. |
😂 welcome back to the scene. Yeah the problem is somewhere in how the block is serialised |
Thanks man haha. I'm slowly getting back into things lol but that was never my forte. If you take a look at qtum projects pull request 16 it shows how they do it for the genesis. maybe that will be of some use? or the reference from the framework tests.
|
that looks about right, ive not worked on this forever, the changes ive done recently were just cleanup mostly to make it work in a sorta way for someone |
Do you have somewhere I could contact you easier? Discord? Here's my username. |
discords fine, same username ahmedbodi |
As discussed with ahmed on bitcointalk, stratum-mining and the new Bitmark code base I've created aren't playing nicely.
Specifically, my codebase is bitcoin with scrypt support, and version 2 blocks requiring the height to be in the coinbase. As per https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki#specification
I've tested on multiple miners, cgminer, minerd, the internal miner, they all work correctly, only stratum-mining is faulting.
The below was the submission of found block with height 13
stratum-mining submitting a found block:
Block::print() output from bitmark debug log for above submitted block:
Apologies as I haven't dissected it to find the exact error. I have checked that getblocktemplate is returning the right value:
To be explicit, the error is being thrown within Bitmark on line 2408, code here: https://github.com/coinsolidation/bitmark/blob/master/src/main.cpp#L2408
I'll monitor the thread to see if I can be of any further assistance.
The text was updated successfully, but these errors were encountered: