forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
perf: using asynchronous worker to validate BLS signatures in quorum commitments #6692
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
Draft
knst
wants to merge
6
commits into
dashpay:develop
Choose a base branch
from
knst:perf-bls-parallel
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
44f7d93
refactor: split quorum commitment verification and its signatures
knst 9266e79
feat: first version of multi-thread bls validation
knst 50e0030
feat: use -par to set threads amount of Quorum Commitment validation
knst 0acc74d
feat: make BlsCheck to validate only signature without any extra work
knst adb1a1d
feat: validate async not only quorum members signature, but also quor…
knst 8b6414d
refactor: break circular dependencies llmq/blockprocessor <-> llmq/co…
knst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
|
||
#include <chain.h> | ||
#include <chainparams.h> | ||
#include <checkqueue.h> | ||
#include <consensus/params.h> | ||
#include <consensus/validation.h> | ||
#include <deploymentstatus.h> | ||
|
@@ -52,8 +53,18 @@ CQuorumBlockProcessor::CQuorumBlockProcessor(CChainState& chainstate, CDetermini | |
m_qsnapman(qsnapman) | ||
{ | ||
utils::InitQuorumsCache(mapHasMinedCommitmentCache); | ||
|
||
int qc_threads = gArgs.GetIntArg("-par", DEFAULT_SCRIPTCHECK_THREADS); | ||
if (qc_threads <= 0) { | ||
// -par=0 means autodetect (number of cores - 1 validator threads) | ||
// -par=-n means "leave n cores free" (number of cores - n - 1 validator threads) | ||
qc_threads += GetNumCores(); | ||
} | ||
m_bls_queue.StartWorkerThreads(qc_threads); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original script check logic has some additional limits
Shouldn't we have smth like that here too? |
||
} | ||
|
||
CQuorumBlockProcessor::~CQuorumBlockProcessor() { m_bls_queue.StopWorkerThreads(); } | ||
|
||
MessageProcessingResult CQuorumBlockProcessor::ProcessMessage(const CNode& peer, std::string_view msg_type, | ||
CDataStream& vRecv) | ||
{ | ||
|
@@ -194,8 +205,21 @@ bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, gsl::not_null<cons | |
} | ||
} | ||
|
||
if (fBLSChecks) { | ||
CCheckQueueControl<utils::BlsCheck> queue_control(&m_bls_queue); | ||
for (const auto& [_, qc] : qcs) { | ||
if (qc.IsNull()) continue; | ||
const auto* pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash); | ||
qc.VerifySignatureAsync(m_dmnman, m_qsnapman, pQuorumBaseBlockIndex, &queue_control); | ||
} | ||
|
||
if (!queue_control.Wait()) { | ||
// at least one check failed | ||
return false; | ||
} | ||
} | ||
for (const auto& [_, qc] : qcs) { | ||
if (!ProcessCommitment(pindex->nHeight, blockHash, qc, state, fJustCheck, fBLSChecks)) { | ||
if (!ProcessCommitment(pindex->nHeight, blockHash, qc, state, fJustCheck, false)) { | ||
LogPrintf("[ProcessBlock] failed h[%d] llmqType[%d] version[%d] quorumIndex[%d] quorumHash[%s]\n", pindex->nHeight, ToUnderlying(qc.llmqType), qc.nVersion, qc.quorumIndex, qc.quorumHash.ToString()); | ||
return false; | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Probably want a separate arg for this