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

fix: A set of qdata/qwatch related fixes #5745

Merged
merged 7 commits into from
Jan 10, 2024

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Nov 29, 2023

Issue being fixed or feature implemented

Fix/tidy up a few qdata/qwatch related parts, improve performance for regular non-watching nodes

based on #5744 atm

What was done?

pls see individual commits

How Has This Been Tested?

run tests

Breaking Changes

n/a

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

…oring qwatch on our side

Checking for `qwatch` doesn't make sense in these conditions because it's set on the node we are watching when it receives `QWATCH` message from us, it's always `false` on the watching node itself.
Copy link
Collaborator

@ogabrielides ogabrielides left a comment

Choose a reason for hiding this comment

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

Looks good in general, some nit and a question for you

src/rpc/quorums.cpp Outdated Show resolved Hide resolved
@@ -730,6 +730,9 @@ static UniValue quorum_getdata(const JSONRPCRequest& request, const LLMQContext&
} else {
throw JSONRPCError(RPC_INVALID_PARAMETER, "proTxHash missing");
}
} else if (!request.params[4].isNull()) {
// Require no proTxHash otherwise
throw JSONRPCError(RPC_INVALID_PARAMETER, "Should not specify proTxHash");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please explain why?

Copy link
Author

Choose a reason for hiding this comment

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

Because in this case we ask for a quorum wide data only (QUORUM_VERIFICATION_VECTOR) and not for a data about one specific MN, so proTxHash is not used in any way in this case and should not be provided. If it still was provided then maybe user doesn't quite understand what he is doing exactly or maybe he made a typo in dataMask.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

I think this would be a breaking change, no?

ogabrielides
ogabrielides previously approved these changes Dec 16, 2023
Copy link
Collaborator

@ogabrielides ogabrielides left a comment

Choose a reason for hiding this comment

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

utack

@@ -429,13 +440,15 @@ bool CDKGSessionManager::GetEncryptedContributions(Consensus::LLMQType llmqType,
}
}
if (nRequestedMemberIdx == std::numeric_limits<size_t>::max()) {
LogPrintf("CDKGSessionManager::%s -- not a member, nProTxHash=%s\n", __func__, nProTxHash.ToString());
Copy link
Member

Choose a reason for hiding this comment

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

why not guard this behind a category?

return false;
}

for (const auto i : irange::range(members.size())) {
if (validMembers[i]) {
CBLSIESMultiRecipientObjects<CBLSSecretKey> encryptedContributions;
if (!db->Read(std::make_tuple(DB_ENC_CONTRIB, llmqType, pQuorumBaseBlockIndex->GetBlockHash(), members[i]->proTxHash), encryptedContributions)) {
LogPrintf("CDKGSessionManager::%s -- can't read from db, nProTxHash=%s\n", __func__, nProTxHash.ToString());
Copy link
Member

Choose a reason for hiding this comment

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

same

@@ -275,7 +275,7 @@ class CQuorumManager
size_t GetQuorumRecoveryStartOffset(const CQuorumCPtr pQuorum, const CBlockIndex* pIndex) const;

void StartCachePopulatorThread(const CQuorumCPtr pQuorum) const;
void StartQuorumDataRecoveryThread(const CQuorumCPtr pQuorum, const CBlockIndex* pIndex, uint16_t nDataMask) const;
void StartQuorumDataRecoveryThread(const CQuorumCPtr pQuorum, const CBlockIndex* pIndex, const uint16_t nDataMaskIn) const;
Copy link
Member

Choose a reason for hiding this comment

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

const in a declaration doesn't do anything; generally this should only be present in the definition.

Suggested change
void StartQuorumDataRecoveryThread(const CQuorumCPtr pQuorum, const CBlockIndex* pIndex, const uint16_t nDataMaskIn) const;
void StartQuorumDataRecoveryThread(const CQuorumCPtr pQuorum, const CBlockIndex* pIndex, uint16_t nDataMaskIn) const;

@@ -730,6 +730,9 @@ static UniValue quorum_getdata(const JSONRPCRequest& request, const LLMQContext&
} else {
throw JSONRPCError(RPC_INVALID_PARAMETER, "proTxHash missing");
}
} else if (!request.params[4].isNull()) {
// Require no proTxHash otherwise
throw JSONRPCError(RPC_INVALID_PARAMETER, "Should not specify proTxHash");
Copy link
Member

Choose a reason for hiding this comment

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

I think this would be a breaking change, no?

@UdjinM6
Copy link
Author

UdjinM6 commented Dec 17, 2023

dropped c5a66ff and 16f5e00, adjusted d0a4894

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK for squash merge; LGTM if you think c5a66ff is valuable, let's open a new PR targeted for v21 with release notes?

Approval contingent on CI

@UdjinM6
Copy link
Author

UdjinM6 commented Dec 17, 2023

utACK for squash merge; LGTM if you think c5a66ff is valuable, let's open a new PR targeted for v21 with release notes?

#5772

Approval contingent on CI

Gitlab had some unrelated issues https://gitlab.com/dashpay/dash/-/jobs/5770189961, restarted it

Copy link
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

Let's refactor IsWatchQuorumsEnabled to validate fMasternodeMode (see a comment for details).

Other comments are non-actionable, just marks for conflicts resolving.

@@ -189,6 +189,11 @@ void CDKGSessionManager::ProcessMessage(CNode& pfrom, const CQuorumManager& quor
}

if (msg_type == NetMsgType::QWATCH) {
if (!fMasternodeMode) {
// non-masternodes should never receive this
m_peerman->Misbehaving(pfrom.GetId(), 10);
Copy link
Collaborator

Choose a reason for hiding this comment

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

just a notice: refactored in #5782 - one of these 2 PR should be changed after other is merged

@@ -198,6 +198,12 @@ void CDKGSessionManager::ProcessMessage(CNode& pfrom, const CQuorumManager& quor
return;
}

if ((!fMasternodeMode && !utils::IsWatchQuorumsEnabled())) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

potentially conflict with #5790 - one of PR to edit; depends which one get merge first.


for (const auto& params : Params().GetConsensus().llmqs) {
CheckQuorumConnections(params, pindexNew);
}

{
if (fMasternodeMode || utils::IsWatchQuorumsEnabled()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see many check "fMasternodeMode || utils::IsWatchQuorumsEnabled()" - maybe move a boolean flag fMasternodeMode inside IsWatchQuorumsEnabled such as:

bool IsWatchQuorumsEnabled()
{       
    static bool fIsWatchQuroumsEnabled = gArgs.GetBoolArg("-watchquorums", DEFAULT_WATCH_QUORUMS);
    return fIsWatchQuroumsEnabled ||fMasternodeMode ;
}

Copy link
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

Let's refactor IsWatchQuorumsEnabled to validate fMasternodeMode (see a comment for details).

can be actually done after by new PR; not that important changes. utACK!

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

re-approval to trigger conflicts check

@PastaPastaPasta PastaPastaPasta merged commit c25d9ae into dashpay:develop Jan 10, 2024
8 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants