Skip to content
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

Parser cannot extract block heights from nonstandard blocks #17

Open
gtank opened this issue Jan 28, 2019 · 3 comments
Open

Parser cannot extract block heights from nonstandard blocks #17

gtank opened this issue Jan 28, 2019 · 3 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@gtank
Copy link
Contributor

gtank commented Jan 28, 2019

Here are four regtest blocks generated with the following parameters:

regtest=1
nuparams=5ba81b19:0 # Overwinter
nuparams=76b809bb:1 # Sapling 
040000000000000000000000000000000000000000000000000000000000000000000000db4d7a85b768123f1dff1d4c4cece70083b2d27e117b4ac2e31d087988a5eac40000000000000000000000000000000000000000000000000000000000000000dae5494d0f0f0f2009000000000000000000000000000000000000000000000000000000000000002401936b7db1eb4ac39f151b8704642d0a8bda13ec547d54cd5e43ba142fc6d8877cab07b30101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff071f0104455a6361736830623963346565663862376363343137656535303031653335303039383462366665613335363833613763616331343161303433633432303634383335643334ffffffff010000000000000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000
0400000027e30134d620e9fe61f719938320bab63e7e72c91b5e23025676f90ed8119f02591cdaf793a2a4f61c4cec11705e8e4bb5d0f19e945fc8e21741181b0aae0f08fbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e66474f5c0f0f0f20280015f8919cd877c280445699d684f55821bb47996f2d71bc63262cd6fd00002402279992d0a33ce9ec16ebc9d761ef9952ed1092f0deb49742857b12f814fdb58c89a369010400008085202f89010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0200ca9a3b000000001976a9144a659bad0ece8040f97a67ab4eb9605fc7f27b4988ac80b2e60e0000000017a9146708e6670db0b950dac68031025cc5b63213a4918700000000000000000000000000000000000000
040000003af9140b34e27951f813c509300001fb549fcb7a01ad0b00567c4948ec266a06600f0187179959aa78a042a728acebedfc99f5940a2d513cdd1f96c3467884aefbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e67474f5c0f0f0f202c00df39093dfb0e92f7ac46969bd48e0587bece099a8eacd4310488aba3000024035c15f6815e65db6123cb27d7c3bc2d1182062a84f3c3971a2bc41c479139a22b7d40d0010400008085202f89010000000000000000000000000000000000000000000000000000000000000000ffffffff03520101ffffffff0200ca9a3b000000001976a9144a659bad0ece8040f97a67ab4eb9605fc7f27b4988ac80b2e60e0000000017a9146708e6670db0b950dac68031025cc5b63213a4918700000000000000000000000000000000000000
04000000fe5e53211a36e5c35690d7cf46e0c0483e3c2b17aa48fbe6b579ec9a4174940acd04b0d436223932c841099681bd43abcc152f11ab61f4f93b651f3529d86659fbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e67474f5c0f0f0f2007006e5eea83495199cb3da05bf2cfe3f261b8887964ade88d62b85fbead000024048968f5d20494aceb48479937b48cc265a605ba317bd46481316b11144fbb932a3e93d4010400008085202f89010000000000000000000000000000000000000000000000000000000000000000ffffffff03530101ffffffff0200ca9a3b000000001976a9144a659bad0ece8040f97a67ab4eb9605fc7f27b4988ac80b2e60e0000000017a9146708e6670db0b950dac68031025cc5b63213a4918700000000000000000000000000000000000000

The expected result would be block heights 0, 1, 2, 3 (unclear actually on the genesis block behavior, but the others should work). In fact though all of them come out as height -1 (indicating a parse error of some sort).

@gtank
Copy link
Contributor Author

gtank commented Feb 8, 2019

Solved: it can't extract them because they are not there. Or at least they're not as expected. This doesn't matter for production networks, so we'll come back to it if it comes up later.

@gtank gtank closed this as completed Feb 8, 2019
@gtank gtank reopened this Feb 14, 2019
@gtank gtank changed the title Parser cannot extract block height from regtest blocks Parser cannot extract block heights from nonstandard blocks Feb 14, 2019
@gtank
Copy link
Contributor Author

gtank commented Feb 14, 2019

The parser also gets the wrong block height for the genesis block.

@gtank gtank added the bug Something isn't working label Feb 14, 2019
@gtank gtank added this to the Sprint 15 milestone Feb 14, 2019
@gtank
Copy link
Contributor Author

gtank commented Feb 25, 2019

The genesis block is being parsed fine. What's wrong is that the genesis block contains a commitment to the initial target difficulty where the coinbase height should be. It does not contain the height. So in fact this bug is a failure to special-case the genesis block, not an incorrect parse.

The genesis block: https://gist.github.com/gtank/daadb1a90d8c131eb1a5b96b80d59f97
The 04ffff071f in the first input transaction scriptsig field is what's giving us trouble. You can see where it's added (along with the number 4?) here: https://github.com/zcash/zcash/blob/fe0507761a5bd1c35dbc657c6f9ed7f553e55662/src/chainparams.cpp#L30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant