-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[CHIA-1562] move signature validation into run_block_generator()
#18812
Conversation
run_block_generator()
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
6f35bd0
to
811781f
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
811781f
to
0835eb0
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
0835eb0
to
c50c7c7
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
…final cost of the block we're creating. This lets us avoid validating the signature (to save time) and run in mempool mode
c50c7c7
to
592b5ea
Compare
run_block_generator()
run_block_generator()
the missing test coverage is not new |
592b5ea
to
69f7f68
Compare
…he inner SpendBundleConditions field
69f7f68
to
de73962
Compare
|
Pull Request Test Coverage Report for Build 11700675112Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
This PR is best reviewed one commit at a time. However, the second commit contains the bulk of the changes.
Purpose:
By combining executing CLVM, parsing (and some validation of) conditions with signature validation, we do more work under a single GIL release, improving the concurrency of block validation.
This is arguably also a simplification of the code, making it a bit more robust. Instead of optionally validating signatures in two places, we now do it unconditionally in one place. (although, there is technically still the option to not validate the signatures, but we currently only use that in tests and in block creation when all we want to do is to compute the final cost of the block).
This is also a step twoards demoting
get_name_puzzle_conditions()
into a test-only function. It's used in many places where the signature is either not available or not set correctly. This PR replaces all production uses of this function.Validating signatures in pre-validate
pre_validate_blocks_multiprocessing()
no longer accepts thevalidate_signatures=False
parameter. It's always validates signatures.Since signature validation now happens in the pre-validation step,
validate_block_body()
no longer validates it. Which also means it doesn't need theBLSCache
passed in to it.This also means
Blockchain.add_block()
no longer needs to take the BLS cache. It validates the block body, but the signature validation has already happened in pre-validate.Current Behavior:
The block signature validation is done in
validate_block_body()
orpre_validate_block()
. Invalidate_block_body()
we can optionally pass in the BLS cache, to save time on BLS pairings. We do this for new unfinished blocks, since they are likely to contain signatures that we've already validated in the mempool. The mempool adds pairings to the BLS cache.Both of these functions can optionally not validate signatures. Sometimes we rely on this in tests, where we don't bother producing correct signatures, or want to save time. The
validate_signature=False
option is used when we receive a newFullBlock
whose correspondingUnfinishedBlock
we've already validated. We save time by not validating the signatures again.New Behavior:
The block signature validation is done in
run_block_generator()
(andrun_block_generator2()
, post hard-fork). This happens along side of running the block generator and parsing the resulting conditions. An invalid signature generates a failure directly in this step.This is always run as part of pre-validation, in thread pools.
run_block_generator()
takes an optional BLS cache and signature to validate. We pass in the BLS cache only when validatingUnfinishedBlocks
. This is already done inmain
, inFullNode.add_unfinished_block()
. What's new is that the resultingSpendBundleConditions
now records that we've validated the conditions, and when adding the corresponding FullBlock, we just pick up theSpendBundleConditions
from the unfinished block cache.Testing Notes: