Skip to content
Open
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
7 changes: 2 additions & 5 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -394,29 +394,26 @@ BITCOIN_CORE_H = \
util/bytevectorhash.h \
util/check.h \
util/edge.h \
util/enumerate.h \
util/epochguard.h \
util/error.h \
util/fastrange.h \
util/fees.h \
util/golombrice.h \
util/hasher.h \
util/hash_type.h \
util/irange.h \
util/helpers.h \
util/asmap.h \
util/getuniquepath.h \
util/macros.h \
util/message.h \
util/moneystr.h \
util/overflow.h \
util/overloaded.h \
util/pointer.h \
util/ranges.h \
util/readwritefile.h \
util/result.h \
util/underlying.h \
util/serfloat.h \
util/settings.h \
util/std23.h \
util/ranges_set.h \
util/sock.h \
util/string.h \
Expand Down
11 changes: 6 additions & 5 deletions src/active/dkgsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <llmq/options.h>
#include <llmq/utils.h>
#include <masternode/meta.h>
#include <util/helpers.h>

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

for (const auto i : irange::range(members.size())) {
for (const auto i : util::irange(members.size())) {
const auto& m = members[i];
CBLSSecretKey skContrib = m_sk_contributions[i];

Expand Down Expand Up @@ -150,7 +151,7 @@ void ActiveDKGSession::VerifyPendingContributions()
return;
}

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

int badCount = 0;
int complaintCount = 0;
for (const auto i : irange::range(members.size())) {
for (const auto i : util::irange(members.size())) {
const auto& m = members[i];
if (m->bad || m->badConnection) {
qc.badMembers[i] = true;
Expand Down Expand Up @@ -352,7 +353,7 @@ void ActiveDKGSession::SendJustification(CDKGPendingMessages& pendingMessages, P
qj.proTxHash = myProTxHash;
qj.contributions.reserve(forMembers.size());

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

for (const auto i : irange::range(members.size())) {
for (const auto i : util::irange(members.size())) {
const auto& m = members[i];
if (!m->bad) {
qc.validMembers[i] = true;
Expand Down
20 changes: 10 additions & 10 deletions src/active/dkgsessionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ void ActiveDKGSessionHandler::UpdatedBlockTip(const CBlockIndex* pindexNew)
bool fNewPhase = (quorumStageInt % params.dkgPhaseBlocks) == 0;
int phaseInt = quorumStageInt / params.dkgPhaseBlocks + 1;
QuorumPhase oldPhase = phase;
if (fNewPhase && phaseInt >= ToUnderlying(QuorumPhase::Initialized) && phaseInt <= ToUnderlying(QuorumPhase::Idle)) {
if (fNewPhase && phaseInt >= std23::to_underlying(QuorumPhase::Initialized) && phaseInt <= std23::to_underlying(QuorumPhase::Idle)) {
phase = static_cast<QuorumPhase>(phaseInt);
}

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

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

m_thread_name = strprintf("llmq-%d-%d", ToUnderlying(params.type), quorumIndex);
m_thread_name = strprintf("llmq-%d-%d", std23::to_underlying(params.type), quorumIndex);
phaseHandlerThread = std::thread(&util::TraceThread, m_thread_name.c_str(),
[this, &connman, &peerman] { PhaseHandlerThread(connman, peerman); });
}
Expand Down Expand Up @@ -120,7 +120,7 @@ class AbortPhaseException : public std::exception {
void ActiveDKGSessionHandler::WaitForNextPhase(std::optional<QuorumPhase> curPhase, QuorumPhase nextPhase,
const uint256& expectedQuorumHash, const WhileWaitFunc& shouldNotWait) const
{
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));
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));

while (true) {
if (stopRequested) {
Expand All @@ -136,15 +136,15 @@ void ActiveDKGSessionHandler::WaitForNextPhase(std::optional<QuorumPhase> curPha
break;
}
if (curPhase.has_value() && _phase != curPhase) {
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);
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);
throw AbortPhaseException();
}
if (!shouldNotWait()) {
UninterruptibleSleep(std::chrono::milliseconds{100});
}
}

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));
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));

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

LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - starting sleep for %d ms, curPhase=%d\n", __func__, params.name, quorumIndex, sleepTime, ToUnderlying(curPhase));
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));

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

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

void ActiveDKGSessionHandler::HandlePhase(QuorumPhase curPhase, QuorumPhase nextPhase,
const uint256& expectedQuorumHash, double randomSleepFactor,
const StartPhaseFunc& startPhaseFunc, const WhileWaitFunc& runWhileWaiting)
{
LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - starting, curPhase=%d, nextPhase=%d\n", __func__, params.name, quorumIndex, ToUnderlying(curPhase), ToUnderlying(nextPhase));
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));

SleepBeforePhase(curPhase, expectedQuorumHash, randomSleepFactor, runWhileWaiting);
startPhaseFunc();
WaitForNextPhase(curPhase, nextPhase, expectedQuorumHash, runWhileWaiting);

LogPrint(BCLog::LLMQ_DKG, "ActiveDKGSessionHandler::%s -- %s qi[%d] - done, curPhase=%d, nextPhase=%d\n", __func__, params.name, quorumIndex, ToUnderlying(curPhase), ToUnderlying(nextPhase));
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));
}

// returns a set of NodeIds which sent invalid messages
Expand Down
23 changes: 15 additions & 8 deletions src/active/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <llmq/quorums.h>
#include <llmq/utils.h>
#include <masternode/sync.h>
#include <util/helpers.h>

#include <chain.h>
#include <chainparams.h>
Expand All @@ -24,6 +25,8 @@

#include <cxxtimer.hpp>

#include <ranges>

namespace llmq {
QuorumParticipant::QuorumParticipant(CBLSWorker& bls_worker, CConnman& connman, CDeterministicMNManager& dmnman,
QuorumObserverParent& qman, CQuorumSnapshotManager& qsnapman,
Expand All @@ -47,13 +50,15 @@ void QuorumParticipant::CheckQuorumConnections(const Consensus::LLMQParams& llmq

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

for (const auto& quorum : lastQuorums) {
if (utils::EnsureQuorumConnections(llmqParams, m_connman, m_sporkman, {m_dmnman, m_qsnapman, m_chainman, quorum->m_quorum_base_block_index},
m_dmnman.GetListAtChainTip(), proTxHash, /*is_masternode=*/true, m_quorums_watch)) {
if (deletableQuorums.erase(quorum->qc->quorumHash) > 0) {
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());
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());
}
} else if (watchOtherISQuorums && !quorum->IsMember(proTxHash)) {
Uint256HashSet connections;
Expand All @@ -63,12 +68,12 @@ void QuorumParticipant::CheckQuorumConnections(const Consensus::LLMQParams& llmq
}
if (!connections.empty()) {
if (!m_connman.HasMasternodeQuorumNodes(llmqParams.type, quorum->m_quorum_base_block_index->GetBlockHash())) {
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());
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());
m_connman.SetMasternodeQuorumNodes(llmqParams.type, quorum->m_quorum_base_block_index->GetBlockHash(), connections);
m_connman.SetMasternodeQuorumRelayMembers(llmqParams.type, quorum->m_quorum_base_block_index->GetBlockHash(), connections);
}
if (deletableQuorums.erase(quorum->qc->quorumHash) > 0) {
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());
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());
}
}
}
Expand Down Expand Up @@ -96,7 +101,7 @@ size_t QuorumParticipant::GetQuorumRecoveryStartOffset(const CQuorum& quorum, gs
size_t nIndex{0};
{
auto my_protx_hash = m_mn_activeman.GetProTxHash();
for (const auto i : irange::range(vecProTxHashes.size())) {
for (const auto i : util::irange(vecProTxHashes.size())) {
// cppcheck-suppress useStlAlgorithm
if (my_protx_hash == vecProTxHashes[i]) {
nIndex = i;
Expand Down Expand Up @@ -156,7 +161,7 @@ MessageProcessingResult QuorumParticipant::ProcessContribQDATA(CNode& pfrom, CDa

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

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

for (auto& pQuorum : vecQuorums) {
if (pQuorum->IsValidMember(proTxHash)) {
Expand All @@ -224,7 +231,7 @@ void QuorumParticipant::TriggerQuorumDataRecoveryThreads(gsl::not_null<const CBl
StartDataRecoveryThread(block_index, std::move(pQuorum), nDataMask);
} else {
LogPrint(BCLog::LLMQ, "QuorumParticipant::%s -- No data needed from (%d, %s) at height %d\n", __func__,
ToUnderlying(pQuorum->qc->llmqType), pQuorum->qc->quorumHash.ToString(), block_index->nHeight);
std23::to_underlying(pQuorum->qc->llmqType), pQuorum->qc->quorumHash.ToString(), block_index->nHeight);
}
} else {
TryStartVvecSyncThread(block_index, std::move(pQuorum), fWeAreQuorumTypeMember);
Expand Down
8 changes: 4 additions & 4 deletions src/addressindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <consensus/amount.h>
#include <serialize.h>
#include <uint256.h>
#include <util/underlying.h>
#include <util/std23.h>

#include <chrono>
#include <tuple>
Expand Down Expand Up @@ -122,7 +122,7 @@ struct CAddressIndexKey {

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

template<typename Stream>
void Serialize(Stream& s) const {
ser_writedata8(s, ToUnderlying(m_address_type));
ser_writedata8(s, std23::to_underlying(m_address_type));
m_address_bytes.Serialize(s);
}

Expand Down Expand Up @@ -207,7 +207,7 @@ struct CAddressIndexIteratorHeightKey {

template<typename Stream>
void Serialize(Stream& s) const {
ser_writedata8(s, ToUnderlying(m_address_type));
ser_writedata8(s, std23::to_underlying(m_address_type));
m_address_bytes.Serialize(s);
ser_writedata32be(s, m_block_height);
}
Expand Down
10 changes: 5 additions & 5 deletions src/bench/bls_dkg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <bls/bls_worker.h>
#include <llmq/options.h>
#include <util/irange.h>
#include <util/helpers.h>

#include <random.h>

Expand Down Expand Up @@ -48,7 +48,7 @@ class DKG
void VerifyContributionShares(size_t whoAmI, const std::set<size_t>& invalidIndexes, bool aggregated)
{
auto result = blsWorker.VerifyContributionShares(members[whoAmI].id, receivedVvecs, receivedSkShares, aggregated);
for (const size_t i : irange::range(receivedVvecs.size())) {
for (const size_t i : util::irange(receivedVvecs.size())) {
if (invalidIndexes.count(i)) {
assert(!result[i]);
} else {
Expand All @@ -63,7 +63,7 @@ class DKG
members.reserve(quorumSize);
ids.reserve(quorumSize);

for (const int i : irange::range(quorumSize)) {
for (const int i : util::irange(quorumSize)) {
uint256 id;
WriteLE64(id.begin(), i + 1);
members.push_back({CBLSId(id), {}, {}});
Expand Down Expand Up @@ -97,7 +97,7 @@ class DKG
ReceiveShares(memberIdx);

std::set<size_t> invalidIndexes;
for ([[maybe_unused]] const auto _ : irange::range(invalidCount)) {
for ([[maybe_unused]] const auto _ : util::irange(invalidCount)) {
size_t shareIdx = GetRand<size_t>(receivedSkShares.size());
receivedSkShares[shareIdx].MakeNewKey();
invalidIndexes.emplace(shareIdx);
Expand All @@ -120,7 +120,7 @@ static void BLSDKG_GenerateContributions(benchmark::Bench& bench, uint32_t epoch
epoch_iters = 1;
quorumSize = 1;
}
for (const int i : irange::range(quorumSize)) {
for (const int i : util::irange(quorumSize)) {
uint256 id;
WriteLE64(id.begin(), i + 1);
members.push_back({CBLSId(id), {}, {}});
Expand Down
8 changes: 3 additions & 5 deletions src/bls/bls.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <serialize.h>
#include <uint256.h>
#include <util/strencodings.h>
#include <util/ranges.h>

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

#include <array>
#include <mutex>
#include <unistd.h>

#include <atomic>
#include <mutex>
#include <ranges>

Comment on lines 24 to 28
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, check the actual file content around the specified lines
head -30 src/bls/bls.h | cat -n

Repository: dashpay/dash

Length of output: 1057


🏁 Script executed:

# Check line 107 specifically for std::ranges::all_of usage
sed -n '100,115p' src/bls/bls.h | cat -n

Repository: dashpay/dash

Length of output: 693


🏁 Script executed:

# Run the verification script from the review comment
set -euo pipefail

# Find files using std::ranges algorithms
rg -nP 'std::ranges::(all_of|any_of|none_of|find_if|find|count_if)\s*\(' --type=cpp --type=h > /tmp/std_ranges_calls.txt 2>&1 || true

python3 - <<'PY'
import re, pathlib, collections

if not pathlib.Path('/tmp/std_ranges_calls.txt').exists():
    print("No matches found")
else:
    hits = collections.defaultdict(int)
    for line in pathlib.Path('/tmp/std_ranges_calls.txt').read_text().splitlines():
        if not line.strip():
            continue
        path = line.split(':', 1)[0]
        hits[path] += 1

    for path in sorted(hits):
        txt = pathlib.Path(path).read_text(errors='ignore')
        has_algorithm = re.search(r'^\s*#\s*include\s*<algorithm>\s*$', txt, re.M) is not None
        print(f"{path}: ranges_calls={hits[path]}, include_<algorithm>={has_algorithm}")
PY

Repository: dashpay/dash

Length of output: 1572


🌐 Web query:

C++20 std::ranges::all_of header location which include file

💡 Result:

std::ranges::all_of is declared in the <algorithm> header (C++20). [1]

`#include` <algorithm>   // std::ranges::all_of

[1] https://en.cppreference.com/w/cpp/algorithm/ranges/all_any_none_of.html


Add <algorithm> when using std::ranges::all_of.

The file uses std::ranges::all_of (line 107) but does not include <algorithm>, where this function is declared in C++20. Relying on transitive includes is non-portable across different standard library implementations (libstdc++, libc++).

Proposed fix
 `#include` <array>
 `#include` <atomic>
 `#include` <mutex>
 `#include` <ranges>
+#include <algorithm>

Note: This pattern appears in multiple files across the PR; a systematic review of all std::ranges::* usage is recommended.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/bls/bls.h` around lines 24 - 28, The header bls.h uses
std::ranges::all_of but does not include <algorithm>; add `#include` <algorithm>
to bls.h so the declaration of std::ranges::all_of is available (and similarly
add <algorithm> in any other headers that use std::ranges::*); search for usages
of std::ranges::all_of (and other std::ranges algorithms) and include
<algorithm> next to other standard headers to avoid relying on transitive
includes.

namespace bls {
extern std::atomic<bool> bls_legacy_scheme;
Expand Down Expand Up @@ -106,7 +104,7 @@ class CBLSWrapper
return;
}

if (ranges::all_of(vecBytes, [](uint8_t c) { return c == 0; })) {
if (std::ranges::all_of(vecBytes, [](uint8_t c) { return c == 0; })) {
Reset();
} else {
try {
Expand Down
Loading
Loading