Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/bls/bls_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,11 @@ std::future<bool> CBLSWorker::AsyncVerifyContributionShare(const CBLSId& forId,
const BLSVerificationVectorPtr& vvec,
const CBLSSecretKey& skContribution)
{
if (!forId.IsValid() || !VerifyVerificationVector(*vvec)) {
// vvec may be null when the verification vector for that member was never
// received (e.g. a non-member observer that did not get the member's QCONTRIB).
// Dereferencing it here is a remote-triggerable crash; treat a missing vvec as a
// failed verification, mirroring the null check in VerifyVerificationVectors().
if (!forId.IsValid() || vvec == nullptr || !VerifyVerificationVector(*vvec)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The full VerifyVerificationVector scan now runs synchronously before the job is submitted, so this method is no longer asynchronous for valid inputs. CDKGSession::VerifyJustification invokes it once per contribution while processing a received justification, causing the same verification vector to be revalidated repeatedly on the message-processing thread and allowing a large vector to block that thread. Keep the null/ID guard synchronous, but perform vector validation inside the worker task or rely on the validation already performed when the contribution was received. [performance]

Severity Level: Major ⚠️
- ⚠️ DKG justification handling rescans vectors synchronously.
- ⚠️ Multiple contributions multiply message-thread validation cost.
- ⚠️ Large vectors can delay subsequent DKG messages.

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/bls/bls_worker.cpp
**Line:** 762:762
**Comment:**
	*Performance: The full `VerifyVerificationVector` scan now runs synchronously before the job is submitted, so this method is no longer asynchronous for valid inputs. `CDKGSession::VerifyJustification` invokes it once per contribution while processing a received justification, causing the same verification vector to be revalidated repeatedly on the message-processing thread and allowing a large vector to block that thread. Keep the null/ID guard synchronous, but perform vector validation inside the worker task or rely on the validation already performed when the contribution was received.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

auto p = BuildFutureDoneCallback<bool>();
p.first(false);
return std::move(p.second);
Expand Down
20 changes: 20 additions & 0 deletions src/test/bls_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "bls/bls.h"
#include "bls/bls_batchverifier.h"
#include "bls/bls_worker.h"
#include "test/test_bitcoin.h"

#include <boost/test/unit_test.hpp>
Expand Down Expand Up @@ -154,4 +155,23 @@ BOOST_AUTO_TEST_CASE(batch_verifier_tests)
Verify(msgs);
}

BOOST_AUTO_TEST_CASE(bls_verify_contribution_share_null_vvec_tests)
{
CBLSWorker worker;
worker.Start();

const CBLSId id{uint256S("1")};
BOOST_REQUIRE(id.IsValid());

CBLSSecretKey sk;
sk.MakeNewKey();

const BLSVerificationVectorPtr nullVvec;
BOOST_REQUIRE(nullVvec == nullptr);

BOOST_CHECK(worker.AsyncVerifyContributionShare(id, nullVvec, sk).get() == false);

worker.Stop();
}

BOOST_AUTO_TEST_SUITE_END()
Loading