Skip to content

Commit 5e8140d

Browse files
UdjinM6ogabrielides
authored andcommitted
fix: Redefine keepOldKeys and align quorum and dkgsession key storage depths (dashpay#5748)
## Issue being fixed or feature implemented When DKG data recovery is triggered by `qgetdata` the data we use to construct `qdata` reply is actually the one handled by `CDKGSessionManager`, not by `CQuorumManager`. Not storing the data long enough in `CDKGSessionManager` will result in this data simply not being recoverable. Also, the formula in `CDKGSessionManager::CleanupOldContributions()` is broken for quorums which use rotation (the depth is way too large). ## What was done? Fix both issues by redefining `keepOldKeys` and aligning key storage depths in both modules. ## How Has This Been Tested? ## Breaking Changes n/a ## Checklist: - [x] 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 - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
1 parent f8e88ad commit 5e8140d

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/llmq/dkgsessionmgr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ void CDKGSessionManager::CleanupOldContributions() const
466466

467467
for (const auto& params : Params().GetConsensus().llmqs) {
468468
// For how many blocks recent DKG info should be kept
469-
const int MAX_STORE_DEPTH = 2 * params.signingActiveQuorumCount * params.dkgInterval;
469+
const int MAX_CYCLES = params.useRotation ? params.keepOldKeys / params.signingActiveQuorumCount : params.keepOldKeys;
470+
const int MAX_STORE_DEPTH = MAX_CYCLES * params.dkgInterval;
470471

471472
LogPrint(BCLog::LLMQ, "CDKGSessionManager::%s -- looking for old entries for llmq type %d\n", __func__, ToUnderlying(params.type));
472473

src/llmq/params.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct LLMQParams {
104104
// For rotated quorums it should be equal to 2 x active quorums set.
105105
int keepOldConnections;
106106

107-
// The number of quorums for which we should keep keys. Usually it's equal to keepOldConnections.
107+
// The number of quorums for which we should keep keys. Usually it's equal to signingActiveQuorumCount * 2.
108108
// Unlike for other quorum types we want to keep data (secret key shares and vvec)
109109
// for Platform quorums for much longer because Platform can be restarted and
110110
// it must be able to re-sign stuff.
@@ -145,7 +145,7 @@ static constexpr std::array<LLMQParams, 14> available_llmqs = {
145145
.signingActiveQuorumCount = 2, // just a few ones to allow easier testing
146146

147147
.keepOldConnections = 3,
148-
.keepOldKeys = 3,
148+
.keepOldKeys = 4,
149149
.recoveryMembers = 3,
150150
},
151151

@@ -171,7 +171,7 @@ static constexpr std::array<LLMQParams, 14> available_llmqs = {
171171
.signingActiveQuorumCount = 2, // just a few ones to allow easier testing
172172

173173
.keepOldConnections = 3,
174-
.keepOldKeys = 3,
174+
.keepOldKeys = 4,
175175
.recoveryMembers = 3,
176176
},
177177

@@ -197,7 +197,7 @@ static constexpr std::array<LLMQParams, 14> available_llmqs = {
197197
.signingActiveQuorumCount = 2, // just a few ones to allow easier testing
198198

199199
.keepOldConnections = 3,
200-
.keepOldKeys = 3,
200+
.keepOldKeys = 4,
201201
.recoveryMembers = 3,
202202
},
203203

@@ -275,7 +275,7 @@ static constexpr std::array<LLMQParams, 14> available_llmqs = {
275275
.signingActiveQuorumCount = 4, // just a few ones to allow easier testing
276276

277277
.keepOldConnections = 5,
278-
.keepOldKeys = 5,
278+
.keepOldKeys = 8,
279279
.recoveryMembers = 6,
280280
},
281281

@@ -353,7 +353,7 @@ static constexpr std::array<LLMQParams, 14> available_llmqs = {
353353

354354
.signingActiveQuorumCount = 24, // a full day worth of LLMQs
355355
.keepOldConnections = 25,
356-
.keepOldKeys = 25,
356+
.keepOldKeys = 48,
357357
.recoveryMembers = 25,
358358
},
359359

@@ -406,7 +406,7 @@ static constexpr std::array<LLMQParams, 14> available_llmqs = {
406406
.signingActiveQuorumCount = 4, // two days worth of LLMQs
407407

408408
.keepOldConnections = 5,
409-
.keepOldKeys = 5,
409+
.keepOldKeys = 8,
410410
.recoveryMembers = 100,
411411
},
412412

@@ -434,7 +434,7 @@ static constexpr std::array<LLMQParams, 14> available_llmqs = {
434434
.signingActiveQuorumCount = 4, // four days worth of LLMQs
435435

436436
.keepOldConnections = 5,
437-
.keepOldKeys = 5,
437+
.keepOldKeys = 8,
438438
.recoveryMembers = 100,
439439
},
440440

0 commit comments

Comments
 (0)