-
Notifications
You must be signed in to change notification settings - Fork 404
[0.17] blockheaders include block height, nodes validate it#431
[0.17] blockheaders include block height, nodes validate it #431instagibbs merged 2 commits intoElementsProject:elements-0.17 from
Conversation
2a12b30 to
a89d0eb
Compare
@jtimon
jtimon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, could use a rebase and move the -con_blockheightinheader to chainparams.
src/primitives/block.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need g_block_height_in_header here too
a89d0eb to
32c7386
Compare
instagibbs
commented
Oct 16, 2018
forgot to push my fixes that I believe fixed things. Will switch to chainparams setup next.
32c7386 to
d8ee236
Compare
instagibbs
commented
Oct 18, 2018
Feature complete now, just no tests.
04c8fe5 to
97b714f
Compare
src/chainparams.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, just don't use -con_blockheightinheader at all outside of CCustomParams and you shouldn't need to touch neither CMainParams, CTestNetParams or CRegTestParams, specially not their asserts.
Perhaps it would be interesting to rebase on top of #436 and add a test like this:
{
'memo': 'default_style with height in header',
'genesis': 'c03f16ae9e2980de2b61fd6dc84af8ac4a37bea928af632166a6b36c5c871ddd',
'args': [
'-con_genesis_style=default_style',
'-con_blockheightinheader',
],
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It creates a new style genesis block for each network when iterating through network types during load, then hits the assert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means blockheight_in_header is not really acting as false for main, test and regtest, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, if you don't set -con_blockheightinheader to true
97b714f to
3f3b3ab
Compare
instagibbs
commented
Oct 22, 2018
I'm getting build failures for windows and other builds due to gArgs in block.h.
instagibbs
commented
Oct 22, 2018
tricked PR to refresh by closing/opening
ba230a7 to
529efb1
Compare
529efb1 to
02bfec8
Compare
instagibbs
commented
Oct 25, 2018
Took essential fixes from #442 and squashed.
02bfec8 to
15e8f6e
Compare
instagibbs
commented
Oct 26, 2018
Rebased, fixed some tests.
e4a3331 to
977ea1a
Compare
instagibbs
commented
Oct 29, 2018
Finally resolves all issues and tests. Ready for review.
mword
commented
Oct 31, 2018
Note that for me many tests fail with test/functional/test_runner.py --extended . The extended functional tests pass on the elements-0.17 branch.
instagibbs
commented
Oct 31, 2018
@mword ah good catch. Will take a look.
instagibbs
commented
Nov 1, 2018
Looks like upstream moved all but two tests into the normal testing regime. We should probably mirror that if possible.
977ea1a to
29763da
Compare
instagibbs
commented
Nov 5, 2018
rebased onto tip to catch most extended failures
51a9458 to
a8c6fcd
Compare
instagibbs
commented
Nov 5, 2018
All builds passing, squashed.
mword
commented
Nov 6, 2018
tACK with one caveat: I ran test_runner.py twice once with --extended and then once without, the second run (without --extended) the rpc_rawtransaction.py test failed. I could not reproduce the failure. I ran test_runner.py again several with no problems and I ran the rpc_rawtransaction.py test by itself a number of times with no failures.
stevenroose
commented
Nov 6, 2018
tACK a8c6fcd
instagibbs
commented
Nov 13, 2018
will cherry-pick Blockstream/liquid#3 when merged
stevenroose
commented
Nov 15, 2018
ACK when you merge liquid#3 :)
instagibbs
commented
Nov 15, 2018
@stevenroose oh it appears I already mirror this logic in liquid#3, great minds yada yada
instagibbs
commented
Nov 19, 2018
via email
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this doesn't need to be conditional. Bitcoin block indexes sure won't have height here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure myself, but Greg discussed it with Jorge here: #431 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with chainparams (ie if the global was a field in chainparams), because chainparams depends on block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment probably doesn't need to be conditional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modifying the function signature like this is begging for silent bugs.
Instead, add block_height to the end, and always specify it by name (enforce with PEP 3102; ie, (hashprev, coinbase, ntime=None, *, block_height)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's what the random asterixes are for! :) Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option is to make ntime non optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that block_height is provided here, suggest making coinbase optional since almost all uses just call create_coinbase(block_height). Probably doesn't matter much unless/until this goes upstream...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd have to implement a CScriptNum encoder in python.... sigh I'll do it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? create_coinbase (and serialize_script_num) already exists..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
de-serialize*. I want to grab it directly from the coinbase.
luke-jr
commented
Nov 19, 2018
It's never (de)serialed as non zero if not active.
Why wouldn't it take an existing CBlockIndex serialisation, and turn that bits into height, and nonce into bits?
src/chainparamsbase.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps indicate that defaults to true here?
jtimon
commented
Nov 22, 2018
I dislike that this modifies many unrelated tests (because the new option defaults to true) instead of just copying or creating a specific one to test this. That's bad for rebases.
Is it really necessary to default to true?
instagibbs
commented
Nov 22, 2018
via email
jtimon
commented
Nov 22, 2018
Or you can just change the default to false, no? Perhaps duplicate and modify some tests if that has value, but run all of them with this set to true.
What am I missing?
instagibbs
commented
Nov 22, 2018
via email
instagibbs
commented
Nov 26, 2018
Pushed an update that is able to extract the block height directly from the coinbase input, and places it in the header. This shrinks the test diff by quite a bit.
5d0d66c to
5a5941a
Compare
instagibbs
commented
Nov 26, 2018
squashed, passing tests, and ready for final review
The block height validation is gated by the startup option `con_blockheightinheader`, accesible in custom chains only using option `chain=<name>`. Only if set to true will this field be (de)serialized and evaluated in consensus logic. Otherwise the field is simply ignored, other than being stored in memory as the default value 0.
5a5941a to
2bfabb3
Compare
instagibbs
commented
Nov 27, 2018
rebased and added default value message in help of true(assuming custom chains since that will be default later)
stevenroose
commented
Nov 27, 2018
cool, tACK 2bfabb3!
2bfabb3 blockheaders include block height, nodes validate it (Gregory Sanders) 8f6bedf functional framework support for CScriptNum decode (Gregory Sanders) Pull request description: The feature is enabled by default in custom chains; cannot be activated in legacy chains. Tree-SHA512: d033b7dd0d853e5693efda584494cf58ed7ff43ce32d1f5d44e4ee52907b989e434c8dbb28a0f843da8b799548924d2499e8759a96ed5a7191b95f22b29c7f6e
...n third-party link action 2ccde2f qt: hyphenate usage of third-party modifier (Jarol Rodriguez) 8177578 qt: ensure seperator when adding third-party transaction links (Jarol Rodriguez) a70a980 qt: improve text for open third-party tx url action (Jarol Rodriguez) 9980f4a qt, refactor: simplify third-party tx url action through overload (Jarol Rodriguez) Pull request description: [#4092](bitcoin/bitcoin#4092) introduced the ability to open up a transaction in a block explorer. This improves the related code by simplifying the addition and connection of the action through an [overloaded](https://doc.qt.io/archives/qt-5.9/qmenu.html#addAction-5) `addAction` function and prepends action description text to the host, "Show in". The reason to add this text is to make it clear what the action does. It also creates a clearer mental correlation between a user doing the work to add the 3rd-party tx link and this new menu action popping up. This updates the setting text so that "third-party" is hyphenated. It should be hyphenated because it is being used as a modifier of both "URL" and "transaction URLs". Additionally, this fixes ElementsProject#431 by ensuring that the seperator will be added before creating action. Screenshots of visual changes: **Context menu actions** | master | pr | |--------------|--------| | <img width="248" alt="3pt-master" src="https://user-images.githubusercontent.com/23396902/134618354-00278ac6-5094-44ee-8ba7-fe648fdcb7d2.png"> | <img width="248" alt="3pt-pr" src="https://user-images.githubusercontent.com/23396902/134618364-ddb64269-e5ee-40af-a2a6-1922001b6f4e.png"> | **Setting text** (tooltip text containing usage of "third-party" is also properly hyphenated) | master | pr | |--------------|--------| |  |  | ACKs for top commit: stratospher: tested ACK 2ccde2f. promag: Code view ACK 2ccde2f. hebasto: ACK 2ccde2f Tree-SHA512: 8dfcd539a1d41c8abf3c8208d150d1480d4ef81a008de826299e8bad1dfa6e3c49dc76d041c5946fafcf0b033eebb9b9fbd3d49ba6d8af93dd388c488e92f143
Uh oh!
There was an error while loading. Please reload this page.
The feature is enabled by default in custom chains; cannot be activated in legacy chains.