Testnet4 Ignoring BIP Rules

4 replies 321 views
DarkMinerFull Member
Posts: 103 · Reputation: 432
#1May 23, 2021, 09:52 AM
Hey everyone, I’m digging into Testnet4 right now. In the file chainparams.cpp, I see this line: Line 315 consensus.BIP34Height = 1; But when I check the coinbase data in block 1, it doesn’t follow the BIP34 rules. It’s only from block 17 onwards that the coinbase data is actually set up right according to those rules. Any idea why that’s happening? Cheers
6 Reply Quote Share
ryan_nodeSenior Member
Posts: 202 · Reputation: 852
#2May 23, 2021, 01:58 PM
Those blocks actually are compliant. They only do not look like all the ones after because of the script encoding rules for the numbers 1 through 16. BIP 34 specifies that the height is encoded as "minimally encoded serialized CScript". For 1 through 16, this minimal encoding is actually the opcodes OP_1 through OP_16, which correspond to the hex values 0x51 through 0x60. All other numbers are length prefixed and encoded in little endian.
3 Reply Quote Share
LuckyCoinLegendary
Posts: 832 · Reputation: 4795
#3May 23, 2021, 03:42 PM
Is there a unit test in the codebase for BIP34 block checks, or validating new blocks in general?
0 Reply Quote Share
sage777Full Member
Posts: 102 · Reputation: 305
#4May 23, 2021, 08:45 PM
https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/blocktools.py#L118
3 Reply Quote Share
DarkMinerFull Member
Posts: 103 · Reputation: 432
#5May 24, 2021, 07:46 AM
Thanks for your answers. Is the reason for this behavior that the Bitcoin script specifications are specifically optimized for small numbers? And the bitcoin script generally uses special opcodes (OP_1 to OP_16, corresponding to 0x51 to 0x60) for numbers 1 to 16 as part of the minimal encoding rules? Or is there an additional justification or other reason for this behavior? Best regards
0 Reply Quote Share
?Reply
Sign in to reply to this topic

Related topics