forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathparams.h
514 lines (426 loc) · 17.3 KB
/
params.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
// Copyright (c) 2021-2025 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_LLMQ_PARAMS_H
#define BITCOIN_LLMQ_PARAMS_H
#include <array>
#include <cstdint>
#include <string_view>
namespace Consensus {
enum class LLMQType : uint8_t {
LLMQ_NONE = 0xff,
LLMQ_50_60 = 1, // 50 members, 30 (60%) threshold, one per hour
LLMQ_400_60 = 2, // 400 members, 240 (60%) threshold, one every 12 hours
LLMQ_400_85 = 3, // 400 members, 340 (85%) threshold, one every 24 hours
LLMQ_100_67 = 4, // 100 members, 67 (67%) threshold, one per hour
LLMQ_60_75 = 5, // 60 members, 45 (75%) threshold, one every 12 hours
LLMQ_25_67 = 6, // 25 members, 17 (67%) threshold, one per hour
// for testing only
LLMQ_TEST = 100, // 3 members, 2 (66%) threshold, one per hour. Params might differ when -llmqtestparams is used
// for devnets only
LLMQ_DEVNET = 101, // 12 members, 6 (50%) threshold, one per hour. Params might differ when -llmqdevnetparams is used
LLMQ_DEVNET_PLATFORM = 107, // 12 members, 8 (67%) threshold, one per hour.
// for testing activation of new quorums only
LLMQ_TEST_V17 = 102, // 3 members, 2 (66%) threshold, one per hour. Params might differ when -llmqtestparams is used
// for testing only
LLMQ_TEST_DIP0024 = 103, // 4 members, 3 (75%) threshold, one per hour.
LLMQ_TEST_INSTANTSEND = 104, // 3 members, 2 (66%) threshold, one per hour. Params might differ when -llmqtestinstantsendparams is used
LLMQ_TEST_PLATFORM = 106, // 3 members, 2 (66%) threshold, one per hour.
// for devnets only. rotated version (v2) for devnets
LLMQ_DEVNET_DIP0024 = 105 // 8 members, 4 (50%) threshold, one per hour. Params might differ when -llmqdevnetparams is used
};
// Configures a LLMQ and its DKG
// See https://github.com/dashpay/dips/blob/master/dip-0006.md for more details
struct LLMQParams {
LLMQType type;
// not consensus critical, only used in logging, RPC and UI
std::string_view name;
// Whether this is a DIP0024 quorum or not
bool useRotation;
// the size of the quorum, e.g. 50 or 400
int size;
// The minimum number of valid members after the DKG. If less members are determined valid, no commitment can be
// created. Should be higher then the threshold to allow some room for failing nodes, otherwise quorum might end up
// not being able to ever created a recovered signature if more nodes fail after the DKG
int minSize;
// The threshold required to recover a final signature. Should be at least 50%+1 of the quorum size. This value
// also controls the size of the public key verification vector and has a large influence on the performance of
// recovery. It also influences the amount of minimum messages that need to be exchanged for a single signing session.
// This value has the most influence on the security of the quorum. The number of total malicious masternodes
// required to negatively influence signing sessions highly correlates to the threshold percentage.
int threshold;
// The interval in number blocks for DKGs and the creation of LLMQs. If set to 24 for example, a DKG will start
// every 24 blocks, which is approximately once every hour.
int dkgInterval;
// The number of blocks per phase in a DKG session. There are 6 phases plus the mining phase that need to be processed
// per DKG. Set this value to a number of blocks so that each phase has enough time to propagate all required
// messages to all members before the next phase starts. If blocks are produced too fast, whole DKG sessions will
// fail.
int dkgPhaseBlocks;
// The starting block inside the DKG interval for when mining of commitments starts. The value is inclusive.
// Starting from this block, the inclusion of (possibly null) commitments is enforced until the first non-null
// commitment is mined. The chosen value should be at least 5 * dkgPhaseBlocks so that it starts right after the
// finalization phase.
int dkgMiningWindowStart;
// The ending block inside the DKG interval for when mining of commitments ends. The value is inclusive.
// Choose a value so that miners have enough time to receive the commitment and mine it. Also take into consideration
// that miners might omit real commitments and revert to always including null commitments. The mining window should
// be large enough so that other miners have a chance to produce a block containing a non-null commitment. The window
// should at the same time not be too large so that not too much space is wasted with null commitments in case a DKG
// session failed.
int dkgMiningWindowEnd;
// In the complaint phase, members will vote on other members being bad (missing valid contribution). If at least
// dkgBadVotesThreshold have voted for another member to be bad, it will considered to be bad by all other members
// as well. This serves as a protection against late-comers who send their contribution on the bring of
// phase-transition, which would otherwise result in inconsistent views of the valid members set
int dkgBadVotesThreshold;
// Number of quorums to consider "active" for signing sessions
int signingActiveQuorumCount;
// Used for intra-quorum communication. This is the number of quorums for which we should keep old connections.
// For non-rotated quorums it should be at least one more than the active quorums set.
// For rotated quorums it should be equal to 2 x active quorums set.
int keepOldConnections;
// The number of quorums for which we should keep keys. Usually it's equal to signingActiveQuorumCount * 2.
// Unlike for other quorum types we want to keep data (secret key shares and vvec)
// for Platform quorums for much longer because Platform can be restarted and
// it must be able to re-sign stuff.
int keepOldKeys;
// How many members should we try to send all sigShares to before we give up.
int recoveryMembers;
public:
[[nodiscard]] constexpr int max_cycles(int quorums_count) const
{
return useRotation ? quorums_count / signingActiveQuorumCount : quorums_count;
}
// For how many blocks recent DKG info should be kept
[[nodiscard]] constexpr int max_store_depth() const { return max_cycles(keepOldKeys) * dkgInterval; }
};
//static_assert(std::is_trivial_v<Consensus::LLMQParams>, "LLMQParams is not a trivial type");
static_assert(std::is_trivially_copyable_v<Consensus::LLMQParams>, "LLMQParams is not trivially copyable");
//static_assert(std::is_trivially_default_constructible_v<Consensus::LLMQParams>, "LLMQParams is not trivially default constructible");
static_assert(std::is_trivially_assignable_v<Consensus::LLMQParams, Consensus::LLMQParams>, "LLMQParams is not trivially assignable");
static constexpr std::array<LLMQParams, 14> available_llmqs = {
/**
* llmq_test
* This quorum is only used for testing
*
*/
LLMQParams{
.type = LLMQType::LLMQ_TEST,
.name = "llmq_test",
.useRotation = false,
.size = 3,
.minSize = 2,
.threshold = 2,
.dkgInterval = 24, // one DKG per hour
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 10, // dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 18,
.dkgBadVotesThreshold = 2,
.signingActiveQuorumCount = 2, // just a few ones to allow easier testing
.keepOldConnections = 3,
.keepOldKeys = 4,
.recoveryMembers = 3,
},
/**
* llmq_test_instantsend (same as llmq_test but used for InstantSend exclusively)
* This quorum is only used for testing
*
*/
LLMQParams{
.type = LLMQType::LLMQ_TEST_INSTANTSEND,
.name = "llmq_test_instantsend",
.useRotation = false,
.size = 3,
.minSize = 2,
.threshold = 2,
.dkgInterval = 24, // one DKG per hour
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 10, // dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 18,
.dkgBadVotesThreshold = 2,
.signingActiveQuorumCount = 2, // just a few ones to allow easier testing
.keepOldConnections = 3,
.keepOldKeys = 4,
.recoveryMembers = 3,
},
/**
* llmq_test (Dash Core 0.17) aka llmq_test_v17
* This quorum is only used for testing
*
*/
LLMQParams{
.type = LLMQType::LLMQ_TEST_V17,
.name = "llmq_test_v17",
.useRotation = false,
.size = 3,
.minSize = 2,
.threshold = 2,
.dkgInterval = 24, // one DKG per hour
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 10, // dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 18,
.dkgBadVotesThreshold = 2,
.signingActiveQuorumCount = 2, // just a few ones to allow easier testing
.keepOldConnections = 3,
.keepOldKeys = 4,
.recoveryMembers = 3,
},
/**
* llmq_test_dip0024
* This quorum is only used for testing
*
*/
LLMQParams{
.type = LLMQType::LLMQ_TEST_DIP0024,
.name = "llmq_test_dip0024",
.useRotation = true,
.size = 4,
.minSize = 4,
.threshold = 3,
.dkgInterval = 24, // DKG cycle
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 12, // signingActiveQuorumCount + dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 20,
.dkgBadVotesThreshold = 2,
.signingActiveQuorumCount = 2, // just a few ones to allow easier testing
.keepOldConnections = 4,
.keepOldKeys = 4,
.recoveryMembers = 3,
},
/**
* llmq_test_platform
* This quorum is only used for testing
*
*/
LLMQParams{
.type = LLMQType::LLMQ_TEST_PLATFORM,
.name = "llmq_test_platform",
.useRotation = false,
.size = 3,
.minSize = 2,
.threshold = 2,
.dkgInterval = 24, // DKG cycle
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 10, // signingActiveQuorumCount + dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 18,
.dkgBadVotesThreshold = 2,
.signingActiveQuorumCount = 2, // just a few ones to allow easier testing
.keepOldConnections = 4,
.keepOldKeys = 24 * 30 * 2, // 2 months of quorums
.recoveryMembers = 3,
},
/**
* llmq_devnet
* This quorum is only used for testing on devnets
*
*/
LLMQParams{
.type = LLMQType::LLMQ_DEVNET,
.name = "llmq_devnet",
.useRotation = false,
.size = 12,
.minSize = 7,
.threshold = 6,
.dkgInterval = 24, // one DKG per hour
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 10, // dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 18,
.dkgBadVotesThreshold = 7,
.signingActiveQuorumCount = 4, // just a few ones to allow easier testing
.keepOldConnections = 5,
.keepOldKeys = 8,
.recoveryMembers = 6,
},
/**
* llmq_devnet_dip0024
* This quorum is only used for testing on devnets
*
*/
LLMQParams{
.type = LLMQType::LLMQ_DEVNET_DIP0024,
.name = "llmq_devnet_dip0024",
.useRotation = true,
.size = 8,
.minSize = 6,
.threshold = 4,
.dkgInterval = 48, // DKG cycle
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 12, // signingActiveQuorumCount + dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 20,
.dkgBadVotesThreshold = 7,
.signingActiveQuorumCount = 2, // just a few ones to allow easier testing
.keepOldConnections = 4,
.keepOldKeys = 4,
.recoveryMembers = 4,
},
/**
* llmq_devnet_platform
* This quorum is only used for testing on devnets
*
*/
LLMQParams{
.type = LLMQType::LLMQ_DEVNET_PLATFORM,
.name = "llmq_devnet_platform",
.useRotation = false,
.size = 12,
.minSize = 9,
.threshold = 8,
.dkgInterval = 24, // one DKG per hour
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 10, // dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 18,
.dkgBadVotesThreshold = 7,
.signingActiveQuorumCount = 4, // just a few ones to allow easier testing
.keepOldConnections = 5,
.keepOldKeys = 24 * 30 * 2, // 2 months of quorums
.recoveryMembers = 6,
},
/**
* llmq_50_60
* This quorum is deployed on mainnet and requires
* 40 - 50 participants
*
*/
LLMQParams{
.type = LLMQType::LLMQ_50_60,
.name = "llmq_50_60",
.useRotation = false,
.size = 50,
.minSize = 40,
.threshold = 30,
.dkgInterval = 24, // one DKG per hour
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 10, // dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 18,
.dkgBadVotesThreshold = 40,
.signingActiveQuorumCount = 24, // a full day worth of LLMQs
.keepOldConnections = 25,
.keepOldKeys = 48,
.recoveryMembers = 25,
},
/**
* llmq_60_75
* This quorum is deployed on mainnet and requires
* 50 - 60 participants
*
*/
LLMQParams{
.type = LLMQType::LLMQ_60_75,
.name = "llmq_60_75",
.useRotation = true,
.size = 60,
.minSize = 50,
.threshold = 45,
.dkgInterval = 24 * 12, // DKG cycle every 12 hours
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 42, // signingActiveQuorumCount + dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 50,
.dkgBadVotesThreshold = 48,
.signingActiveQuorumCount = 32,
.keepOldConnections = 64,
.keepOldKeys = 64,
.recoveryMembers = 25,
},
/**
* llmq_400_60
* This quorum is deployed on mainnet and requires
* 300 - 400 participants
*
*/
LLMQParams{
.type = LLMQType::LLMQ_400_60,
.name = "llmq_400_60",
.useRotation = false,
.size = 400,
.minSize = 300,
.threshold = 240,
.dkgInterval = 24 * 12, // one DKG every 12 hours
.dkgPhaseBlocks = 4,
.dkgMiningWindowStart = 20, // dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 28,
.dkgBadVotesThreshold = 300,
.signingActiveQuorumCount = 4, // two days worth of LLMQs
.keepOldConnections = 5,
.keepOldKeys = 8,
.recoveryMembers = 100,
},
/**
* llmq_400_85
* This quorum is deployed on mainnet and requires
* 300 - 400 participants _with_ a supermajority
*
* Used for deployment and min-proto-version signalling
*/
LLMQParams{
.type = LLMQType::LLMQ_400_85,
.name = "llmq_400_85",
.useRotation = false,
.size = 400,
.minSize = 350,
.threshold = 340,
.dkgInterval = 24 * 24, // one DKG every 24 hours
.dkgPhaseBlocks = 4,
.dkgMiningWindowStart = 20, // dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 48, // give it a larger mining window to make sure it is mined
.dkgBadVotesThreshold = 300,
.signingActiveQuorumCount = 4, // four days worth of LLMQs
.keepOldConnections = 5,
.keepOldKeys = 8,
.recoveryMembers = 100,
},
/**
* llmq_100_67
* This quorum is deployed on mainnet and requires
* 80 - 100 participants
*
* Used by Dash Platform
*/
LLMQParams{
.type = LLMQType::LLMQ_100_67,
.name = "llmq_100_67",
.useRotation = false,
.size = 100,
.minSize = 80,
.threshold = 67,
.dkgInterval = 24, // one DKG per hour
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 10, // dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 18,
.dkgBadVotesThreshold = 80,
.signingActiveQuorumCount = 24, // a full day worth of LLMQs
.keepOldConnections = 25,
.keepOldKeys = 24 * 30 * 2, // 2 months of quorums
.recoveryMembers = 50,
},
/**
* llmq_25_67
* This quorum is deployed on Testnet and requires
* 25 participants
*
* Used by Dash Platform
*/
LLMQParams{
.type = LLMQType::LLMQ_25_67,
.name = "llmq_25_67",
.useRotation = false,
.size = 25,
.minSize = 22,
.threshold = 17,
.dkgInterval = 24, // one DKG per hour
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 10, // dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 18,
.dkgBadVotesThreshold = 22,
.signingActiveQuorumCount = 24, // a full day worth of LLMQs
.keepOldConnections = 25,
.keepOldKeys = 24 * 30 * 2, // 2 months of quorums
.recoveryMembers = 12,
},
}; // available_llmqs
} // namespace Consensus
// This must be outside of all namespaces. We must also duplicate the forward declaration of is_serializable_enum to
// avoid inclusion of serialize.h here.
template<typename T> struct is_serializable_enum;
template<> struct is_serializable_enum<Consensus::LLMQType> : std::true_type {};
#endif // BITCOIN_LLMQ_PARAMS_H