GBT now appears to return before TBV is complete.
Move TestBlockValidity into a background thread #7167
pull jameshilliard wants to merge 5 commits into bitcoin:master from jameshilliard:TBVBackground changing 3 files +17 −4-
jameshilliard commented at 12:00 AM on December 4, 2015: contributor
-
Move TestBlockValidity into a background thread 4bbaf7945b
-
gmaxwell commented at 12:07 AM on December 4, 2015: contributor
This doesn't crash immediately from the use after free with the CValidationstate escaping its scope?
-
jameshilliard commented at 12:30 AM on December 4, 2015: contributor
Didn't crash for me....odd...tests passed on OSX(which is what I tested the change on), but not other OS's should it have failed?
-
Move CValidationState inside of validationThread 3c5b30482c
-
jameshilliard commented at 1:03 AM on December 4, 2015: contributor
Hmm, so it appeared to crash sometimes, hopefully this should fix it.
-
luke-jr commented at 1:34 AM on December 4, 2015: member
You still have a race on block.
-
jameshilliard commented at 1:36 AM on December 4, 2015: contributor
Yeah, I think I'm missing a lock, which lock does TBV need to be under?
-
morcos commented at 1:43 AM on December 4, 2015: member
So what will catch the runtime_error that is thrown if it fails? Previously the RPC code caught that and returned an JSON-RPC error, but the node kept running.
-
replace throw with assert f0d8bbe307
-
jameshilliard commented at 2:31 AM on December 4, 2015: contributor
@morcos I changed it to an assert so that it should shutdown instead
-
pstratem commented at 3:56 AM on December 4, 2015: contributor
Please gate this on an option off by default. On Dec 3, 2015 6:31 PM, "jameshilliard" notifications@github.com wrote:
@morcos https://github.com/morcos I changed it to an assert so that it should shutdown instead
— Reply to this email directly or view it on GitHub #7167 (comment).
-
jameshilliard commented at 4:03 AM on December 4, 2015: contributor
@pstratem If it's off by default a miner could keep mining on invalid templates without realizing anything is wrong.
-
pstratem commented at 4:08 AM on December 4, 2015: contributor
I'm asking for background vs inline to be selectable.
So you always call TestBlockValidity, the question just being when. On Dec 3, 2015 8:04 PM, "jameshilliard" notifications@github.com wrote:
@pstratem https://github.com/pstratem If it's off by default a miner could keep mining on invalid templates without realizing anything is wrong.
— Reply to this email directly or view it on GitHub #7167 (comment).
-
Move TestBlockValidity to getblocktemplate 46eb2bc8b8
-
jameshilliard commented at 6:36 AM on December 4, 2015: contributor
Well I moved TBV to be inside of getblocktemplate, the only tests that seem to be failing now are the ones that expect TBV to be inside of CNB.
-
disable tests that depend on removed std::runtime_error 48f4ceea46
-
jameshilliard commented at 1:09 AM on December 5, 2015: contributor
I'm thinking the easiest way to do this is to copy the block generated by CNB for the TBV thread and use a modified version of TBV that doesn't depend on the cs_main lock, is it possible to test the block well enough without the cs_main lock?
-
sipa commented at 3:00 AM on December 5, 2015: member
There is no way you can do TBV without cs_main, as it needs to access the UTXO set.
-
jameshilliard commented at 3:13 AM on December 5, 2015: contributor
@sipa does it do the check based on the current UTXO set only or is it possible for it to do the check based off a historical UTXO set? ie so the thread can be run in the background with a trylock waiting for GBT to release its lock?
-
pstratem commented at 3:23 AM on December 5, 2015: contributor
@jameshilliard the only way to make the test act truly in parallel would be to re-implement the utxo database as a proper mvcc database...
-
jameshilliard commented at 3:27 AM on December 5, 2015: contributor
@pstratem it doesn't need to be parallel so much as not block CNB/GBT
-
sipa commented at 3:35 AM on December 5, 2015: member
And not block with other calls to ProcessNewBlock.
-
jameshilliard commented at 3:39 AM on December 5, 2015: contributor
What types of failures are we worried about in regards to CNB? Would it be reasonably safe to skip checks that depend on the UTXO set?
-
sipa commented at 3:44 AM on December 5, 2015: member
If you skip checks based on the UTXO set, it cannot do anything. It can't do double-spend detection, script evaluation, fee/subsidy calculations, ...
-
sipa commented at 3:48 AM on December 5, 2015: member
The new CNB code is already intended to never ever produce an invalid block. TBV is a last-resort validation to be sure the code is working right. If you're going to skip checks, it is no longer useful; you could just as well not do any checks at all.
So, no, you need cs_main. And you need to make sure no ProcessBlock happened in between either.
-
jameshilliard commented at 3:50 AM on December 5, 2015: contributor
@sipa Yeah, I wasn't sure if we are trying to protect against mempool errors or more just formatting errors.
- laanwj added the label Mining on Feb 16, 2016
-
sipa commented at 6:44 AM on May 17, 2016: member
Closing, as this is not a viable strategy.
I think there are alternatives possible (like not running TBV for every block, or running TBV while still holding cs_main, before after returning from the RPC), but maybe it's just much less needed with the much faster 0.12 CNB?
- sipa closed this on May 17, 2016
- MarcoFalke locked this on Sep 8, 2021