RPosts: 2 · Reputation: 585
Hey folks,
I'm messing around with Testnet4 right now. I saw in chainparams.cpp, line 315, where it says consensus.BIP34Height = 1. But when I check the coinbase data for block 1, it doesn't seem to follow BIP34 rules at all. It looks right only from block 17 onwards. Why's that?
MPosts: 14 · Reputation: 612
They *are* compliant, trust me. Just doesn't seem like it at first. For blocks 1 to 16, BIP34 says the height is encoded in a specific way. It uses opcodes OP_1 through OP_16, which map to hex values 0x51 to 0x60. For numbers above that, it's a different encoding style. So it looks off, but it's all good.
0Posts: 257 · Reputation: 80
Is there a unit test for BIP34 in the code? Like, are new blocks being validated properly?
DiPosts: 79 · Reputation: 2112
Check this link https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/blocktools.py#L118
That should help.
RPosts: 2 · Reputation: 585
Thanks for clearing that up!
So, this is about Bitcoin script optimizing for small numbers, right? Using special opcodes for 1 to 16 makes sense.
But I wonder if there's more to it or just these encoding rules we talked about.