Testnet4 and BIP34 Compliance Issues

4 replies 194 views
RogueLaserFull Member
Posts: 2 · Reputation: 585
#1Dec 27, 2024, 09:19 PM
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?
3 Reply Quote Share
matrix2021Full Member
Posts: 14 · Reputation: 612
#2Dec 29, 2024, 04:41 PM
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.
1 Reply Quote Share
0xNodeMember
Posts: 257 · Reputation: 80
#3Dec 29, 2024, 10:05 PM
Is there a unit test for BIP34 in the code? Like, are new blocks being validated properly?
3 Reply Quote Share
diamondhandsHero Member
Posts: 79 · Reputation: 2112
#4Dec 29, 2024, 11:05 PM
Check this link https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/blocktools.py#L118 That should help.
3 Reply Quote Share
RogueLaserFull Member
Posts: 2 · Reputation: 585
#5Dec 31, 2024, 05:43 AM
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.
6 Reply Quote Share

Related topics