Skip to content

Commit ccdb0dc

Browse files
Merge #7098: refactor: consolidate Dash-specific utils between C++23 polyfills (util/std23.h) and helpers (util/helpers.h)
1c8260c refactor: add `util::to_string(bool)` for convenience (Kittywhiskers Van Gogh) dec2766 refactor: merge `util/ranges.h` and `util/pointer.h` to `util/helpers.h` (Kittywhiskers Van Gogh) f57edb5 refactor: use `std23::ranges::fold_left` in Dash-specific code (Kittywhiskers Van Gogh) 4c30be5 util: add polyfill for `std::ranges::fold_left` (Kittywhiskers Van Gogh) 5dc17fc refactor: use `std23::ranges::contains` in Dash-specific code (Kittywhiskers Van Gogh) 43e64ed util: add polyfill for `std::ranges::contains` (Kittywhiskers Van Gogh) 79f0711 refactor: replace `irange::range` with thin `std::views::iota` wrapper (Kittywhiskers Van Gogh) 58a9a3d refactor: switch from `irange(min, max)` to `std::views::iota(min, max)` (Kittywhiskers Van Gogh) 6bee408 refactor: distinguish between custom helpers and polyfills (Kittywhiskers Van Gogh) f1d5d30 refactor: move `enumerate` to C++23 polyfill, mirror namespace structure (Kittywhiskers Van Gogh) aa12106 refactor: rename `ToUnderlying()` to match C++23 convention (Kittywhiskers Van Gogh) 2ca0fd7 fix: enum bound check in GetSimulatedErrorRate (Kittywhiskers Van Gogh) Pull request description: ## Motivation The upgrade to C++20 ([dash#6380](#6380)) allowed us to drop most of our polyfills meant as bridge from C++17, though we still have utils beyond the ones inherited from upstream that have accumulated over time, most of them, seeking to bridge C++23 features while others are entirely custom or serve as convenience functions or thin wrappers. Some of them include: * [dash#4622](#4622) for `util/ranges.h` (mostly now an alias to [`std::ranges`](https://en.cppreference.com/w/cpp/ranges.html) after C++20 migration except for `find_if_opt`, which is custom) * [dash#4788](#4788) for `util/irange.h` (equivalent to [`std::views::iota`](https://en.cppreference.com/w/cpp/ranges/iota_view.html), introduced in C++20) * [dash#5059](#5059) for `util/enumerate.h` (equivalent to [`std::views::enumerate`](http://en.cppreference.com/w/cpp/ranges/enumerate_view.html), introduced in C++23) * [dash#5210](#5210) for `util/underlying.h` (equivalent to [`std::to_underlying`](https://en.cppreference.com/w/cpp/utility/to_underlying.html), introduced in C++23) * 0a4e726 for `util/pointer.h` (custom `std::shared_ptr` helper) This pull requests compacts all of those helpers into two files: * `util/helpers.h` (custom helpers, replacing `util/irange.h`, `util/pointer.h`, `util/ranges.h`) * `util/std23.h` (polyfill for C++23, replacing `util/enumerate.h` and `util/underlying.h`) And additionally, introduces additional capabilities utilised in Dash-specific code: * `std23::ranges::contains` (equivalent to [`std::ranges::contains`](https://en.cppreference.com/w/cpp/algorithm/ranges/contains.html)) * `std23::ranges::fold_left` (equivalent to [`std::ranges::fold_left`](https://en.cppreference.com/w/cpp/algorithm/ranges/fold_left.html)) * `util::to_string(bool)` (equivalent to `value ? "true" : "false"`) ## Additional Information * `ToUnderlying()` needed to be renamed to `to_underlying()` to match with the standard library naming so we can discontinue the polyfill easily when we migrate to C++23 by just going `s/std23/std/g`. * While `iranges::range` is equivalent to `std::views::iota`, the latter requires both min and max to be of the same type but literal `0` has a type incompatible with `size_t`, requiring `size_t{0}` to compile. As propagation of these changes for each instance is bothersome, `util::irange()` exists as a thin wrapper that wraps the literal around the type for `max` ## Breaking Changes None expected. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK 1c8260c; seems reasonable UdjinM6: utACK 1c8260c Tree-SHA512: 82f4b74f304d8680ddb03a923843905a470b374c034284dbe6a013d19e67a769743965f710c5267751742488961907d346ce721d01029cffa543178fd560dcc1
2 parents a35134a + 1c8260c commit ccdb0dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+660
-654
lines changed

src/Makefile.am

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,29 +394,26 @@ BITCOIN_CORE_H = \
394394
util/bytevectorhash.h \
395395
util/check.h \
396396
util/edge.h \
397-
util/enumerate.h \
398397
util/epochguard.h \
399398
util/error.h \
400399
util/fastrange.h \
401400
util/fees.h \
402401
util/golombrice.h \
403402
util/hasher.h \
404403
util/hash_type.h \
405-
util/irange.h \
404+
util/helpers.h \
406405
util/asmap.h \
407406
util/getuniquepath.h \
408407
util/macros.h \
409408
util/message.h \
410409
util/moneystr.h \
411410
util/overflow.h \
412411
util/overloaded.h \
413-
util/pointer.h \
414-
util/ranges.h \
415412
util/readwritefile.h \
416413
util/result.h \
417-
util/underlying.h \
418414
util/serfloat.h \
419415
util/settings.h \
416+
util/std23.h \
420417
util/ranges_set.h \
421418
util/sock.h \
422419
util/string.h \

src/active/dkgsession.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <llmq/options.h>
1313
#include <llmq/utils.h>
1414
#include <masternode/meta.h>
15+
#include <util/helpers.h>
1516

1617
#include <chain.h>
1718
#include <deploymentstatus.h>
@@ -81,7 +82,7 @@ void ActiveDKGSession::SendContributions(CDKGPendingMessages& pendingMessages, P
8182
qc.contributions = std::make_shared<CBLSIESMultiRecipientObjects<CBLSSecretKey>>();
8283
qc.contributions->InitEncrypt(members.size());
8384

84-
for (const auto i : irange::range(members.size())) {
85+
for (const auto i : util::irange(members.size())) {
8586
const auto& m = members[i];
8687
CBLSSecretKey skContrib = m_sk_contributions[i];
8788

@@ -150,7 +151,7 @@ void ActiveDKGSession::VerifyPendingContributions()
150151
return;
151152
}
152153

153-
for (const auto i : irange::range(memberIndexes.size())) {
154+
for (const auto i : util::irange(memberIndexes.size())) {
154155
if (!result[i]) {
155156
const auto& m = members[memberIndexes[i]];
156157
logger.Batch("invalid contribution from %s. will complain later", m->dmn->proTxHash.ToString());
@@ -267,7 +268,7 @@ void ActiveDKGSession::SendComplaint(CDKGPendingMessages& pendingMessages, PeerM
267268

268269
int badCount = 0;
269270
int complaintCount = 0;
270-
for (const auto i : irange::range(members.size())) {
271+
for (const auto i : util::irange(members.size())) {
271272
const auto& m = members[i];
272273
if (m->bad || m->badConnection) {
273274
qc.badMembers[i] = true;
@@ -352,7 +353,7 @@ void ActiveDKGSession::SendJustification(CDKGPendingMessages& pendingMessages, P
352353
qj.proTxHash = myProTxHash;
353354
qj.contributions.reserve(forMembers.size());
354355

355-
for (const uint32_t i : irange::range(members.size())) {
356+
for (const uint32_t i : util::irange(members.size())) {
356357
const auto& m = members[i];
357358
if (forMembers.count(m->dmn->proTxHash) == 0) {
358359
continue;
@@ -444,7 +445,7 @@ void ActiveDKGSession::SendCommitment(CDKGPendingMessages& pendingMessages, Peer
444445
qc.quorumHash = m_quorum_base_block_index->GetBlockHash();
445446
qc.proTxHash = myProTxHash;
446447

447-
for (const auto i : irange::range(members.size())) {
448+
for (const auto i : util::irange(members.size())) {
448449
const auto& m = members[i];
449450
if (!m->bad) {
450451
qc.validMembers[i] = true;

src/active/dkgsessionhandler.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ void ActiveDKGSessionHandler::UpdatedBlockTip(const CBlockIndex* pindexNew)
6161
bool fNewPhase = (quorumStageInt % params.dkgPhaseBlocks) == 0;
6262
int phaseInt = quorumStageInt / params.dkgPhaseBlocks + 1;
6363
QuorumPhase oldPhase = phase;
64-
if (fNewPhase && phaseInt >= ToUnderlying(QuorumPhase::Initialized) && phaseInt <= ToUnderlying(QuorumPhase::Idle)) {
64+
if (fNewPhase && phaseInt >= std23::to_underlying(QuorumPhase::Initialized) && phaseInt <= std23::to_underlying(QuorumPhase::Idle)) {
6565
phase = static_cast<QuorumPhase>(phaseInt);
6666
}
6767

6868
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] currentHeight=%d, pQuorumBaseBlockIndex->nHeight=%d, oldPhase=%d, newPhase=%d\n", __func__,
69-
params.name, quorumIndex, currentHeight, pQuorumBaseBlockIndex->nHeight, ToUnderlying(oldPhase), ToUnderlying(phase));
69+
params.name, quorumIndex, currentHeight, pQuorumBaseBlockIndex->nHeight, std23::to_underlying(oldPhase), std23::to_underlying(phase));
7070
}
7171

7272
void ActiveDKGSessionHandler::StartThread(CConnman& connman, PeerManager& peerman)
@@ -75,7 +75,7 @@ void ActiveDKGSessionHandler::StartThread(CConnman& connman, PeerManager& peerma
7575
throw std::runtime_error("Tried to start an already started ActiveDKGSessionHandler thread.");
7676
}
7777

78-
m_thread_name = strprintf("llmq-%d-%d", ToUnderlying(params.type), quorumIndex);
78+
m_thread_name = strprintf("llmq-%d-%d", std23::to_underlying(params.type), quorumIndex);
7979
phaseHandlerThread = std::thread(&util::TraceThread, m_thread_name.c_str(),
8080
[this, &connman, &peerman] { PhaseHandlerThread(connman, peerman); });
8181
}
@@ -120,7 +120,7 @@ class AbortPhaseException : public std::exception {
120120
void ActiveDKGSessionHandler::WaitForNextPhase(std::optional<QuorumPhase> curPhase, QuorumPhase nextPhase,
121121
const uint256& expectedQuorumHash, const WhileWaitFunc& shouldNotWait) const
122122
{
123-
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - starting, curPhase=%d, nextPhase=%d\n", __func__, params.name, quorumIndex, curPhase.has_value() ? ToUnderlying(*curPhase) : -1, ToUnderlying(nextPhase));
123+
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - starting, curPhase=%d, nextPhase=%d\n", __func__, params.name, quorumIndex, curPhase.has_value() ? std23::to_underlying(*curPhase) : -1, std23::to_underlying(nextPhase));
124124

125125
while (true) {
126126
if (stopRequested) {
@@ -136,15 +136,15 @@ void ActiveDKGSessionHandler::WaitForNextPhase(std::optional<QuorumPhase> curPha
136136
break;
137137
}
138138
if (curPhase.has_value() && _phase != curPhase) {
139-
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - aborting due unexpected phase change, _phase=%d, curPhase=%d\n", __func__, params.name, quorumIndex, ToUnderlying(_phase), curPhase.has_value() ? ToUnderlying(*curPhase) : -1);
139+
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - aborting due unexpected phase change, _phase=%d, curPhase=%d\n", __func__, params.name, quorumIndex, std23::to_underlying(_phase), curPhase.has_value() ? std23::to_underlying(*curPhase) : -1);
140140
throw AbortPhaseException();
141141
}
142142
if (!shouldNotWait()) {
143143
UninterruptibleSleep(std::chrono::milliseconds{100});
144144
}
145145
}
146146

147-
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - done, curPhase=%d, nextPhase=%d\n", __func__, params.name, quorumIndex, curPhase.has_value() ? ToUnderlying(*curPhase) : -1, ToUnderlying(nextPhase));
147+
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - done, curPhase=%d, nextPhase=%d\n", __func__, params.name, quorumIndex, curPhase.has_value() ? std23::to_underlying(*curPhase) : -1, std23::to_underlying(nextPhase));
148148

149149
if (nextPhase == QuorumPhase::Initialized) {
150150
m_dkgdbgman.ResetLocalSessionStatus(params.type, quorumIndex);
@@ -206,7 +206,7 @@ void ActiveDKGSessionHandler::SleepBeforePhase(QuorumPhase curPhase, const uint2
206206
int heightTmp{currentHeight.load()};
207207
int heightStart{heightTmp};
208208

209-
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - starting sleep for %d ms, curPhase=%d\n", __func__, params.name, quorumIndex, sleepTime, ToUnderlying(curPhase));
209+
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - starting sleep for %d ms, curPhase=%d\n", __func__, params.name, quorumIndex, sleepTime, std23::to_underlying(curPhase));
210210

211211
while (TicksSinceEpoch<std::chrono::milliseconds>(SystemClock::now()) < endTime) {
212212
if (stopRequested) {
@@ -233,20 +233,20 @@ void ActiveDKGSessionHandler::SleepBeforePhase(QuorumPhase curPhase, const uint2
233233
}
234234
}
235235

236-
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - done, curPhase=%d\n", __func__, params.name, quorumIndex, ToUnderlying(curPhase));
236+
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - done, curPhase=%d\n", __func__, params.name, quorumIndex, std23::to_underlying(curPhase));
237237
}
238238

239239
void ActiveDKGSessionHandler::HandlePhase(QuorumPhase curPhase, QuorumPhase nextPhase,
240240
const uint256& expectedQuorumHash, double randomSleepFactor,
241241
const StartPhaseFunc& startPhaseFunc, const WhileWaitFunc& runWhileWaiting)
242242
{
243-
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - starting, curPhase=%d, nextPhase=%d\n", __func__, params.name, quorumIndex, ToUnderlying(curPhase), ToUnderlying(nextPhase));
243+
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - starting, curPhase=%d, nextPhase=%d\n", __func__, params.name, quorumIndex, std23::to_underlying(curPhase), std23::to_underlying(nextPhase));
244244

245245
SleepBeforePhase(curPhase, expectedQuorumHash, randomSleepFactor, runWhileWaiting);
246246
startPhaseFunc();
247247
WaitForNextPhase(curPhase, nextPhase, expectedQuorumHash, runWhileWaiting);
248248

249-
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - done, curPhase=%d, nextPhase=%d\n", __func__, params.name, quorumIndex, ToUnderlying(curPhase), ToUnderlying(nextPhase));
249+
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - done, curPhase=%d, nextPhase=%d\n", __func__, params.name, quorumIndex, std23::to_underlying(curPhase), std23::to_underlying(nextPhase));
250250
}
251251

252252
// returns a set of NodeIds which sent invalid messages

src/active/quorums.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <llmq/quorums.h>
1515
#include <llmq/utils.h>
1616
#include <masternode/sync.h>
17+
#include <util/helpers.h>
1718

1819
#include <chain.h>
1920
#include <chainparams.h>
@@ -24,6 +25,8 @@
2425

2526
#include <cxxtimer.hpp>
2627

28+
#include <ranges>
29+
2730
namespace llmq {
2831
QuorumParticipant::QuorumParticipant(CBLSWorker& bls_worker, CConnman& connman, CDeterministicMNManager& dmnman,
2932
QuorumObserverParent& qman, CQuorumSnapshotManager& qsnapman,
@@ -47,13 +50,15 @@ void QuorumParticipant::CheckQuorumConnections(const Consensus::LLMQParams& llmq
4750

4851
const uint256 proTxHash = m_mn_activeman.GetProTxHash();
4952
const bool watchOtherISQuorums = llmqParams.type == Params().GetConsensus().llmqTypeDIP0024InstantSend &&
50-
ranges::any_of(lastQuorums, [&proTxHash](const auto& old_quorum){ return old_quorum->IsMember(proTxHash); });
53+
std::ranges::any_of(lastQuorums, [&proTxHash](const auto& old_quorum) {
54+
return old_quorum->IsMember(proTxHash);
55+
});
5156

5257
for (const auto& quorum : lastQuorums) {
5358
if (utils::EnsureQuorumConnections(llmqParams, m_connman, m_sporkman, {m_dmnman, m_qsnapman, m_chainman, quorum->m_quorum_base_block_index},
5459
m_dmnman.GetListAtChainTip(), proTxHash, /*is_masternode=*/true, m_quorums_watch)) {
5560
if (deletableQuorums.erase(quorum->qc->quorumHash) > 0) {
56-
LogPrint(BCLog::LLMQ, "QuorumParticipant::%s -- llmqType[%d] h[%d] keeping mn quorum connections for quorum: [%d:%s]\n", __func__, ToUnderlying(llmqParams.type), pindexNew->nHeight, quorum->m_quorum_base_block_index->nHeight, quorum->m_quorum_base_block_index->GetBlockHash().ToString());
61+
LogPrint(BCLog::LLMQ, "QuorumParticipant::%s -- llmqType[%d] h[%d] keeping mn quorum connections for quorum: [%d:%s]\n", __func__, std23::to_underlying(llmqParams.type), pindexNew->nHeight, quorum->m_quorum_base_block_index->nHeight, quorum->m_quorum_base_block_index->GetBlockHash().ToString());
5762
}
5863
} else if (watchOtherISQuorums && !quorum->IsMember(proTxHash)) {
5964
Uint256HashSet connections;
@@ -63,12 +68,12 @@ void QuorumParticipant::CheckQuorumConnections(const Consensus::LLMQParams& llmq
6368
}
6469
if (!connections.empty()) {
6570
if (!m_connman.HasMasternodeQuorumNodes(llmqParams.type, quorum->m_quorum_base_block_index->GetBlockHash())) {
66-
LogPrint(BCLog::LLMQ, "QuorumParticipant::%s -- llmqType[%d] h[%d] adding mn inter-quorum connections for quorum: [%d:%s]\n", __func__, ToUnderlying(llmqParams.type), pindexNew->nHeight, quorum->m_quorum_base_block_index->nHeight, quorum->m_quorum_base_block_index->GetBlockHash().ToString());
71+
LogPrint(BCLog::LLMQ, "QuorumParticipant::%s -- llmqType[%d] h[%d] adding mn inter-quorum connections for quorum: [%d:%s]\n", __func__, std23::to_underlying(llmqParams.type), pindexNew->nHeight, quorum->m_quorum_base_block_index->nHeight, quorum->m_quorum_base_block_index->GetBlockHash().ToString());
6772
m_connman.SetMasternodeQuorumNodes(llmqParams.type, quorum->m_quorum_base_block_index->GetBlockHash(), connections);
6873
m_connman.SetMasternodeQuorumRelayMembers(llmqParams.type, quorum->m_quorum_base_block_index->GetBlockHash(), connections);
6974
}
7075
if (deletableQuorums.erase(quorum->qc->quorumHash) > 0) {
71-
LogPrint(BCLog::LLMQ, "QuorumParticipant::%s -- llmqType[%d] h[%d] keeping mn inter-quorum connections for quorum: [%d:%s]\n", __func__, ToUnderlying(llmqParams.type), pindexNew->nHeight, quorum->m_quorum_base_block_index->nHeight, quorum->m_quorum_base_block_index->GetBlockHash().ToString());
76+
LogPrint(BCLog::LLMQ, "QuorumParticipant::%s -- llmqType[%d] h[%d] keeping mn inter-quorum connections for quorum: [%d:%s]\n", __func__, std23::to_underlying(llmqParams.type), pindexNew->nHeight, quorum->m_quorum_base_block_index->nHeight, quorum->m_quorum_base_block_index->GetBlockHash().ToString());
7277
}
7378
}
7479
}
@@ -96,7 +101,7 @@ size_t QuorumParticipant::GetQuorumRecoveryStartOffset(const CQuorum& quorum, gs
96101
size_t nIndex{0};
97102
{
98103
auto my_protx_hash = m_mn_activeman.GetProTxHash();
99-
for (const auto i : irange::range(vecProTxHashes.size())) {
104+
for (const auto i : util::irange(vecProTxHashes.size())) {
100105
// cppcheck-suppress useStlAlgorithm
101106
if (my_protx_hash == vecProTxHashes[i]) {
102107
nIndex = i;
@@ -156,7 +161,7 @@ MessageProcessingResult QuorumParticipant::ProcessContribQDATA(CNode& pfrom, CDa
156161

157162
std::vector<CBLSSecretKey> vecSecretKeys;
158163
vecSecretKeys.resize(vecEncrypted.size());
159-
for (const auto i : irange::range(vecEncrypted.size())) {
164+
for (const auto i : util::irange(vecEncrypted.size())) {
160165
if (!m_mn_activeman.Decrypt(vecEncrypted[i], memberIdx, vecSecretKeys[i], PROTOCOL_VERSION)) {
161166
return MisbehavingError{10, "failed to decrypt"};
162167
}
@@ -209,7 +214,9 @@ void QuorumParticipant::TriggerQuorumDataRecoveryThreads(gsl::not_null<const CBl
209214

210215
for (const auto& params : Params().GetConsensus().llmqs) {
211216
auto vecQuorums = m_qman.ScanQuorums(params.type, block_index, params.keepOldConnections);
212-
const bool fWeAreQuorumTypeMember = ranges::any_of(vecQuorums, [&proTxHash](const auto& pQuorum) { return pQuorum->IsValidMember(proTxHash); });
217+
const bool fWeAreQuorumTypeMember = std::ranges::any_of(vecQuorums, [&proTxHash](const auto& pQuorum) {
218+
return pQuorum->IsValidMember(proTxHash);
219+
});
213220

214221
for (auto& pQuorum : vecQuorums) {
215222
if (pQuorum->IsValidMember(proTxHash)) {
@@ -224,7 +231,7 @@ void QuorumParticipant::TriggerQuorumDataRecoveryThreads(gsl::not_null<const CBl
224231
StartDataRecoveryThread(block_index, std::move(pQuorum), nDataMask);
225232
} else {
226233
LogPrint(BCLog::LLMQ, "QuorumParticipant::%s -- No data needed from (%d, %s) at height %d\n", __func__,
227-
ToUnderlying(pQuorum->qc->llmqType), pQuorum->qc->quorumHash.ToString(), block_index->nHeight);
234+
std23::to_underlying(pQuorum->qc->llmqType), pQuorum->qc->quorumHash.ToString(), block_index->nHeight);
228235
}
229236
} else {
230237
TryStartVvecSyncThread(block_index, std::move(pQuorum), fWeAreQuorumTypeMember);

src/addressindex.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <consensus/amount.h>
1212
#include <serialize.h>
1313
#include <uint256.h>
14-
#include <util/underlying.h>
14+
#include <util/std23.h>
1515

1616
#include <chrono>
1717
#include <tuple>
@@ -122,7 +122,7 @@ struct CAddressIndexKey {
122122

123123
template<typename Stream>
124124
void Serialize(Stream& s) const {
125-
ser_writedata8(s, ToUnderlying(m_address_type));
125+
ser_writedata8(s, std23::to_underlying(m_address_type));
126126
m_address_bytes.Serialize(s);
127127
// Heights are stored big-endian for key sorting in LevelDB
128128
ser_writedata32be(s, m_block_height);
@@ -169,7 +169,7 @@ struct CAddressIndexIteratorKey {
169169

170170
template<typename Stream>
171171
void Serialize(Stream& s) const {
172-
ser_writedata8(s, ToUnderlying(m_address_type));
172+
ser_writedata8(s, std23::to_underlying(m_address_type));
173173
m_address_bytes.Serialize(s);
174174
}
175175

@@ -207,7 +207,7 @@ struct CAddressIndexIteratorHeightKey {
207207

208208
template<typename Stream>
209209
void Serialize(Stream& s) const {
210-
ser_writedata8(s, ToUnderlying(m_address_type));
210+
ser_writedata8(s, std23::to_underlying(m_address_type));
211211
m_address_bytes.Serialize(s);
212212
ser_writedata32be(s, m_block_height);
213213
}

src/bench/bls_dkg.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <bls/bls_worker.h>
88
#include <llmq/options.h>
9-
#include <util/irange.h>
9+
#include <util/helpers.h>
1010

1111
#include <random.h>
1212

@@ -48,7 +48,7 @@ class DKG
4848
void VerifyContributionShares(size_t whoAmI, const std::set<size_t>& invalidIndexes, bool aggregated)
4949
{
5050
auto result = blsWorker.VerifyContributionShares(members[whoAmI].id, receivedVvecs, receivedSkShares, aggregated);
51-
for (const size_t i : irange::range(receivedVvecs.size())) {
51+
for (const size_t i : util::irange(receivedVvecs.size())) {
5252
if (invalidIndexes.count(i)) {
5353
assert(!result[i]);
5454
} else {
@@ -63,7 +63,7 @@ class DKG
6363
members.reserve(quorumSize);
6464
ids.reserve(quorumSize);
6565

66-
for (const int i : irange::range(quorumSize)) {
66+
for (const int i : util::irange(quorumSize)) {
6767
uint256 id;
6868
WriteLE64(id.begin(), i + 1);
6969
members.push_back({CBLSId(id), {}, {}});
@@ -97,7 +97,7 @@ class DKG
9797
ReceiveShares(memberIdx);
9898

9999
std::set<size_t> invalidIndexes;
100-
for ([[maybe_unused]] const auto _ : irange::range(invalidCount)) {
100+
for ([[maybe_unused]] const auto _ : util::irange(invalidCount)) {
101101
size_t shareIdx = GetRand<size_t>(receivedSkShares.size());
102102
receivedSkShares[shareIdx].MakeNewKey();
103103
invalidIndexes.emplace(shareIdx);
@@ -120,7 +120,7 @@ static void BLSDKG_GenerateContributions(benchmark::Bench& bench, uint32_t epoch
120120
epoch_iters = 1;
121121
quorumSize = 1;
122122
}
123-
for (const int i : irange::range(quorumSize)) {
123+
for (const int i : util::irange(quorumSize)) {
124124
uint256 id;
125125
WriteLE64(id.begin(), i + 1);
126126
members.push_back({CBLSId(id), {}, {}});

src/bls/bls.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <serialize.h>
1010
#include <uint256.h>
1111
#include <util/strencodings.h>
12-
#include <util/ranges.h>
1312

1413
// bls-dash uses relic, which may define DEBUG and ERROR, which leads to many warnings in some build setups
1514
#undef ERROR
@@ -23,10 +22,9 @@
2322
#undef SEED
2423

2524
#include <array>
26-
#include <mutex>
27-
#include <unistd.h>
28-
2925
#include <atomic>
26+
#include <mutex>
27+
#include <ranges>
3028

3129
namespace bls {
3230
extern std::atomic<bool> bls_legacy_scheme;
@@ -106,7 +104,7 @@ class CBLSWrapper
106104
return;
107105
}
108106

109-
if (ranges::all_of(vecBytes, [](uint8_t c) { return c == 0; })) {
107+
if (std::ranges::all_of(vecBytes, [](uint8_t c) { return c == 0; })) {
110108
Reset();
111109
} else {
112110
try {

0 commit comments

Comments
 (0)