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

Move TestBlockValidity into a background thread #7167

Closed
wants to merge 5 commits into from

Conversation

jameshilliard
Copy link
Contributor

GBT now appears to return before TBV is complete.

@gmaxwell
Copy link
Contributor

gmaxwell commented Dec 4, 2015

This doesn't crash immediately from the use after free with the CValidationstate escaping its scope?

@jameshilliard
Copy link
Contributor Author

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?

@jameshilliard
Copy link
Contributor Author

Hmm, so it appeared to crash sometimes, hopefully this should fix it.

@luke-jr
Copy link
Member

luke-jr commented Dec 4, 2015

You still have a race on block.

@jameshilliard
Copy link
Contributor Author

Yeah, I think I'm missing a lock, which lock does TBV need to be under?

@morcos
Copy link
Member

morcos commented Dec 4, 2015

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.

@jameshilliard
Copy link
Contributor Author

@morcos I changed it to an assert so that it should shutdown instead

@pstratem
Copy link
Contributor

pstratem commented Dec 4, 2015

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
Copy link
Contributor Author

@pstratem If it's off by default a miner could keep mining on invalid templates without realizing anything is wrong.

@pstratem
Copy link
Contributor

pstratem commented Dec 4, 2015

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).

@jameshilliard
Copy link
Contributor Author

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.

@jameshilliard
Copy link
Contributor Author

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
Copy link
Member

sipa commented Dec 5, 2015 via email

@jameshilliard
Copy link
Contributor Author

@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
Copy link
Contributor

pstratem commented Dec 5, 2015

@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
Copy link
Contributor Author

@pstratem it doesn't need to be parallel so much as not block CNB/GBT

@sipa
Copy link
Member

sipa commented Dec 5, 2015 via email

@jameshilliard
Copy link
Contributor Author

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
Copy link
Member

sipa commented Dec 5, 2015 via email

@sipa
Copy link
Member

sipa commented Dec 5, 2015 via email

@jameshilliard
Copy link
Contributor Author

@sipa Yeah, I wasn't sure if we are trying to protect against mempool errors or more just formatting errors.

@laanwj laanwj added the Mining label Feb 16, 2016
@sipa
Copy link
Member

sipa commented May 17, 2016

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?

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants