-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: consolidate Dash-specific utils between C++23 polyfills (util/std23.h) and helpers (util/helpers.h)
#7098
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
base: develop
Are you sure you want to change the base?
Conversation
We have a multitude of C++23 polyfills across the codebase and the current naming convention makes it painful to switch to the standard library when the time eventually comes.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
WalkthroughThe PR removes legacy util headers (util/enumerate.h, util/irange.h, util/pointer.h, util/ranges.h, util/underlying.h) and adds util/helpers.h and util/std23.h. util/helpers.h provides find_if_opt, irange, shared_ptr_equal/not_equal, and to_string. util/std23.h provides C++23 shims (to_underlying, ranges::contains, ranges::fold_left, views::enumerate). The codebase is updated to use std23::to_underlying, std::ranges, std23::views::enumerate, util::irange, and util::find_if_opt. Three constructor signatures were expanded: QuorumParticipant, CCoinJoinServer, and CSimplifiedMNListEntry. Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/coinjoin/coinjoin.cpp (1)
1-1: Critical: Clang-format differences detected.The pipeline failure indicates formatting issues in this file. Run clang-format to resolve the differences before merging.
src/llmq/quorumsman.cpp (1)
1-753: Address clang-format violations.The pipeline reports formatting differences in this file. Please run clang-format to ensure consistent code style.
#!/bin/bash # Verify the clang-format status of this file clang-format --style=file --dry-run src/llmq/quorumsman.cpp 2>&1 || echo "Formatting check complete"src/governance/governance.cpp (1)
1-1565: Run clang-format onsrc/governance/governance.cppto fix column limit violations.Multiple lines in this file exceed the 120-character column limit defined in
.clang-format, which will be detected by CI checks. Run the repo's clang-format/diff-format target to automatically correct these before merging.
🤖 Fix all issues with AI agents
In @src/governance/governance.cpp:
- Around line 14-20: governance.cpp uses std23::to_underlying but doesn't
include its header; add the missing include for <util/std23.h> at the top of
governance.cpp (near other includes) so references to std23::to_underlying (used
at lines around where functions reference enum underlying values) compile
correctly.
In @src/masternode/utils.cpp:
- Around line 11-15: The file currently includes <ranges> but uses
std::ranges::any_of (a ranges algorithm) which on many standard libraries is
provided via <algorithm>; replace or augment the include by adding #include
<algorithm> and remove the non-portable reliance on <ranges> so that
std::ranges::any_of is guaranteed to be declared (update the include list where
<ranges> is present in utils.cpp).
In @src/rpc/mempool.cpp:
- Around line 329-330: The RPC currently emits "instantlock" as a tri-state
string from the info.pushKV("instantlock", isman ?
util::to_string(isman->IsLocked(tx.GetHash())) : "unknown") call, but the RPC
schema/docs (MempoolEntryDescription()) don't reflect that; update the RPC
schema to match by adding "instantlock" to MempoolEntryDescription() as type STR
(or alternatively change the emitted fields to a boolean plus a separate
"instantlock_known" flag), and ensure the output generation (the info.pushKV
call and use of isman->IsLocked) is consistent with that documented choice.
🧹 Nitpick comments (14)
src/masternode/utils.cpp (1)
71-74: Good modernization tostd::ranges::any_of; consider inlining for brevity.
This aligns with the project’s C++20 baseline and reduces custom utility reliance. Based on learnings, prefer std algorithms.Optional refactor
- bool fFound = std::ranges::any_of(mixing_masternodes, [&pnode](const auto& dmn) { - return pnode->addr == dmn->pdmnState->netInfo->GetPrimary(); - }); - if (fFound) return; // do NOT disconnect mixing masternodes + if (std::ranges::any_of(mixing_masternodes, [pnode](const auto& dmn) { + return pnode->addr == dmn->pdmnState->netInfo->GetPrimary(); + })) { + return; // do NOT disconnect mixing masternodes + }src/governance/signing.cpp (1)
18-20: Consider dropping<ranges>here (not needed forstd::ranges::any_of).
std::ranges::any_ofis provided by<algorithm>; keeping<ranges>is harmless but adds an extra header.src/llmq/quorums.cpp (2)
142-151:util::irange(members.size())index type change: consider guarding theint(i)cast.
util::irange(size_t)yieldssize_t;return int(i);assumesmembers.size() <= INT_MAX(probably true for quorum sizes, but making it explicit avoids future footguns).One low-noise option
int CQuorum::GetMemberIndex(const uint256& proTxHash) const { + // Quorum sizes are bounded; keep the cast safe even if this ever changes. + assert(members.size() <= static_cast<size_t>(std::numeric_limits<int>::max())); for (const auto i : util::irange(members.size())) { // cppcheck-suppress useStlAlgorithm if (members[i]->proTxHash == proTxHash) { return int(i); } } return -1; }Also applies to: 179-188
7-15: Add<algorithm>for explicit access tostd::ranges::any_of
While<ranges>transitively includes<algorithm>in modern C++20 standard libraries (Clang 16+, GCC 11.1+), explicit inclusion is more defensive and follows the pattern used in other LLMQ files like src/llmq/signing.cpp and src/governance/signing.cpp.Proposed fix
#include <dbwrapper.h> +#include <algorithm> #include <memory> #include <ranges>src/llmq/options.cpp (1)
75-81: Thefind_if_optusage correctly returnsLLMQParamsby value.LLMQParamsis a small, trivially-copyable struct (~64 bytes) containing only scalar values andstd::string_view, so the copy cost is negligible. The code executes during configuration parsing (not in a hot path), making this design choice acceptable. If stricter optimization is desired later, returning a pointer or reference wrapper would be an option, but it's not necessary for correctness or meaningful performance.src/test/block_reward_reallocation_tests.cpp (1)
48-51: Watchstd23::views::enumerate()index types (likelysize_t) flowing intoCOutPoint/SignSignature.
To avoid narrowing warnings/implicit conversions, cast indices at the use site (e.g.,uint32_tfor vout,unsigned intfor vin).Proposed minimal casts
- for (auto [i, tx] : std23::views::enumerate(txs)) { - for (auto [j, output] : std23::views::enumerate(tx->vout)) { - utxos.try_emplace(COutPoint(tx->GetHash(), j), std::make_pair((int)i + 1, output.nValue)); + for (auto [i, tx] : std23::views::enumerate(txs)) { + for (auto [j, output] : std23::views::enumerate(tx->vout)) { + utxos.try_emplace(COutPoint(tx->GetHash(), static_cast<uint32_t>(j)), + std::make_pair(static_cast<int>(i) + 1, output.nValue)); } }- for (auto [i, input] : std23::views::enumerate(tx.vin)) { + for (auto [i, input] : std23::views::enumerate(tx.vin)) { uint256 hashBlock; CTransactionRef txFrom = GetTransaction(/*block_index=*/nullptr, &mempool, input.prevout.hash, Params().GetConsensus(), hashBlock); BOOST_REQUIRE(txFrom); - BOOST_REQUIRE(SignSignature(tempKeystore, *txFrom, tx, i, SIGHASH_ALL)); + BOOST_REQUIRE(SignSignature(tempKeystore, *txFrom, tx, static_cast<unsigned int>(i), SIGHASH_ALL)); }Also applies to: 103-109
src/chainparams.cpp (2)
9-21: Consider adding<algorithm>explicitly forstd::ranges::find_if.
Relying on transitive includes can be brittle across toolchains/stdlibs.
736-744: Validatethresholdrelative tosizebefore mutating LLMQ params.
A bad-llmq*params=<size>:<threshold>could silently produce nonsense and fail later in harder-to-debug ways.Also applies to: 975-983
src/evo/deterministicmns.cpp (1)
120-129:std::ranges::find_ifmigration looks good; ensure required headers are present.
If this TU no longer includes<algorithm>transitively after the header moves, you may need to add it forstd::ranges::find_if.src/llmq/utils.cpp (1)
791-792: Consider usingstd::ranges::any_offor clarity.The current implementation uses
std::ranges::find_if(...) != members.end()to check membership. For a simple membership check,std::ranges::any_oforstd23::ranges::contains(since you're adding it in this PR) would be more expressive.♻️ Suggested refactor
- bool isMember = std::ranges::find_if(members, [&](const auto& dmn) { return dmn->proTxHash == myProTxHash; }) != - members.end(); + bool isMember = std::ranges::any_of(members, [&](const auto& dmn) { return dmn->proTxHash == myProTxHash; });src/validation.cpp (1)
6061-6067: Avoid transitive include reliance forstd23::to_underlying+ prefer a release-safe “unreachable”.
- Line 6062: if
std23::to_underlyingisn’t guaranteed via direct include in this TU, please include the defining header here (avoid brittle transitive includes).- Lines 6065-6067:
assert(false)disappears in release; if you want a hard “can’t happen” marker, prefer a construct that remains unreachable in release builds too (e.g. projectAssume(false)/std::unreachable()/ equivalent).src/llmq/dkgsessionmgr.cpp (3)
287-321: Make thesize_t→uint16_tnarrowing explicit when storing member indexes.Line 317:
icomes fromutil::irange(members.size())(likelysize_t) but is stored intostd::vector<uint16_t> memberIndexesRet; make the narrowing explicit (and optionally assert the bound) to prevent silent truncation if quorum sizes ever change.Proposed patch
- memberIndexesRet.emplace_back(i); + memberIndexesRet.emplace_back(static_cast<uint16_t>(i));
302-309:util::irange(vvec_size)loop is fine; consider avoiding unused loop variable.Minor: if you don’t need
_, you could use a simple index loop orwhile (vvec_size--)style; current code is acceptable, but clang-format may prefer slightly different wrapping.
371-381: Unify enum-to-int logging withinCleanupOldContributions().Line 380 now logs
std23::to_underlying(params.type), but later in the same function you still loguint8_t(params.type)(unchanged lines). Consider switching those tostd23::to_underlying(params.type)as well to keep output consistent and avoid any accidental “char-like” formatting surprises.
142820d to
e92a764
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/llmq/commitment.cpp (1)
163-172: Guardstd::views::iota(start,end)againststart > end(can become non-terminating + OOB)
Ifmembers.size()ever exceedsllmq_params.size,std::views::iota(members.size(), llmq_params.size)can iterate forever and immediately index pastvalidMembers/signers. Even if the invariant “members.size() == params.size” should hold, this is a validation path and should fail safely.Proposed fix
- for (const auto i : std::views::iota(members.size(), size_t(llmq_params.size))) { + const size_t members_sz = members.size(); + const size_t params_sz = size_t(llmq_params.size); + if (members_sz > params_sz) { + LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid members.size=%d > params.size=%d\n", + quorumHash.ToString(), members_sz, params_sz); + return false; + } + for (size_t i = members_sz; i < params_sz; ++i) { if (validMembers[i]) { LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid validMembers bitset. bit %d should not be set\n", quorumHash.ToString(), i); return false; } if (signers[i]) { LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid signers bitset. bit %d should not be set\n", quorumHash.ToString(), i); return false; } }src/llmq/dkgsession.cpp (1)
580-588: Guardstd::views::iota(start,end)againststart > endin bitset validation
Same issue as inCFinalCommitment::Verify: ifmembers.size()ever exceedsparams.size, this can become non-terminating and/or index OOB.Proposed fix
- for (const auto i : std::views::iota(members.size(), size_t(params.size))) { + const size_t members_sz = members.size(); + const size_t params_sz = size_t(params.size); + if (members_sz > params_sz) { + logger.Batch("invalid members.size=%d > params.size=%d", members_sz, params_sz); + retBan = true; + return false; + } + for (size_t i = members_sz; i < params_sz; ++i) { // cppcheck-suppress useStlAlgorithm if (qc.validMembers[i]) { retBan = true; logger.Batch("invalid validMembers bitset. bit %d should not be set", i); return false; } }
🤖 Fix all issues with AI agents
In @src/llmq/commitment.cpp:
- Around line 9-11: This file uses new symbols std23::to_underlying,
util::irange, and std::views::iota but doesn't include their defining headers;
add explicit includes for the appropriate headers (the header that defines
std23::to_underlying, the util header that defines util::irange, and <ranges> or
<iterator> as needed to provide std::views::iota) so the file no longer relies
on transitive includes; update the top of src/llmq/commitment.cpp near the
existing includes to add these headers and apply the same change to the other
affected files (lines 35-38).
In @src/llmq/dkgsession.cpp:
- Around line 28-29: The file currently includes <ranges> but uses
std::ranges::count_if which is declared in <algorithm>; add #include <algorithm>
alongside the existing includes (replace or augment the include block that
currently contains <ranges>) so std::ranges::count_if is resolved, and apply the
same change in the other occurrences mentioned (around the other include sites
at the locations noted ~lines 240 and ~670).
- Around line 47-51: The bound check in GetSimulatedErrorRate is comparing an
integral underlying value to the scoped enum constant DKGError::type::_COUNT;
change the comparison to use the same representation for both sides — e.g.
compare std23::to_underlying(type) >=
std23::to_underlying(DKGError::type::_COUNT) or cast DKGError::type::_COUNT to
the underlying integer type — and additionally guard the map access by verifying
the index is less than simDkgErrorMap.size() before returning
simDkgErrorMap[...] to avoid out-of-range indexing in GetSimulatedErrorRate.
In @src/rpc/mempool.cpp:
- Around line 329-330: Replace the stringified instantlock value with a real
JSON boolean: remove util::to_string() and make the info.pushKV("instantlock",
...) call pass a bool (use isman->IsLocked(tx.GetHash()) when isman is non-null,
otherwise return a sensible boolean/null according to desired tri-state). Update
the pushKV invocation around info.pushKV("instantlock", ...) that currently
references util::to_string/isman/IsLocked/tx.GetHash() so the RPC returns a
boolean instead of "true"/"false"/"unknown".
🧹 Nitpick comments (6)
src/evo/deterministicmns.cpp (1)
1468-1468: Use util::irange for consistency.Line 1468 uses
std::views::iotadirectly, which is inconsistent with the rest of the PR. For consistency and to match the consolidated utility pattern, consider usingutil::irangeinstead.♻️ Suggested change for consistency
- for (auto current_height : std::views::iota(start_height, tip_index->nHeight + 1)) { + for (auto current_height : util::irange(start_height, tip_index->nHeight + 1)) {Note: This would require adding an overload of
util::irangethat takes a start and end parameter, or the current usage withstd::views::iotais acceptable as it doesn't have a simpleutil::irangeequivalent.src/active/dkgsession.cpp (2)
86-99: Prefersize_t(orauto) for indices yielded byutil::irange
util::irange(members.size())iteratessize_t; keep the loop variablesize_t/autoto avoid signed/width conversion warnings.Proposed tweak
- for (const uint32_t i : util::irange(members.size())) { + for (const size_t i : util::irange(members.size())) { const auto& m = members[i]; if (!std23::ranges::contains(forMembers, m->dmn->proTxHash)) { continue; } ... }Also applies to: 155-168, 272-281, 449-454
357-372:std23::ranges::contains(...)is fine; consider container-native.contains()when available
IfforMembers/validCommitmentsare associative containers (std::set/std::unordered_set),.contains()can be clearer and (forstd::set) avoids a potentially linear genericranges::containspolyfill.Also applies to: 564-566
src/llmq/dkgsessionmgr.cpp (1)
289-322:util::irangeloop conversions are fine; keep an eye on large/untrusted sizes
Iteratingvvec_sizefrom DB viautil::irange(vvec_size)is fine, but if DB corruption is in-scope, consider a sanity cap before allocating/reading.Also applies to: 333-339, 345-355, 380-381
src/llmq/blockprocessor.cpp (1)
478-482: Optional: castquorumIndexto the API’s expected type to avoid sign/width warnings
util::irange(quorums_num)yieldssize_t; some callees takeint/int16_t. Tighten conversions at the call sites for warning-clean builds.Also applies to: 628-634, 744-769
src/util/std23.h (1)
72-98: Consider returningiterator&fromoperator++for better iterator conformance.The
enumerateiterator'soperator++returnsvoid(line 88), which works for range-based for loops but doesn't fully conform to standard iterator requirements. Standard iterators typically return a reference to*thisfrom prefix increment.♻️ Optional enhancement for iterator conformance
- void operator ++ () { ++i; ++iter; } + iterator& operator ++ () { ++i; ++iter; return *this; }
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (58)
src/Makefile.amsrc/active/dkgsession.cppsrc/active/quorums.cppsrc/bench/bls_dkg.cppsrc/bls/bls.hsrc/bls/bls_worker.cppsrc/chainparams.cppsrc/coinjoin/client.cppsrc/coinjoin/client.hsrc/coinjoin/coinjoin.cppsrc/coinjoin/coinjoin.hsrc/coinjoin/common.hsrc/coinjoin/server.cppsrc/evo/cbtx.cppsrc/evo/deterministicmns.cppsrc/evo/deterministicmns.hsrc/evo/dmnstate.hsrc/evo/mnhftx.cppsrc/evo/simplifiedmns.hsrc/evo/specialtxman.cppsrc/governance/classes.cppsrc/governance/governance.cppsrc/governance/signing.cppsrc/instantsend/signing.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/commitment.hsrc/llmq/debug.cppsrc/llmq/dkgsession.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/dkgsessionmgr.hsrc/llmq/observer/quorums.cppsrc/llmq/options.cppsrc/llmq/quorums.cppsrc/llmq/quorumsman.cppsrc/llmq/signing.cppsrc/llmq/signing_shares.cppsrc/llmq/signing_shares.hsrc/llmq/snapshot.hsrc/llmq/utils.cppsrc/masternode/payments.cppsrc/masternode/utils.cppsrc/qt/guiutil_font.cppsrc/rpc/mempool.cppsrc/rpc/quorums.cppsrc/rpc/rawtransaction.cppsrc/spork.cppsrc/test/block_reward_reallocation_tests.cppsrc/test/bls_tests.cppsrc/test/evo_netinfo_tests.cppsrc/test/llmq_dkg_tests.cppsrc/util/helpers.hsrc/util/irange.hsrc/util/pointer.hsrc/util/ranges.hsrc/util/std23.hsrc/validation.cpptest/util/data/non-backported.txt
💤 Files with no reviewable changes (4)
- src/util/ranges.h
- src/util/pointer.h
- src/evo/specialtxman.cpp
- src/util/irange.h
🚧 Files skipped from review as they are similar to previous changes (19)
- src/evo/deterministicmns.h
- src/evo/mnhftx.cpp
- src/evo/dmnstate.h
- test/util/data/non-backported.txt
- src/llmq/observer/quorums.cpp
- src/llmq/dkgsessionmgr.h
- src/qt/guiutil_font.cpp
- src/test/evo_netinfo_tests.cpp
- src/llmq/signing_shares.cpp
- src/llmq/signing.cpp
- src/bls/bls_worker.cpp
- src/util/helpers.h
- src/Makefile.am
- src/coinjoin/coinjoin.h
- src/validation.cpp
- src/llmq/snapshot.h
- src/llmq/signing_shares.h
- src/governance/signing.cpp
- src/masternode/utils.cpp
🧰 Additional context used
📓 Path-based instructions (11)
src/**/*.{cpp,h,hpp,cc}
📄 CodeRabbit inference engine (CLAUDE.md)
Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1
Files:
src/coinjoin/common.hsrc/llmq/commitment.hsrc/bench/bls_dkg.cppsrc/llmq/utils.cppsrc/governance/governance.cppsrc/rpc/rawtransaction.cppsrc/test/bls_tests.cppsrc/governance/classes.cppsrc/evo/cbtx.cppsrc/util/std23.hsrc/coinjoin/server.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsession.cppsrc/rpc/quorums.cppsrc/llmq/quorums.cppsrc/masternode/payments.cppsrc/llmq/dkgsessionmgr.cppsrc/spork.cppsrc/evo/simplifiedmns.hsrc/llmq/quorumsman.cppsrc/evo/deterministicmns.cppsrc/test/block_reward_reallocation_tests.cppsrc/test/llmq_dkg_tests.cppsrc/active/dkgsession.cppsrc/active/quorums.cppsrc/llmq/debug.cppsrc/chainparams.cppsrc/rpc/mempool.cppsrc/coinjoin/client.cppsrc/coinjoin/client.hsrc/bls/bls.hsrc/coinjoin/coinjoin.cppsrc/instantsend/signing.cppsrc/llmq/options.cpp
src/{masternode,evo,llmq,governance,coinjoin}/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Use Dash-specific database implementations: CFlatDB for persistent storage (MasternodeMetaStore, GovernanceStore, SporkStore, NetFulfilledRequestStore) and CDBWrapper extensions for Evolution/DKG/InstantSend/Quorum/RecoveredSigs data
Files:
src/coinjoin/common.hsrc/llmq/commitment.hsrc/llmq/utils.cppsrc/governance/governance.cppsrc/governance/classes.cppsrc/evo/cbtx.cppsrc/coinjoin/server.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsession.cppsrc/llmq/quorums.cppsrc/masternode/payments.cppsrc/llmq/dkgsessionmgr.cppsrc/evo/simplifiedmns.hsrc/llmq/quorumsman.cppsrc/evo/deterministicmns.cppsrc/llmq/debug.cppsrc/coinjoin/client.cppsrc/coinjoin/client.hsrc/coinjoin/coinjoin.cppsrc/llmq/options.cpp
src/coinjoin/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
CoinJoin implementation must use masternode-coordinated mixing sessions with uniform denomination outputs
Files:
src/coinjoin/common.hsrc/coinjoin/server.cppsrc/coinjoin/client.cppsrc/coinjoin/client.hsrc/coinjoin/coinjoin.cpp
src/{masternode,llmq,evo,coinjoin,governance}/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Use unordered_lru_cache for efficient caching with LRU eviction in Dash-specific data structures
Files:
src/coinjoin/common.hsrc/llmq/commitment.hsrc/llmq/utils.cppsrc/governance/governance.cppsrc/governance/classes.cppsrc/evo/cbtx.cppsrc/coinjoin/server.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsession.cppsrc/llmq/quorums.cppsrc/masternode/payments.cppsrc/llmq/dkgsessionmgr.cppsrc/evo/simplifiedmns.hsrc/llmq/quorumsman.cppsrc/evo/deterministicmns.cppsrc/llmq/debug.cppsrc/coinjoin/client.cppsrc/coinjoin/client.hsrc/coinjoin/coinjoin.cppsrc/llmq/options.cpp
src/{masternode,llmq}/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
BLS integration must be used for cryptographic foundation of advanced masternode features
Files:
src/llmq/commitment.hsrc/llmq/utils.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsession.cppsrc/llmq/quorums.cppsrc/masternode/payments.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/quorumsman.cppsrc/llmq/debug.cppsrc/llmq/options.cpp
src/llmq/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
src/llmq/**/*.{cpp,h}: LLMQ quorums must support multiple configurations (50/60, 400/60, 400/85) for different services (ChainLocks, InstantSend, governance voting)
InstantSend implementation must provide distributed key generation for secure transaction locking with quorum consensus
ChainLocks implementation must prevent reorganizations and provide block finality through 51% attack prevention
Files:
src/llmq/commitment.hsrc/llmq/utils.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsession.cppsrc/llmq/quorums.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/quorumsman.cppsrc/llmq/debug.cppsrc/llmq/options.cpp
src/bench/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Performance benchmarks in src/bench/ must use the nanobench library
Files:
src/bench/bls_dkg.cpp
src/governance/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Governance implementation must support governance objects (proposals, triggers, superblock management) and on-chain voting with tallying
Files:
src/governance/governance.cppsrc/governance/classes.cpp
src/{test,wallet/test}/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework
Files:
src/test/bls_tests.cppsrc/test/block_reward_reallocation_tests.cppsrc/test/llmq_dkg_tests.cpp
src/{masternode,evo}/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Masternode lists must use immutable data structures (Immer library) for thread safety
Files:
src/evo/cbtx.cppsrc/masternode/payments.cppsrc/evo/simplifiedmns.hsrc/evo/deterministicmns.cpp
src/evo/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Special transactions use payload serialization routines defined in src/evo/specialtx.h and must include appropriate special transaction types (ProRegTx, ProUpServTx, ProUpRegTx, ProUpRevTx)
Files:
src/evo/cbtx.cppsrc/evo/simplifiedmns.hsrc/evo/deterministicmns.cpp
🧠 Learnings (46)
📓 Common learnings
Learnt from: kwvg
Repo: dashpay/dash PR: 6838
File: src/governance/signing.cpp:232-242
Timestamp: 2025-10-03T11:30:10.766Z
Learning: The Dash codebase dropped C++17 support in PR #6380 and now requires C++20 or later, as configured in configure.ac. C++20 features, including std::ranges algorithms like std::ranges::any_of, are appropriate and preferred where they improve code clarity.
Learnt from: kwvg
Repo: dashpay/dash PR: 6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Learnt from: knst
Repo: dashpay/dash PR: 6916
File: src/univalue/include/univalue.h:81-88
Timestamp: 2025-10-25T07:08:51.918Z
Learning: The univalue library (in src/univalue/) is no longer a vendored external dependency but is now part of the Bitcoin Core codebase and can be modified as needed during backports.
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/coinjoin/**/*.{cpp,h} : CoinJoin implementation must use masternode-coordinated mixing sessions with uniform denomination outputs
Applied to files:
src/coinjoin/common.hsrc/llmq/utils.cppsrc/governance/classes.cppsrc/coinjoin/server.cppsrc/llmq/dkgsession.cppsrc/masternode/payments.cppsrc/llmq/dkgsessionmgr.cppsrc/evo/deterministicmns.cppsrc/test/block_reward_reallocation_tests.cppsrc/active/dkgsession.cppsrc/active/quorums.cppsrc/coinjoin/client.cppsrc/coinjoin/client.hsrc/coinjoin/coinjoin.cppsrc/instantsend/signing.cpp
📚 Learning: 2025-12-22T15:42:48.595Z
Learnt from: kwvg
Repo: dashpay/dash PR: 7068
File: src/qt/guiutil_font.h:68-77
Timestamp: 2025-12-22T15:42:48.595Z
Learning: In C++/Qt codebases, use fail-fast asserts in setters to enforce invariants (e.g., ensuring internal maps contain necessary keys). Prefer assert() for programmer errors that should be caught in development and debugging, rather than defensive runtime checks with fallbacks. This helps catch invariant violations early during development. Apply to header and source files where invariant-driven state mutations occur, especially in setters like SetWeightBold/SetWeightNormal that assume established relationships or preconditions.
Applied to files:
src/coinjoin/common.hsrc/llmq/commitment.hsrc/util/std23.hsrc/evo/simplifiedmns.hsrc/coinjoin/client.hsrc/bls/bls.h
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/llmq/**/*.{cpp,h} : InstantSend implementation must provide distributed key generation for secure transaction locking with quorum consensus
Applied to files:
src/llmq/commitment.hsrc/bench/bls_dkg.cppsrc/llmq/utils.cppsrc/rpc/rawtransaction.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsession.cppsrc/rpc/quorums.cppsrc/llmq/quorums.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/quorumsman.cppsrc/test/llmq_dkg_tests.cppsrc/active/dkgsession.cppsrc/active/quorums.cppsrc/llmq/debug.cppsrc/chainparams.cppsrc/rpc/mempool.cppsrc/coinjoin/coinjoin.cppsrc/instantsend/signing.cppsrc/llmq/options.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{masternode,llmq}/**/*.{cpp,h} : BLS integration must be used for cryptographic foundation of advanced masternode features
Applied to files:
src/llmq/commitment.hsrc/bench/bls_dkg.cppsrc/llmq/utils.cppsrc/rpc/rawtransaction.cppsrc/test/bls_tests.cppsrc/evo/cbtx.cppsrc/coinjoin/server.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsession.cppsrc/rpc/quorums.cppsrc/llmq/quorums.cppsrc/masternode/payments.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/quorumsman.cppsrc/evo/deterministicmns.cppsrc/test/block_reward_reallocation_tests.cppsrc/active/dkgsession.cppsrc/active/quorums.cppsrc/chainparams.cppsrc/rpc/mempool.cppsrc/coinjoin/client.cppsrc/bls/bls.hsrc/coinjoin/coinjoin.cppsrc/instantsend/signing.cppsrc/llmq/options.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/llmq/**/*.{cpp,h} : LLMQ quorums must support multiple configurations (50/60, 400/60, 400/85) for different services (ChainLocks, InstantSend, governance voting)
Applied to files:
src/llmq/commitment.hsrc/bench/bls_dkg.cppsrc/llmq/utils.cppsrc/governance/governance.cppsrc/rpc/rawtransaction.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsession.cppsrc/rpc/quorums.cppsrc/llmq/quorums.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/quorumsman.cppsrc/evo/deterministicmns.cppsrc/active/dkgsession.cppsrc/active/quorums.cppsrc/llmq/debug.cppsrc/chainparams.cppsrc/rpc/mempool.cppsrc/instantsend/signing.cppsrc/llmq/options.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/llmq/**/*.{cpp,h} : ChainLocks implementation must prevent reorganizations and provide block finality through 51% attack prevention
Applied to files:
src/llmq/commitment.hsrc/llmq/utils.cppsrc/rpc/rawtransaction.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsession.cppsrc/rpc/quorums.cppsrc/llmq/quorums.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/quorumsman.cppsrc/active/dkgsession.cppsrc/active/quorums.cppsrc/chainparams.cppsrc/rpc/mempool.cppsrc/coinjoin/coinjoin.cppsrc/instantsend/signing.cppsrc/llmq/options.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/evo/evodb/**/*.{cpp,h} : Evolution Database (CEvoDb) must handle masternode snapshots, quorum state, governance objects with efficient differential updates for masternode lists
Applied to files:
src/llmq/utils.cppsrc/governance/governance.cppsrc/evo/cbtx.cppsrc/coinjoin/server.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/rpc/quorums.cppsrc/llmq/quorums.cppsrc/evo/deterministicmns.cppsrc/test/block_reward_reallocation_tests.cppsrc/active/quorums.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{masternode,evo}/**/*.{cpp,h} : Masternode lists must use immutable data structures (Immer library) for thread safety
Applied to files:
src/llmq/utils.cppsrc/coinjoin/server.cppsrc/masternode/payments.cppsrc/evo/deterministicmns.cppsrc/test/block_reward_reallocation_tests.cpp
📚 Learning: 2025-08-19T15:08:00.835Z
Learnt from: knst
Repo: dashpay/dash PR: 6692
File: src/llmq/commitment.cpp:54-60
Timestamp: 2025-08-19T15:08:00.835Z
Learning: In Dash Core, llmq_params.size == 1 is used only for regtest environments, not on public networks, which significantly reduces the risk profile of code paths specific to single-member quorums.
Applied to files:
src/llmq/utils.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/rpc/quorums.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/quorumsman.cppsrc/active/quorums.cppsrc/chainparams.cpp
📚 Learning: 2025-07-15T14:53:04.819Z
Learnt from: knst
Repo: dashpay/dash PR: 6691
File: src/test/llmq_params_tests.cpp:148-151
Timestamp: 2025-07-15T14:53:04.819Z
Learning: In the Dash Core LLMQ implementation, signingActiveQuorumCount is never 0 in the actual parameters defined in params.h, making division by zero scenarios unrealistic in the max_cycles() function.
Applied to files:
src/llmq/utils.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/rpc/quorums.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/quorumsman.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/governance/**/*.{cpp,h} : Governance implementation must support governance objects (proposals, triggers, superblock management) and on-chain voting with tallying
Applied to files:
src/governance/governance.cppsrc/governance/classes.cpp
📚 Learning: 2025-10-03T11:30:10.766Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6838
File: src/governance/signing.cpp:232-242
Timestamp: 2025-10-03T11:30:10.766Z
Learning: The Dash codebase dropped C++17 support in PR #6380 and now requires C++20 or later, as configured in configure.ac. C++20 features, including std::ranges algorithms like std::ranges::any_of, are appropriate and preferred where they improve code clarity.
Applied to files:
src/governance/governance.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/**/*.{cpp,h,hpp,cc} : Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1
Applied to files:
src/governance/governance.cpp
📚 Learning: 2025-06-09T16:43:20.996Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6718
File: test/functional/test_framework/test_framework.py:2102-2102
Timestamp: 2025-06-09T16:43:20.996Z
Learning: In the test framework consolidation PR (#6718), user kwvg prefers to limit functional changes to those directly related to MasternodeInfo, avoiding scope creep even for minor improvements like error handling consistency.
Applied to files:
src/governance/governance.cppsrc/test/block_reward_reallocation_tests.cppsrc/rpc/mempool.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{masternode,evo,llmq,governance,coinjoin}/**/*.{cpp,h} : Use Dash-specific database implementations: CFlatDB for persistent storage (MasternodeMetaStore, GovernanceStore, SporkStore, NetFulfilledRequestStore) and CDBWrapper extensions for Evolution/DKG/InstantSend/Quorum/RecoveredSigs data
Applied to files:
src/governance/governance.cppsrc/evo/cbtx.cppsrc/coinjoin/server.cppsrc/llmq/quorums.cppsrc/llmq/dkgsessionmgr.cppsrc/spork.cppsrc/evo/deterministicmns.cppsrc/test/block_reward_reallocation_tests.cppsrc/rpc/mempool.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/instantsend/signing.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/node/chainstate.{cpp,h} : Chainstate initialization must be separated into dedicated src/node/chainstate.* files
Applied to files:
src/governance/governance.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/evo/deterministicmns.cppsrc/test/block_reward_reallocation_tests.cppsrc/chainparams.cppsrc/rpc/mempool.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/instantsend/signing.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{validation,txmempool}/**/*.{cpp,h} : Block validation and mempool handling must use extensions to Bitcoin Core mechanisms for special transaction validation and enhanced transaction relay
Applied to files:
src/rpc/rawtransaction.cppsrc/governance/classes.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/masternode/payments.cppsrc/test/block_reward_reallocation_tests.cppsrc/rpc/mempool.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/instantsend/signing.cpp
📚 Learning: 2025-08-08T07:01:47.332Z
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.
Applied to files:
src/rpc/rawtransaction.cppsrc/test/block_reward_reallocation_tests.cppsrc/rpc/mempool.cpp
📚 Learning: 2025-10-02T18:29:54.756Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6840
File: src/net_processing.cpp:2882-2886
Timestamp: 2025-10-02T18:29:54.756Z
Learning: Across net_processing.cpp, once LLMQContext (m_llmq_ctx) is asserted non-null, its subcomponents (e.g., isman, qdkgsman, quorum_block_processor) are treated as initialized and used without extra null checks.
Applied to files:
src/rpc/rawtransaction.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsession.cppsrc/llmq/quorums.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/quorumsman.cppsrc/active/dkgsession.cppsrc/active/quorums.cppsrc/chainparams.cppsrc/rpc/mempool.cppsrc/llmq/options.cpp
📚 Learning: 2025-01-02T21:50:00.967Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6504
File: src/llmq/context.cpp:42-43
Timestamp: 2025-01-02T21:50:00.967Z
Learning: LLMQContext manages concurrency for the `CInstantSendManager`. Previously, this was handled globally; now it's handled as a class member in `LLMQContext`, but the concurrency control remains consistent.
Applied to files:
src/rpc/rawtransaction.cppsrc/rpc/mempool.cpp
📚 Learning: 2025-11-04T18:23:28.175Z
Learnt from: UdjinM6
Repo: dashpay/dash PR: 6933
File: src/governance/classes.cpp:147-154
Timestamp: 2025-11-04T18:23:28.175Z
Learning: In src/governance/classes.cpp, CSuperblock::GetPaymentsLimit intentionally uses synthetic difficulty constants (nBits = 1 for mainnet, powLimit for networks with min difficulty) and simple height-based V20 activation checks instead of actual chain block data. This is by design because superblocks themselves are "synthetic" governance payment blocks, not regular mined blocks.
Applied to files:
src/governance/classes.cppsrc/masternode/payments.cppsrc/test/block_reward_reallocation_tests.cppsrc/chainparams.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{validation,consensus,net_processing}/**/*.{cpp,h} : ValidationInterface callbacks must be used for event-driven architecture to coordinate subsystems during block/transaction processing
Applied to files:
src/governance/classes.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/test/block_reward_reallocation_tests.cppsrc/rpc/mempool.cppsrc/coinjoin/coinjoin.cppsrc/instantsend/signing.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/evo/**/*.{cpp,h} : Special transactions use payload serialization routines defined in src/evo/specialtx.h and must include appropriate special transaction types (ProRegTx, ProUpServTx, ProUpRegTx, ProUpRevTx)
Applied to files:
src/governance/classes.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/evo/simplifiedmns.hsrc/test/block_reward_reallocation_tests.cpp
📚 Learning: 2025-10-25T07:08:51.918Z
Learnt from: knst
Repo: dashpay/dash PR: 6916
File: src/univalue/include/univalue.h:81-88
Timestamp: 2025-10-25T07:08:51.918Z
Learning: The univalue library (in src/univalue/) is no longer a vendored external dependency but is now part of the Bitcoin Core codebase and can be modified as needed during backports.
Applied to files:
src/governance/classes.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{masternode,llmq,evo,coinjoin,governance}/**/*.{cpp,h} : Use unordered_lru_cache for efficient caching with LRU eviction in Dash-specific data structures
Applied to files:
src/evo/cbtx.cppsrc/coinjoin/server.cppsrc/masternode/payments.cppsrc/llmq/dkgsessionmgr.cpp
📚 Learning: 2025-11-13T20:02:55.480Z
Learnt from: UdjinM6
Repo: dashpay/dash PR: 6969
File: src/evo/deterministicmns.h:441-479
Timestamp: 2025-11-13T20:02:55.480Z
Learning: In `src/evo/deterministicmns.h`, the `internalId` field in `CDeterministicMN` and the `mnInternalIdMap` in `CDeterministicMNList` are non-deterministic and used only for internal bookkeeping and efficient lookups. Different nodes can assign different internalIds to the same masternode depending on their sync history. Methods like `IsEqual()` intentionally ignore internalId mappings and only compare consensus-critical deterministic fields (proTxHash, collateral, state, etc.).
Applied to files:
src/coinjoin/server.cppsrc/llmq/commitment.cppsrc/evo/deterministicmns.cppsrc/test/block_reward_reallocation_tests.cppsrc/llmq/debug.cpp
📚 Learning: 2025-01-07T18:50:44.838Z
Learnt from: knst
Repo: dashpay/dash PR: 6511
File: src/evo/deterministicmns.cpp:1369-1373
Timestamp: 2025-01-07T18:50:44.838Z
Learning: The functions `MigrateDBIfNeeded` and `MigrateDBIfNeeded2` in `src/evo/deterministicmns.cpp` are temporary and will be removed in a future version. Refactoring suggestions for these functions should be avoided.
Applied to files:
src/coinjoin/server.cppsrc/llmq/quorums.cppsrc/evo/deterministicmns.cpp
📚 Learning: 2025-11-25T10:53:37.523Z
Learnt from: knst
Repo: dashpay/dash PR: 7008
File: src/masternode/sync.h:17-18
Timestamp: 2025-11-25T10:53:37.523Z
Learning: The file src/masternode/sync.h containing `CMasternodeSync` is misnamed and misplaced—it has nothing to do with "masternode" functionality. It should eventually be renamed to `NodeSyncing` or `NodeSyncStatus` and moved to src/node/sync.h as a future refactoring.
Applied to files:
src/coinjoin/server.cppsrc/masternode/payments.cppsrc/instantsend/signing.cpp
📚 Learning: 2025-08-19T14:57:31.801Z
Learnt from: knst
Repo: dashpay/dash PR: 6692
File: src/llmq/blockprocessor.cpp:217-224
Timestamp: 2025-08-19T14:57:31.801Z
Learning: In PR #6692, knst acknowledged a null pointer dereference issue in ProcessBlock() method where LookupBlockIndex may return nullptr but is passed to gsl::not_null, and created follow-up PR #6789 to address it, consistent with avoiding scope creep in performance-focused PRs.
Applied to files:
src/llmq/blockprocessor.cppsrc/test/block_reward_reallocation_tests.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/wallet/**/*.{cpp,h} : Wallet implementation must use Berkeley DB and SQLite
Applied to files:
src/llmq/blockprocessor.cppsrc/rpc/mempool.cpp
📚 Learning: 2024-12-29T17:43:41.755Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6504
File: src/llmq/quorums.cpp:224-224
Timestamp: 2024-12-29T17:43:41.755Z
Learning: The `CQuorumManager` is fully initialized by `LLMQContext`, addressing any concerns about the manager’s initialization sequence.
Applied to files:
src/llmq/dkgsessionmgr.cppsrc/llmq/quorumsman.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{test,wallet/test}/**/*.{cpp,h} : Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework
Applied to files:
src/test/block_reward_reallocation_tests.cppsrc/test/llmq_dkg_tests.cpp
📚 Learning: 2025-01-14T08:37:16.955Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6530
File: src/validation.cpp:360-362
Timestamp: 2025-01-14T08:37:16.955Z
Learning: The UpdateTransactionsFromBlock() method in txmempool.cpp takes parameters in the order: vHashUpdate, ancestor_size_limit, ancestor_count_limit. The size limit comes before the count limit.
Applied to files:
src/test/block_reward_reallocation_tests.cpp
📚 Learning: 2025-11-25T10:53:37.523Z
Learnt from: knst
Repo: dashpay/dash PR: 7008
File: src/masternode/sync.h:17-18
Timestamp: 2025-11-25T10:53:37.523Z
Learning: In Dash Core, `DEFAULT_SYNC_MEMPOOL` belongs with node synchronization logic (currently in src/masternode/sync.h) rather than with validation logic in src/validation.h, even though other mempool-related constants are in validation.h. The constant is conceptually tied to sync functionality, not validation.
Applied to files:
src/rpc/mempool.cppsrc/coinjoin/coinjoin.cpp
📚 Learning: 2025-06-06T11:53:09.094Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6665
File: src/evo/providertx.h:82-82
Timestamp: 2025-06-06T11:53:09.094Z
Learning: In ProTx serialization code (SERIALIZE_METHODS), version checks should use hardcoded maximum flags (/*is_basic_scheme_active=*/true, /*is_extended_addr=*/true) rather than deployment-based flags. This is because serialization code should be able to deserialize any structurally valid ProTx up to the maximum version the code knows how to handle, regardless of current consensus validity. Validation code, not serialization code, is responsible for checking whether a ProTx version is consensus-valid based on deployment status.
Applied to files:
src/rpc/mempool.cpp
📚 Learning: 2025-02-06T14:34:30.466Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Applied to files:
src/rpc/mempool.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/instantsend/signing.cpp
📚 Learning: 2025-10-13T12:37:12.357Z
Learnt from: knst
Repo: dashpay/dash PR: 6883
File: src/rpc/rawtransaction.cpp:1088-1125
Timestamp: 2025-10-13T12:37:12.357Z
Learning: In backport pull requests (especially from Bitcoin Core), treat "moved" or refactored code as out-of-scope for content-level review. Focus validation on verifying that code is moved correctly: no fields added, no fields removed, no fields reordered, and no unexpected changes beyond whitespace adjustments. Pre-existing issues in the upstream code should be preserved to maintain fidelity to the original implementation.
Applied to files:
src/rpc/mempool.cpp
📚 Learning: 2025-10-25T07:08:51.918Z
Learnt from: knst
Repo: dashpay/dash PR: 6916
File: src/univalue/include/univalue.h:81-88
Timestamp: 2025-10-25T07:08:51.918Z
Learning: For backport PRs from bitcoin/bitcoin, bitcoin-core/gui, etc., backported changes should match the original upstream PRs even if they appear strange, modify vendored code, or seem to violate coding guidelines. Still flag genuine issues like bugs, undefined behavior, crashes, compilation errors, or linter failures.
Applied to files:
src/rpc/mempool.cpp
📚 Learning: 2025-11-04T18:24:27.241Z
Learnt from: UdjinM6
Repo: dashpay/dash PR: 6933
File: src/llmq/utils.cpp:284-298
Timestamp: 2025-11-04T18:24:27.241Z
Learning: In consensus-critical code (such as quorum formation, block validation, or deployment activation logic), do not suggest changes to the logic itself even if the implementation appears theoretically incorrect or off-by-one. Consensus rules, once deployed on the Dash network, must be preserved exactly to avoid network forks. Refactoring PRs should maintain perfect behavioral equivalence. Only suggest logic changes if explicitly accompanied by a DIP (Dash Improvement Proposal) or if the maintainer indicates the consensus rule needs to be changed with appropriate activation logic.
Applied to files:
src/rpc/mempool.cpp
📚 Learning: 2025-07-29T14:33:01.040Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6761
File: src/wallet/wallet.cpp:0-0
Timestamp: 2025-07-29T14:33:01.040Z
Learning: In refactoring PRs like #6761, kwvg acknowledges code safety improvements (like null pointer checks and unused parameter warnings) but prefers to defer them to follow-up PRs to maintain focus on the primary refactoring objectives, avoiding scope creep.
Applied to files:
src/rpc/mempool.cpp
📚 Learning: 2025-07-29T14:32:48.369Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6761
File: src/chainlock/signing.cpp:247-250
Timestamp: 2025-07-29T14:32:48.369Z
Learning: In PR #6761, kwvg acknowledged a null pointer check issue in ChainLockSigner::Cleanup() method but deferred it to follow-up, consistent with the pattern of avoiding scope creep in refactoring PRs.
Applied to files:
src/rpc/mempool.cppsrc/instantsend/signing.cpp
📚 Learning: 2025-10-05T20:38:28.457Z
Learnt from: knst
Repo: dashpay/dash PR: 6871
File: contrib/guix/libexec/build.sh:358-360
Timestamp: 2025-10-05T20:38:28.457Z
Learning: In the Dash repository, when backporting code from Bitcoin Core, typos and minor issues in comments should be kept as-is to reduce merge conflicts in future backports, even if they remain unfixed in Bitcoin Core's master branch.
Applied to files:
src/rpc/mempool.cpp
📚 Learning: 2025-07-23T09:30:34.631Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6761
File: src/chainlock/signing.h:5-6
Timestamp: 2025-07-23T09:30:34.631Z
Learning: Dash Core uses BITCOIN_ prefix for header guards as the standard convention, inherited from Bitcoin Core. Only a few BLS-specific files in src/bls/ use DASH_ prefix. The vast majority of files (385+) use BITCOIN_ prefix.
Applied to files:
src/bls/bls.h
📚 Learning: 2025-08-13T16:10:51.336Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6815
File: src/chainlock/clsig.cpp:27-30
Timestamp: 2025-08-13T16:10:51.336Z
Learning: The Dash codebase has explicit serialization support for std::string_view through template specializations in src/serialize.h (lines 976-987), allowing SerializeHash and other serialization functions to work directly with string_view without conversion to std::string.
Applied to files:
src/bls/bls.h
📚 Learning: 2025-05-10T00:54:30.887Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6629
File: src/evo/netinfo.h:248-256
Timestamp: 2025-05-10T00:54:30.887Z
Learning: The Dash codebase includes a specialization for serializing std::shared_ptr objects in src/serialize.h, which allows direct serialization of shared_ptr instances with stream operators.
Applied to files:
src/bls/bls.h
🧬 Code graph analysis (24)
src/coinjoin/common.h (2)
src/util/helpers.h (1)
util(13-22)src/node/interfaces.cpp (1)
GetStandardDenominations(500-503)
src/llmq/commitment.h (1)
src/util/helpers.h (2)
util(13-22)irange(25-28)
src/bench/bls_dkg.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/llmq/utils.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/rpc/rawtransaction.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/test/bls_tests.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/governance/classes.cpp (1)
src/util/std23.h (1)
fold_left(63-66)
src/evo/cbtx.cpp (1)
src/util/std23.h (1)
fold_left(63-66)
src/llmq/blockprocessor.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/llmq/commitment.cpp (2)
src/util/helpers.h (1)
irange(25-28)src/logging.h (1)
LogAcceptDebug(238-241)
src/llmq/dkgsession.cpp (2)
src/llmq/dkgsession.h (1)
type(244-253)src/util/helpers.h (1)
irange(25-28)
src/llmq/quorums.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/llmq/dkgsessionmgr.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/llmq/quorumsman.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/evo/deterministicmns.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/test/block_reward_reallocation_tests.cpp (2)
src/util/std23.h (1)
enumerate(81-90)src/util/helpers.h (1)
irange(25-28)
src/test/llmq_dkg_tests.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/active/dkgsession.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/active/quorums.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/llmq/debug.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/coinjoin/client.h (1)
src/util/std23.h (1)
ranges(31-101)
src/bls/bls.h (1)
src/util/std23.h (1)
ranges(31-101)
src/coinjoin/coinjoin.cpp (1)
src/coinjoin/coinjoin.h (2)
nTime(186-186)fTried(190-209)
src/instantsend/signing.cpp (1)
src/util/helpers.h (1)
irange(25-28)
🪛 Cppcheck (2.19.0)
src/llmq/utils.cpp
[error] 24-24: #error No known always_inline attribute for this platform.
(preprocessorErrorDirective)
src/governance/governance.cpp
[error] 22-22: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
[error] 24-24: #error No known always_inline attribute for this platform.
(preprocessorErrorDirective)
src/evo/cbtx.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/llmq/blockprocessor.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/llmq/commitment.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/llmq/dkgsession.cpp
[error] 24-24: #error No known always_inline attribute for this platform.
(preprocessorErrorDirective)
src/llmq/quorums.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/masternode/payments.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/llmq/dkgsessionmgr.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/spork.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/test/block_reward_reallocation_tests.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/coinjoin/client.cpp
[error] 24-24: #error No known always_inline attribute for this platform.
(preprocessorErrorDirective)
src/coinjoin/coinjoin.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/instantsend/signing.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/llmq/options.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: linux64_multiprocess-test / Test source
`ranges` was the polyfill for C++20 `std::ranges` but we've mixed it with our custom helper, `find_if_opt`, that should be in `util`. Let's retire most use and keep it minimal.
We are only migrating this overload to `std::views::iota` because it is assumed that min and max have the same underlying or compatible type, the `irange(max)` overload causes type issues because `0` needs to be statically cast, to keep it simple we will be introducing a small wrapper but not extending it to this case where it is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/coinjoin/coinjoin.cpp (1)
1-24: Fix clang-format diff (CI is failing).
GitHub Actions reports clang-format differences in this file; please run the repo’s formatting script and re-push.src/validation.cpp (1)
6020-6068: Avoid “no return” afterassert(false)in NDEBUG builds.
After theswitch,assert(false);compiles out underNDEBUG. Even if logically unreachable, it’s safer (and silences toolchain warnings) to add a return or an explicit unreachable helper.Proposed fix (minimal)
@@ default: throw std::runtime_error(strprintf("%s: Unknown LLMQ type %d", __func__, std23::to_underlying(llmqType))); } // Something wrong with conditions above, they are not consistent assert(false); + return false; }
🤖 Fix all issues with AI agents
In @src/coinjoin/coinjoin.cpp:
- Around line 7-12: The code uses std::ranges::all_of but only includes
<ranges>, which may rely on transitive includes; add the proper header by
including <algorithm> (or replace <ranges> with <algorithm> if <ranges> isn’t
otherwise needed) so that std::ranges::all_of is guaranteed to be declared; look
for the include block around the top of coinjoin.cpp where headers such as
<ranges> are present and add <algorithm> next to them.
In @src/util/std23.h:
- Around line 1-107: The file fails clang-format style checks; run the project's
formatting script (or clang-format) on src/util/std23.h and commit the changes.
Ensure formatting is applied consistently across the entire file, including the
to_underlying template, std23::ranges::contains, std23::ranges::fold_left, and
std23::ranges::views::enumerate definitions and surrounding namespace/brace
alignment so the diffs disappear.
🧹 Nitpick comments (2)
src/llmq/options.cpp (1)
8-9: Consider verifying if all new includes are necessary.The
util/helpers.hinclude is required forutil::find_if_optused at line 75. However,util/std23.hand<ranges>don't appear to be used in this file. The<string>include may have been transitively available before.If these headers are included for consistency across the refactoring or for future use, no action is needed.
Also applies to: 17-17, 19-19
src/evo/deterministicmns.h (1)
265-280: Optional: avoid potential sign-conversion warnings when returningsize_t.std::ranges::count_if(...)returns a (signed) difference type; some warning configs might complain about implicit conversion tosize_t.Proposed tweak (if CI/toolchain warns)
- return std::ranges::count_if(mnMap, [](const auto& p) { return !p.second->pdmnState->IsBanned(); }); + return static_cast<size_t>(std::ranges::count_if(mnMap, [](const auto& p) { return !p.second->pdmnState->IsBanned(); }));- return std::ranges::count_if(mnMap, [](const auto& p) { return p.second->nType == MnType::Evo; }); + return static_cast<size_t>(std::ranges::count_if(mnMap, [](const auto& p) { return p.second->nType == MnType::Evo; }));- return std::ranges::count_if(mnMap, [](const auto& p) { + return static_cast<size_t>(std::ranges::count_if(mnMap, [](const auto& p) { return p.second->nType == MnType::Evo && !p.second->pdmnState->IsBanned(); - }); + }));
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (58)
src/Makefile.amsrc/active/dkgsession.cppsrc/active/quorums.cppsrc/bench/bls_dkg.cppsrc/bls/bls.hsrc/bls/bls_worker.cppsrc/chainparams.cppsrc/coinjoin/client.cppsrc/coinjoin/client.hsrc/coinjoin/coinjoin.cppsrc/coinjoin/coinjoin.hsrc/coinjoin/common.hsrc/coinjoin/server.cppsrc/evo/cbtx.cppsrc/evo/deterministicmns.cppsrc/evo/deterministicmns.hsrc/evo/dmnstate.hsrc/evo/mnhftx.cppsrc/evo/simplifiedmns.hsrc/evo/specialtxman.cppsrc/governance/classes.cppsrc/governance/governance.cppsrc/governance/signing.cppsrc/instantsend/signing.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/commitment.hsrc/llmq/debug.cppsrc/llmq/dkgsession.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/dkgsessionmgr.hsrc/llmq/observer/quorums.cppsrc/llmq/options.cppsrc/llmq/quorums.cppsrc/llmq/quorumsman.cppsrc/llmq/signing.cppsrc/llmq/signing_shares.cppsrc/llmq/signing_shares.hsrc/llmq/snapshot.hsrc/llmq/utils.cppsrc/masternode/payments.cppsrc/masternode/utils.cppsrc/qt/guiutil_font.cppsrc/rpc/mempool.cppsrc/rpc/quorums.cppsrc/rpc/rawtransaction.cppsrc/spork.cppsrc/test/block_reward_reallocation_tests.cppsrc/test/bls_tests.cppsrc/test/evo_netinfo_tests.cppsrc/test/llmq_dkg_tests.cppsrc/util/helpers.hsrc/util/irange.hsrc/util/pointer.hsrc/util/ranges.hsrc/util/std23.hsrc/validation.cpptest/util/data/non-backported.txt
💤 Files with no reviewable changes (4)
- src/util/ranges.h
- src/util/irange.h
- src/util/pointer.h
- src/evo/specialtxman.cpp
🚧 Files skipped from review as they are similar to previous changes (18)
- src/evo/dmnstate.h
- src/llmq/dkgsessionmgr.h
- src/llmq/signing.cpp
- src/llmq/signing_shares.h
- src/coinjoin/common.h
- src/llmq/quorumsman.cpp
- src/evo/simplifiedmns.h
- src/rpc/rawtransaction.cpp
- src/llmq/observer/quorums.cpp
- src/evo/deterministicmns.cpp
- src/rpc/quorums.cpp
- src/test/bls_tests.cpp
- src/coinjoin/coinjoin.h
- src/bls/bls_worker.cpp
- src/bench/bls_dkg.cpp
- src/coinjoin/client.h
- src/governance/signing.cpp
- src/llmq/debug.cpp
🧰 Additional context used
📓 Path-based instructions (11)
src/**/*.{cpp,h,hpp,cc}
📄 CodeRabbit inference engine (CLAUDE.md)
Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1
Files:
src/masternode/utils.cppsrc/active/dkgsession.cppsrc/instantsend/signing.cppsrc/test/evo_netinfo_tests.cppsrc/test/block_reward_reallocation_tests.cppsrc/governance/classes.cppsrc/qt/guiutil_font.cppsrc/bls/bls.hsrc/llmq/commitment.hsrc/util/helpers.hsrc/llmq/snapshot.hsrc/chainparams.cppsrc/llmq/signing_shares.cppsrc/rpc/mempool.cppsrc/active/quorums.cppsrc/governance/governance.cppsrc/evo/deterministicmns.hsrc/llmq/utils.cppsrc/util/std23.hsrc/coinjoin/server.cppsrc/evo/mnhftx.cppsrc/validation.cppsrc/llmq/dkgsession.cppsrc/test/llmq_dkg_tests.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/options.cppsrc/llmq/quorums.cppsrc/masternode/payments.cppsrc/spork.cpp
src/{masternode,evo}/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Masternode lists must use immutable data structures (Immer library) for thread safety
Files:
src/masternode/utils.cppsrc/evo/deterministicmns.hsrc/evo/mnhftx.cppsrc/evo/cbtx.cppsrc/masternode/payments.cpp
src/{masternode,evo,llmq,governance,coinjoin}/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Use Dash-specific database implementations: CFlatDB for persistent storage (MasternodeMetaStore, GovernanceStore, SporkStore, NetFulfilledRequestStore) and CDBWrapper extensions for Evolution/DKG/InstantSend/Quorum/RecoveredSigs data
Files:
src/masternode/utils.cppsrc/governance/classes.cppsrc/llmq/commitment.hsrc/llmq/snapshot.hsrc/llmq/signing_shares.cppsrc/governance/governance.cppsrc/evo/deterministicmns.hsrc/llmq/utils.cppsrc/coinjoin/server.cppsrc/evo/mnhftx.cppsrc/llmq/dkgsession.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/options.cppsrc/llmq/quorums.cppsrc/masternode/payments.cpp
src/{masternode,llmq}/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
BLS integration must be used for cryptographic foundation of advanced masternode features
Files:
src/masternode/utils.cppsrc/llmq/commitment.hsrc/llmq/snapshot.hsrc/llmq/signing_shares.cppsrc/llmq/utils.cppsrc/llmq/dkgsession.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/options.cppsrc/llmq/quorums.cppsrc/masternode/payments.cpp
src/{masternode,llmq,evo,coinjoin,governance}/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Use unordered_lru_cache for efficient caching with LRU eviction in Dash-specific data structures
Files:
src/masternode/utils.cppsrc/governance/classes.cppsrc/llmq/commitment.hsrc/llmq/snapshot.hsrc/llmq/signing_shares.cppsrc/governance/governance.cppsrc/evo/deterministicmns.hsrc/llmq/utils.cppsrc/coinjoin/server.cppsrc/evo/mnhftx.cppsrc/llmq/dkgsession.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/options.cppsrc/llmq/quorums.cppsrc/masternode/payments.cpp
src/{test,wallet/test}/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework
Files:
src/test/evo_netinfo_tests.cppsrc/test/block_reward_reallocation_tests.cppsrc/test/llmq_dkg_tests.cpp
src/governance/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Governance implementation must support governance objects (proposals, triggers, superblock management) and on-chain voting with tallying
Files:
src/governance/classes.cppsrc/governance/governance.cpp
src/qt/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
GUI implementation in src/qt/ must use Qt 5
Files:
src/qt/guiutil_font.cpp
src/llmq/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
src/llmq/**/*.{cpp,h}: LLMQ quorums must support multiple configurations (50/60, 400/60, 400/85) for different services (ChainLocks, InstantSend, governance voting)
InstantSend implementation must provide distributed key generation for secure transaction locking with quorum consensus
ChainLocks implementation must prevent reorganizations and provide block finality through 51% attack prevention
Files:
src/llmq/commitment.hsrc/llmq/snapshot.hsrc/llmq/signing_shares.cppsrc/llmq/utils.cppsrc/llmq/dkgsession.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/options.cppsrc/llmq/quorums.cpp
src/evo/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
Special transactions use payload serialization routines defined in src/evo/specialtx.h and must include appropriate special transaction types (ProRegTx, ProUpServTx, ProUpRegTx, ProUpRevTx)
Files:
src/evo/deterministicmns.hsrc/evo/mnhftx.cppsrc/evo/cbtx.cpp
src/coinjoin/**/*.{cpp,h}
📄 CodeRabbit inference engine (CLAUDE.md)
CoinJoin implementation must use masternode-coordinated mixing sessions with uniform denomination outputs
Files:
src/coinjoin/server.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cpp
🧠 Learnings (55)
📓 Common learnings
Learnt from: kwvg
Repo: dashpay/dash PR: 6838
File: src/governance/signing.cpp:232-242
Timestamp: 2025-10-03T11:30:10.766Z
Learning: The Dash codebase dropped C++17 support in PR #6380 and now requires C++20 or later, as configured in configure.ac. C++20 features, including std::ranges algorithms like std::ranges::any_of, are appropriate and preferred where they improve code clarity.
Learnt from: kwvg
Repo: dashpay/dash PR: 6761
File: src/wallet/wallet.cpp:0-0
Timestamp: 2025-07-29T14:33:01.040Z
Learning: In refactoring PRs like #6761, kwvg acknowledges code safety improvements (like null pointer checks and unused parameter warnings) but prefers to defer them to follow-up PRs to maintain focus on the primary refactoring objectives, avoiding scope creep.
Learnt from: kwvg
Repo: dashpay/dash PR: 6718
File: test/functional/test_framework/test_framework.py:2102-2102
Timestamp: 2025-06-09T16:43:20.996Z
Learning: In the test framework consolidation PR (#6718), user kwvg prefers to limit functional changes to those directly related to MasternodeInfo, avoiding scope creep even for minor improvements like error handling consistency.
Learnt from: kwvg
Repo: dashpay/dash PR: 6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Learnt from: kwvg
Repo: dashpay/dash PR: 6761
File: src/chainlock/signing.cpp:15-250
Timestamp: 2025-07-23T09:28:32.783Z
Learning: In refactoring PRs like #6761, kwvg prefers to defer code formatting fixes to separate follow-up PRs when formatting is not the primary objective, to maintain focus on the structural changes and avoid scope creep.
Learnt from: knst
Repo: dashpay/dash PR: 6916
File: src/univalue/include/univalue.h:81-88
Timestamp: 2025-10-25T07:08:51.918Z
Learning: The univalue library (in src/univalue/) is no longer a vendored external dependency but is now part of the Bitcoin Core codebase and can be modified as needed during backports.
📚 Learning: 2025-12-01T18:13:21.314Z
Learnt from: PastaPastaPasta
Repo: dashpay/dash PR: 7018
File: test/lint/lint-github-actions.py:1-9
Timestamp: 2025-12-01T18:13:21.314Z
Learning: In the Dash repository, the file test/util/data/non-backported.txt should only include C++ files (.cpp or .h) because it is used for running clang-format. Other file types (such as Python files, .ui files, etc.) should not be added to this list.
Applied to files:
test/util/data/non-backported.txt
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{test,wallet/test}/**/*.{cpp,h} : Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework
Applied to files:
test/util/data/non-backported.txtsrc/test/evo_netinfo_tests.cppsrc/test/block_reward_reallocation_tests.cppsrc/test/llmq_dkg_tests.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{masternode,llmq,evo,coinjoin,governance}/**/*.{cpp,h} : Use unordered_lru_cache for efficient caching with LRU eviction in Dash-specific data structures
Applied to files:
test/util/data/non-backported.txtsrc/masternode/utils.cppsrc/llmq/snapshot.hsrc/coinjoin/server.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{validation,txmempool}/**/*.{cpp,h} : Block validation and mempool handling must use extensions to Bitcoin Core mechanisms for special transaction validation and enhanced transaction relay
Applied to files:
test/util/data/non-backported.txtsrc/instantsend/signing.cppsrc/test/block_reward_reallocation_tests.cppsrc/governance/classes.cppsrc/rpc/mempool.cppsrc/evo/mnhftx.cppsrc/validation.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/governance/**/*.{cpp,h} : Governance implementation must support governance objects (proposals, triggers, superblock management) and on-chain voting with tallying
Applied to files:
test/util/data/non-backported.txtsrc/governance/classes.cppsrc/governance/governance.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{masternode,llmq}/**/*.{cpp,h} : BLS integration must be used for cryptographic foundation of advanced masternode features
Applied to files:
test/util/data/non-backported.txtsrc/masternode/utils.cppsrc/active/dkgsession.cppsrc/instantsend/signing.cppsrc/test/block_reward_reallocation_tests.cppsrc/bls/bls.hsrc/llmq/commitment.hsrc/llmq/snapshot.hsrc/chainparams.cppsrc/llmq/signing_shares.cppsrc/rpc/mempool.cppsrc/active/quorums.cppsrc/llmq/utils.cppsrc/coinjoin/server.cppsrc/evo/mnhftx.cppsrc/validation.cppsrc/llmq/dkgsession.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/options.cppsrc/llmq/quorums.cppsrc/masternode/payments.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/coinjoin/**/*.{cpp,h} : CoinJoin implementation must use masternode-coordinated mixing sessions with uniform denomination outputs
Applied to files:
test/util/data/non-backported.txtsrc/masternode/utils.cppsrc/active/dkgsession.cppsrc/instantsend/signing.cppsrc/test/block_reward_reallocation_tests.cppsrc/governance/classes.cppsrc/active/quorums.cppsrc/llmq/utils.cppsrc/coinjoin/server.cppsrc/validation.cppsrc/llmq/dkgsession.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/llmq/dkgsessionmgr.cppsrc/masternode/payments.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{masternode,evo,llmq,governance,coinjoin}/**/*.{cpp,h} : Use Dash-specific database implementations: CFlatDB for persistent storage (MasternodeMetaStore, GovernanceStore, SporkStore, NetFulfilledRequestStore) and CDBWrapper extensions for Evolution/DKG/InstantSend/Quorum/RecoveredSigs data
Applied to files:
test/util/data/non-backported.txtsrc/instantsend/signing.cppsrc/test/block_reward_reallocation_tests.cppsrc/governance/governance.cppsrc/coinjoin/server.cppsrc/validation.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/evo/cbtx.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/quorums.cppsrc/spork.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/wallet/**/*.{cpp,h} : Wallet implementation must use Berkeley DB and SQLite
Applied to files:
test/util/data/non-backported.txtsrc/rpc/mempool.cppsrc/llmq/blockprocessor.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{crc32c,dashbls,gsl,immer,leveldb,minisketch,secp256k1,univalue,crypto/{ctaes,x11}}/** : Do not make changes to vendored dependencies: src/{crc32c,dashbls,gsl,immer,leveldb,minisketch,secp256k1,univalue} or src/crypto/{ctaes,x11}
Applied to files:
test/util/data/non-backported.txt
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/**/*.{cpp,h,hpp,cc} : Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1
Applied to files:
test/util/data/non-backported.txtsrc/governance/governance.cpp
📚 Learning: 2025-11-14T23:17:08.495Z
Learnt from: PastaPastaPasta
Repo: dashpay/dash PR: 6976
File: src/stacktraces.cpp:475-482
Timestamp: 2025-11-14T23:17:08.495Z
Learning: In C++ code reviews, always check for opportunities to use standard algorithms (std::any_of, std::all_of, std::none_of, std::find_if, std::transform, std::for_each, etc.) instead of manual for-loops, especially when the loop body performs simple checks, transformations, or accumulations.
Applied to files:
src/masternode/utils.cppsrc/llmq/dkgsession.cppsrc/llmq/quorums.cpp
📚 Learning: 2025-10-03T11:30:10.766Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6838
File: src/governance/signing.cpp:232-242
Timestamp: 2025-10-03T11:30:10.766Z
Learning: The Dash codebase dropped C++17 support in PR #6380 and now requires C++20 or later, as configured in configure.ac. C++20 features, including std::ranges algorithms like std::ranges::any_of, are appropriate and preferred where they improve code clarity.
Applied to files:
src/masternode/utils.cppsrc/governance/governance.cpp
📚 Learning: 2025-06-09T16:43:20.996Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6718
File: test/functional/test_framework/test_framework.py:2102-2102
Timestamp: 2025-06-09T16:43:20.996Z
Learning: In the test framework consolidation PR (#6718), user kwvg prefers to limit functional changes to those directly related to MasternodeInfo, avoiding scope creep even for minor improvements like error handling consistency.
Applied to files:
src/masternode/utils.cppsrc/test/block_reward_reallocation_tests.cppsrc/rpc/mempool.cppsrc/governance/governance.cppsrc/validation.cppsrc/llmq/dkgsession.cppsrc/masternode/payments.cpp
📚 Learning: 2025-11-04T18:24:27.241Z
Learnt from: UdjinM6
Repo: dashpay/dash PR: 6933
File: src/llmq/utils.cpp:284-298
Timestamp: 2025-11-04T18:24:27.241Z
Learning: In consensus-critical code (such as quorum formation, block validation, or deployment activation logic), do not suggest changes to the logic itself even if the implementation appears theoretically incorrect or off-by-one. Consensus rules, once deployed on the Dash network, must be preserved exactly to avoid network forks. Refactoring PRs should maintain perfect behavioral equivalence. Only suggest logic changes if explicitly accompanied by a DIP (Dash Improvement Proposal) or if the maintainer indicates the consensus rule needs to be changed with appropriate activation logic.
Applied to files:
src/masternode/utils.cppsrc/rpc/mempool.cppsrc/governance/governance.cpp
📚 Learning: 2025-07-29T14:32:48.369Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6761
File: src/chainlock/signing.cpp:247-250
Timestamp: 2025-07-29T14:32:48.369Z
Learning: In PR #6761, kwvg acknowledged a null pointer check issue in ChainLockSigner::Cleanup() method but deferred it to follow-up, consistent with the pattern of avoiding scope creep in refactoring PRs.
Applied to files:
src/masternode/utils.cppsrc/instantsend/signing.cppsrc/rpc/mempool.cppsrc/llmq/dkgsession.cpp
📚 Learning: 2025-10-13T12:37:12.357Z
Learnt from: knst
Repo: dashpay/dash PR: 6883
File: src/rpc/rawtransaction.cpp:1088-1125
Timestamp: 2025-10-13T12:37:12.357Z
Learning: In backport pull requests (especially from Bitcoin Core), treat "moved" or refactored code as out-of-scope for content-level review. Focus validation on verifying that code is moved correctly: no fields added, no fields removed, no fields reordered, and no unexpected changes beyond whitespace adjustments. Pre-existing issues in the upstream code should be preserved to maintain fidelity to the original implementation.
Applied to files:
src/masternode/utils.cppsrc/rpc/mempool.cpp
📚 Learning: 2025-10-05T20:38:28.457Z
Learnt from: knst
Repo: dashpay/dash PR: 6871
File: contrib/guix/libexec/build.sh:358-360
Timestamp: 2025-10-05T20:38:28.457Z
Learning: In the Dash repository, when backporting code from Bitcoin Core, typos and minor issues in comments should be kept as-is to reduce merge conflicts in future backports, even if they remain unfixed in Bitcoin Core's master branch.
Applied to files:
src/masternode/utils.cppsrc/rpc/mempool.cpp
📚 Learning: 2025-07-29T14:33:01.040Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6761
File: src/wallet/wallet.cpp:0-0
Timestamp: 2025-07-29T14:33:01.040Z
Learning: In refactoring PRs like #6761, kwvg acknowledges code safety improvements (like null pointer checks and unused parameter warnings) but prefers to defer them to follow-up PRs to maintain focus on the primary refactoring objectives, avoiding scope creep.
Applied to files:
src/masternode/utils.cppsrc/rpc/mempool.cpp
📚 Learning: 2025-08-19T14:57:31.801Z
Learnt from: knst
Repo: dashpay/dash PR: 6692
File: src/llmq/blockprocessor.cpp:217-224
Timestamp: 2025-08-19T14:57:31.801Z
Learning: In PR #6692, knst acknowledged a null pointer dereference issue in ProcessBlock() method where LookupBlockIndex may return nullptr but is passed to gsl::not_null, and created follow-up PR #6789 to address it, consistent with avoiding scope creep in performance-focused PRs.
Applied to files:
src/masternode/utils.cppsrc/test/block_reward_reallocation_tests.cppsrc/llmq/blockprocessor.cpp
📚 Learning: 2025-11-13T20:02:55.480Z
Learnt from: UdjinM6
Repo: dashpay/dash PR: 6969
File: src/evo/deterministicmns.h:441-479
Timestamp: 2025-11-13T20:02:55.480Z
Learning: In `src/evo/deterministicmns.h`, the `internalId` field in `CDeterministicMN` and the `mnInternalIdMap` in `CDeterministicMNList` are non-deterministic and used only for internal bookkeeping and efficient lookups. Different nodes can assign different internalIds to the same masternode depending on their sync history. Methods like `IsEqual()` intentionally ignore internalId mappings and only compare consensus-critical deterministic fields (proTxHash, collateral, state, etc.).
Applied to files:
src/masternode/utils.cppsrc/test/block_reward_reallocation_tests.cppsrc/evo/deterministicmns.hsrc/coinjoin/server.cppsrc/llmq/commitment.cpp
📚 Learning: 2025-11-25T10:53:37.523Z
Learnt from: knst
Repo: dashpay/dash PR: 7008
File: src/masternode/sync.h:17-18
Timestamp: 2025-11-25T10:53:37.523Z
Learning: The file src/masternode/sync.h containing `CMasternodeSync` is misnamed and misplaced—it has nothing to do with "masternode" functionality. It should eventually be renamed to `NodeSyncing` or `NodeSyncStatus` and moved to src/node/sync.h as a future refactoring.
Applied to files:
src/masternode/utils.cppsrc/instantsend/signing.cppsrc/coinjoin/server.cppsrc/masternode/payments.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/llmq/**/*.{cpp,h} : LLMQ quorums must support multiple configurations (50/60, 400/60, 400/85) for different services (ChainLocks, InstantSend, governance voting)
Applied to files:
src/active/dkgsession.cppsrc/instantsend/signing.cppsrc/llmq/commitment.hsrc/llmq/snapshot.hsrc/chainparams.cppsrc/llmq/signing_shares.cppsrc/rpc/mempool.cppsrc/active/quorums.cppsrc/governance/governance.cppsrc/llmq/utils.cppsrc/evo/mnhftx.cppsrc/validation.cppsrc/llmq/dkgsession.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/options.cppsrc/llmq/quorums.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/llmq/**/*.{cpp,h} : InstantSend implementation must provide distributed key generation for secure transaction locking with quorum consensus
Applied to files:
src/active/dkgsession.cppsrc/instantsend/signing.cppsrc/llmq/commitment.hsrc/llmq/snapshot.hsrc/chainparams.cppsrc/llmq/signing_shares.cppsrc/rpc/mempool.cppsrc/active/quorums.cppsrc/llmq/utils.cppsrc/evo/mnhftx.cppsrc/validation.cppsrc/llmq/dkgsession.cppsrc/test/llmq_dkg_tests.cppsrc/coinjoin/coinjoin.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/options.cppsrc/llmq/quorums.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/llmq/**/*.{cpp,h} : ChainLocks implementation must prevent reorganizations and provide block finality through 51% attack prevention
Applied to files:
src/active/dkgsession.cppsrc/instantsend/signing.cppsrc/llmq/commitment.hsrc/llmq/snapshot.hsrc/chainparams.cppsrc/llmq/signing_shares.cppsrc/rpc/mempool.cppsrc/active/quorums.cppsrc/llmq/utils.cppsrc/evo/mnhftx.cppsrc/validation.cppsrc/llmq/dkgsession.cppsrc/coinjoin/coinjoin.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/options.cppsrc/llmq/quorums.cpp
📚 Learning: 2025-10-02T18:29:54.756Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6840
File: src/net_processing.cpp:2882-2886
Timestamp: 2025-10-02T18:29:54.756Z
Learning: Across net_processing.cpp, once LLMQContext (m_llmq_ctx) is asserted non-null, its subcomponents (e.g., isman, qdkgsman, quorum_block_processor) are treated as initialized and used without extra null checks.
Applied to files:
src/active/dkgsession.cppsrc/chainparams.cppsrc/rpc/mempool.cppsrc/active/quorums.cppsrc/validation.cppsrc/llmq/dkgsession.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cppsrc/llmq/options.cppsrc/llmq/quorums.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/node/chainstate.{cpp,h} : Chainstate initialization must be separated into dedicated src/node/chainstate.* files
Applied to files:
src/instantsend/signing.cppsrc/test/block_reward_reallocation_tests.cppsrc/chainparams.cppsrc/rpc/mempool.cppsrc/governance/governance.cppsrc/evo/mnhftx.cppsrc/coinjoin/client.cppsrc/coinjoin/coinjoin.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{validation,consensus,net_processing}/**/*.{cpp,h} : ValidationInterface callbacks must be used for event-driven architecture to coordinate subsystems during block/transaction processing
Applied to files:
src/instantsend/signing.cppsrc/test/block_reward_reallocation_tests.cppsrc/governance/classes.cppsrc/rpc/mempool.cppsrc/coinjoin/coinjoin.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cpp
📚 Learning: 2025-10-28T18:36:40.263Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6923
File: src/test/util/setup_common.cpp:235-251
Timestamp: 2025-10-28T18:36:40.263Z
Learning: In `src/test/util/setup_common.cpp`, the `CEvoDB` instance in `BasicTestingSetup` is constructed with `.memory = true` flag (memory-only mode), so it does not create file handles on disk. This makes the destructor teardown order safe even if `fs::remove_all(m_path_root)` is called before `m_node.evodb.reset()`.
Applied to files:
src/test/evo_netinfo_tests.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/evo/**/*.{cpp,h} : Special transactions use payload serialization routines defined in src/evo/specialtx.h and must include appropriate special transaction types (ProRegTx, ProUpServTx, ProUpRegTx, ProUpRevTx)
Applied to files:
src/test/block_reward_reallocation_tests.cppsrc/governance/classes.cppsrc/validation.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cpp
📚 Learning: 2025-08-08T07:01:47.332Z
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.
Applied to files:
src/test/block_reward_reallocation_tests.cppsrc/rpc/mempool.cppsrc/validation.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/evo/evodb/**/*.{cpp,h} : Evolution Database (CEvoDb) must handle masternode snapshots, quorum state, governance objects with efficient differential updates for masternode lists
Applied to files:
src/test/block_reward_reallocation_tests.cppsrc/llmq/snapshot.hsrc/active/quorums.cppsrc/governance/governance.cppsrc/llmq/utils.cppsrc/coinjoin/server.cppsrc/validation.cppsrc/evo/cbtx.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/quorums.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{masternode,evo}/**/*.{cpp,h} : Masternode lists must use immutable data structures (Immer library) for thread safety
Applied to files:
src/test/block_reward_reallocation_tests.cppsrc/llmq/utils.cppsrc/coinjoin/server.cppsrc/validation.cpp
📚 Learning: 2025-11-04T18:23:28.175Z
Learnt from: UdjinM6
Repo: dashpay/dash PR: 6933
File: src/governance/classes.cpp:147-154
Timestamp: 2025-11-04T18:23:28.175Z
Learning: In src/governance/classes.cpp, CSuperblock::GetPaymentsLimit intentionally uses synthetic difficulty constants (nBits = 1 for mainnet, powLimit for networks with min difficulty) and simple height-based V20 activation checks instead of actual chain block data. This is by design because superblocks themselves are "synthetic" governance payment blocks, not regular mined blocks.
Applied to files:
src/test/block_reward_reallocation_tests.cppsrc/governance/classes.cppsrc/chainparams.cppsrc/masternode/payments.cpp
📚 Learning: 2025-01-14T08:37:16.955Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6530
File: src/validation.cpp:360-362
Timestamp: 2025-01-14T08:37:16.955Z
Learning: The UpdateTransactionsFromBlock() method in txmempool.cpp takes parameters in the order: vHashUpdate, ancestor_size_limit, ancestor_count_limit. The size limit comes before the count limit.
Applied to files:
src/test/block_reward_reallocation_tests.cpp
📚 Learning: 2025-10-25T07:08:51.918Z
Learnt from: knst
Repo: dashpay/dash PR: 6916
File: src/univalue/include/univalue.h:81-88
Timestamp: 2025-10-25T07:08:51.918Z
Learning: The univalue library (in src/univalue/) is no longer a vendored external dependency but is now part of the Bitcoin Core codebase and can be modified as needed during backports.
Applied to files:
src/governance/classes.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/qt/**/*.{cpp,h} : GUI implementation in src/qt/ must use Qt 5
Applied to files:
src/qt/guiutil_font.cpp
📚 Learning: 2025-12-22T15:42:51.679Z
Learnt from: kwvg
Repo: dashpay/dash PR: 7068
File: src/qt/guiutil_font.h:68-77
Timestamp: 2025-12-22T15:42:51.679Z
Learning: In the Dash Core Qt codebase (src/qt/guiutil_font.h), kwvg intentionally uses `assert()` in setter methods like `SetWeightBold` and `SetWeightNormal` to enforce invariants (e.g., `assert(m_weights.count(m_font))`). This fail-fast approach is preferred over defensive checks with fallbacks when an inconsistent state indicates a programming error that should be caught during development, rather than a runtime condition requiring graceful handling.
Applied to files:
src/qt/guiutil_font.cpp
📚 Learning: 2025-12-17T13:58:19.813Z
Learnt from: kwvg
Repo: dashpay/dash PR: 7072
File: src/qt/walletcontroller.cpp:520-528
Timestamp: 2025-12-17T13:58:19.813Z
Learning: In Dash Qt wallet code, prefer using existing Qt signals/slots (e.g., ShowProgress signals) for long-running operations instead of adding explicit QProgressDialog dialogs. This minimizes upstream deviations and simplifies backports. Apply this pattern to wallet-related Qt components (e.g., operations like rescanning) and rely on signal-based progress updates rather than bespoke dialogs.
Applied to files:
src/qt/guiutil_font.cpp
📚 Learning: 2025-07-23T09:30:34.631Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6761
File: src/chainlock/signing.h:5-6
Timestamp: 2025-07-23T09:30:34.631Z
Learning: Dash Core uses BITCOIN_ prefix for header guards as the standard convention, inherited from Bitcoin Core. Only a few BLS-specific files in src/bls/ use DASH_ prefix. The vast majority of files (385+) use BITCOIN_ prefix.
Applied to files:
src/bls/bls.h
📚 Learning: 2025-08-13T16:10:51.336Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6815
File: src/chainlock/clsig.cpp:27-30
Timestamp: 2025-08-13T16:10:51.336Z
Learning: The Dash codebase has explicit serialization support for std::string_view through template specializations in src/serialize.h (lines 976-987), allowing SerializeHash and other serialization functions to work directly with string_view without conversion to std::string.
Applied to files:
src/bls/bls.h
📚 Learning: 2025-05-10T00:54:30.887Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6629
File: src/evo/netinfo.h:248-256
Timestamp: 2025-05-10T00:54:30.887Z
Learning: The Dash codebase includes a specialization for serializing std::shared_ptr objects in src/serialize.h, which allows direct serialization of shared_ptr instances with stream operators.
Applied to files:
src/bls/bls.h
📚 Learning: 2025-12-22T15:42:48.595Z
Learnt from: kwvg
Repo: dashpay/dash PR: 7068
File: src/qt/guiutil_font.h:68-77
Timestamp: 2025-12-22T15:42:48.595Z
Learning: In C++/Qt codebases, use fail-fast asserts in setters to enforce invariants (e.g., ensuring internal maps contain necessary keys). Prefer assert() for programmer errors that should be caught in development and debugging, rather than defensive runtime checks with fallbacks. This helps catch invariant violations early during development. Apply to header and source files where invariant-driven state mutations occur, especially in setters like SetWeightBold/SetWeightNormal that assume established relationships or preconditions.
Applied to files:
src/bls/bls.hsrc/llmq/commitment.hsrc/util/helpers.hsrc/llmq/snapshot.hsrc/evo/deterministicmns.hsrc/util/std23.h
📚 Learning: 2025-08-19T15:08:00.835Z
Learnt from: knst
Repo: dashpay/dash PR: 6692
File: src/llmq/commitment.cpp:54-60
Timestamp: 2025-08-19T15:08:00.835Z
Learning: In Dash Core, llmq_params.size == 1 is used only for regtest environments, not on public networks, which significantly reduces the risk profile of code paths specific to single-member quorums.
Applied to files:
src/chainparams.cppsrc/llmq/signing_shares.cppsrc/active/quorums.cppsrc/llmq/utils.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cpp
📚 Learning: 2025-07-15T14:53:04.819Z
Learnt from: knst
Repo: dashpay/dash PR: 6691
File: src/test/llmq_params_tests.cpp:148-151
Timestamp: 2025-07-15T14:53:04.819Z
Learning: In the Dash Core LLMQ implementation, signingActiveQuorumCount is never 0 in the actual parameters defined in params.h, making division by zero scenarios unrealistic in the max_cycles() function.
Applied to files:
src/llmq/signing_shares.cppsrc/llmq/utils.cppsrc/llmq/blockprocessor.cppsrc/llmq/commitment.cppsrc/llmq/dkgsessionmgr.cpp
📚 Learning: 2025-11-25T10:53:37.523Z
Learnt from: knst
Repo: dashpay/dash PR: 7008
File: src/masternode/sync.h:17-18
Timestamp: 2025-11-25T10:53:37.523Z
Learning: In Dash Core, `DEFAULT_SYNC_MEMPOOL` belongs with node synchronization logic (currently in src/masternode/sync.h) rather than with validation logic in src/validation.h, even though other mempool-related constants are in validation.h. The constant is conceptually tied to sync functionality, not validation.
Applied to files:
src/rpc/mempool.cppsrc/coinjoin/coinjoin.cpp
📚 Learning: 2025-06-06T11:53:09.094Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6665
File: src/evo/providertx.h:82-82
Timestamp: 2025-06-06T11:53:09.094Z
Learning: In ProTx serialization code (SERIALIZE_METHODS), version checks should use hardcoded maximum flags (/*is_basic_scheme_active=*/true, /*is_extended_addr=*/true) rather than deployment-based flags. This is because serialization code should be able to deserialize any structurally valid ProTx up to the maximum version the code knows how to handle, regardless of current consensus validity. Validation code, not serialization code, is responsible for checking whether a ProTx version is consensus-valid based on deployment status.
Applied to files:
src/rpc/mempool.cpp
📚 Learning: 2025-02-06T14:34:30.466Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Applied to files:
src/rpc/mempool.cppsrc/coinjoin/coinjoin.cppsrc/masternode/payments.cpp
📚 Learning: 2025-10-25T07:08:51.918Z
Learnt from: knst
Repo: dashpay/dash PR: 6916
File: src/univalue/include/univalue.h:81-88
Timestamp: 2025-10-25T07:08:51.918Z
Learning: For backport PRs from bitcoin/bitcoin, bitcoin-core/gui, etc., backported changes should match the original upstream PRs even if they appear strange, modify vendored code, or seem to violate coding guidelines. Still flag genuine issues like bugs, undefined behavior, crashes, compilation errors, or linter failures.
Applied to files:
src/rpc/mempool.cpp
📚 Learning: 2025-01-02T21:50:00.967Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6504
File: src/llmq/context.cpp:42-43
Timestamp: 2025-01-02T21:50:00.967Z
Learning: LLMQContext manages concurrency for the `CInstantSendManager`. Previously, this was handled globally; now it's handled as a class member in `LLMQContext`, but the concurrency control remains consistent.
Applied to files:
src/rpc/mempool.cpp
📚 Learning: 2025-12-09T20:40:42.286Z
Learnt from: UdjinM6
Repo: dashpay/dash PR: 7051
File: test/functional/feature_governance_cl.py:159-170
Timestamp: 2025-12-09T20:40:42.286Z
Learning: In feature_governance_cl.py, before running governance cleanup with mockscheduler, the test must wait for the governance module to catch up with the latest block height by checking for the "CGovernanceManager::UpdatedBlockTip -- nCachedBlockHeight" log message. This synchronization ensures that subsequent cleanup operations see the correct block height and produce deterministic results (e.g., "CleanAndRemoveTriggers -- Removing trigger object" instead of "NOT marked for removal").
Applied to files:
src/governance/governance.cpp
📚 Learning: 2025-01-07T18:50:44.838Z
Learnt from: knst
Repo: dashpay/dash PR: 6511
File: src/evo/deterministicmns.cpp:1369-1373
Timestamp: 2025-01-07T18:50:44.838Z
Learning: The functions `MigrateDBIfNeeded` and `MigrateDBIfNeeded2` in `src/evo/deterministicmns.cpp` are temporary and will be removed in a future version. Refactoring suggestions for these functions should be avoided.
Applied to files:
src/evo/deterministicmns.hsrc/coinjoin/server.cppsrc/llmq/quorums.cpp
📚 Learning: 2025-07-17T15:48:29.418Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6752
File: src/wallet/load.cpp:164-164
Timestamp: 2025-07-17T15:48:29.418Z
Learning: In Dash Core, kwvg prefers using assert() statements to document expected behavior in code paths, especially when the called function also has internal asserts. This is used as a defensive programming pattern rather than requiring conditional error handling.
Applied to files:
src/llmq/dkgsession.cpp
📚 Learning: 2024-12-29T17:43:41.755Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6504
File: src/llmq/quorums.cpp:224-224
Timestamp: 2024-12-29T17:43:41.755Z
Learning: The `CQuorumManager` is fully initialized by `LLMQContext`, addressing any concerns about the manager’s initialization sequence.
Applied to files:
src/llmq/dkgsessionmgr.cpp
🧬 Code graph analysis (18)
src/instantsend/signing.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/test/block_reward_reallocation_tests.cpp (2)
src/util/std23.h (1)
enumerate(81-90)src/util/helpers.h (1)
irange(25-28)
src/governance/classes.cpp (1)
src/util/std23.h (1)
fold_left(63-66)
src/bls/bls.h (1)
src/util/std23.h (1)
ranges(31-101)
src/util/helpers.h (1)
src/util/std23.h (1)
ranges(31-101)
src/llmq/snapshot.h (1)
src/util/helpers.h (2)
util(13-22)irange(25-28)
src/llmq/signing_shares.cpp (2)
src/util/helpers.h (1)
irange(25-28)src/util/std23.h (1)
fold_left(63-66)
src/active/quorums.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/llmq/utils.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/llmq/dkgsession.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/test/llmq_dkg_tests.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/coinjoin/client.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/coinjoin/coinjoin.cpp (1)
src/coinjoin/coinjoin.h (2)
nTime(186-186)fTried(190-209)
src/evo/cbtx.cpp (1)
src/util/std23.h (1)
fold_left(63-66)
src/llmq/blockprocessor.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/llmq/commitment.cpp (2)
src/util/helpers.h (1)
irange(25-28)src/logging.h (1)
LogAcceptDebug(238-241)
src/llmq/dkgsessionmgr.cpp (1)
src/util/helpers.h (1)
irange(25-28)
src/llmq/quorums.cpp (1)
src/util/helpers.h (1)
irange(25-28)
🪛 Cppcheck (2.19.0)
src/instantsend/signing.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/test/block_reward_reallocation_tests.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/governance/governance.cpp
[error] 22-22: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
[error] 24-24: #error No known always_inline attribute for this platform.
(preprocessorErrorDirective)
src/llmq/utils.cpp
[error] 24-24: #error No known always_inline attribute for this platform.
(preprocessorErrorDirective)
src/llmq/dkgsession.cpp
[error] 24-24: #error No known always_inline attribute for this platform.
(preprocessorErrorDirective)
src/coinjoin/client.cpp
[error] 24-24: #error No known always_inline attribute for this platform.
(preprocessorErrorDirective)
src/coinjoin/coinjoin.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/evo/cbtx.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/llmq/blockprocessor.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/llmq/commitment.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/llmq/dkgsessionmgr.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/llmq/options.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/llmq/quorums.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/masternode/payments.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
src/spork.cpp
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
🪛 GitHub Actions: Clang Diff Format Check
src/util/helpers.h
[error] 1-1: Clang-format differences detected in this file. Run the formatting script to fix code style issues.
src/util/std23.h
[error] 1-1: Clang-format differences detected in this file. Run the formatting script to fix code style issues.
src/coinjoin/coinjoin.cpp
[error] 1-1: Clang-format differences detected in this file. Run the formatting script to fix code style issues.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: predict_conflicts
- GitHub Check: linux64_multiprocess-build / Build source
- GitHub Check: linux64_tsan-build / Build source
- GitHub Check: linux64_fuzz-build / Build source
- GitHub Check: linux64-build / Build source
- GitHub Check: linux64_ubsan-build / Build source
- GitHub Check: linux64_sqlite-build / Build source
- GitHub Check: linux64_nowallet-build / Build source
- GitHub Check: win64-build / Build source
- GitHub Check: arm-linux-build / Build source
- GitHub Check: mac-build / Build source
| #include <bls/bls.h> | ||
| #include <chainlock/chainlock.h> | ||
| #include <instantsend/instantsend.h> | ||
| #include <masternode/sync.h> | ||
| #include <util/helpers.h> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the correct header for std::ranges::all_of (don’t rely on transitive includes).
std::ranges::all_of is a ranges algorithm; it should be available via <algorithm>. Keeping only <ranges> may be toolchain-dependent.
Proposed fix
@@
#include <tinyformat.h>
-#include <ranges>
+#include <algorithm>
+#include <ranges>
#include <string>Also applies to: 22-22
🧰 Tools
🪛 Cppcheck (2.19.0)
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
🤖 Prompt for AI Agents
In @src/coinjoin/coinjoin.cpp around lines 7 - 12, The code uses
std::ranges::all_of but only includes <ranges>, which may rely on transitive
includes; add the proper header by including <algorithm> (or replace <ranges>
with <algorithm> if <ranges> isn’t otherwise needed) so that std::ranges::all_of
is guaranteed to be declared; look for the include block around the top of
coinjoin.cpp where headers such as <ranges> are present and add <algorithm> next
to them.
| // Copyright (c) 2022-2026 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_UTIL_STD23_H | ||
| #define BITCOIN_UTIL_STD23_H | ||
|
|
||
| #include <algorithm> | ||
| #include <functional> | ||
| #include <iterator> | ||
| #include <numeric> | ||
| #include <ranges> | ||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
||
| namespace std23 { | ||
| #if __cplusplus >= 202302L | ||
| using std::to_underlying; | ||
| #else | ||
| /** | ||
| * @tparam E enumeration type, automatically deduced | ||
| * @param e the enumerated value to convert | ||
| * @return the underlying value in base type | ||
| */ | ||
| template <typename E> | ||
| [[nodiscard]] inline constexpr std::underlying_type_t<E> to_underlying(E e) noexcept | ||
| { | ||
| return static_cast<std::underlying_type_t<E>>(e); | ||
| } | ||
| #endif // __cplusplus >= 202302L | ||
| namespace ranges { | ||
| #if __cplusplus >= 202302L | ||
| using std::ranges::contains; | ||
| using std::ranges::fold_left; | ||
| #else | ||
| /** | ||
| * @tparam R range type, automatically deduced | ||
| * @tparam T value type to search for, automatically deduced | ||
| * @tparam Proj projection type | ||
| * @param range the range to search in | ||
| * @param value the value to search for | ||
| * @param proj optional projection to apply to elements before comparison | ||
| * @return true if the range contains the value, false otherwise | ||
| */ | ||
| template <typename R, typename T, typename Proj = std::identity> | ||
| inline constexpr bool contains(R&& range, const T& value, Proj proj = {}) | ||
| { | ||
| return std::ranges::any_of(std::forward<R>(range), [&value, &proj](auto&& elem) { | ||
| return std::invoke(proj, std::forward<decltype(elem)>(elem)) == value; | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * @tparam R range type, automatically deduced | ||
| * @tparam T initial value type, automatically deduced | ||
| * @tparam F binary operation type, automatically deduced | ||
| * @param range the range to fold | ||
| * @param init the initial value | ||
| * @param f binary operation to apply | ||
| * @return the result of folding the range | ||
| */ | ||
| template <typename R, typename T, typename F> | ||
| inline constexpr auto fold_left(R&& range, T init, F f) | ||
| { | ||
| return std::accumulate(std::ranges::begin(range), std::ranges::end(range), std::move(init), std::move(f)); | ||
| } | ||
| #endif // __cplusplus >= 202302L | ||
| namespace views { | ||
| #if __cplusplus >= 202302L | ||
| using std::ranges::views::enumerate; | ||
| #else | ||
| /** | ||
| * @tparam T type of iterable, automatically deduced | ||
| * @tparam TIter begin of container | ||
| * @param iterable an iterable object, can be a temporary | ||
| * @return struct containing a size_t index, and it's element in iterable | ||
| */ | ||
| template <typename T, | ||
| typename TIter = decltype(std::begin(std::declval<T>())), | ||
| typename = decltype(std::end(std::declval<T>()))> | ||
| inline constexpr auto enumerate(T && iterable) | ||
| { | ||
| struct iterator | ||
| { | ||
| size_t i; | ||
| TIter iter; | ||
| bool operator != (const iterator & other) const { return iter != other.iter; } | ||
| void operator ++ () { ++i; ++iter; } | ||
| auto operator * () const { return std::tie(i, *iter); } | ||
| }; | ||
| struct iterable_wrapper | ||
| { | ||
| T iterable; | ||
| auto begin() { return iterator{ 0, std::begin(iterable) }; } | ||
| auto end() { return iterator{ 0, std::end(iterable) }; } | ||
| }; | ||
| return iterable_wrapper{ std::forward<T>(iterable) }; | ||
| } | ||
| #endif // __cplusplus >= 202302L | ||
| } // namespace views | ||
| } // namespace ranges | ||
| namespace views { | ||
| using namespace std23::ranges::views; | ||
| } // namespace views | ||
| } // namespace std23 | ||
|
|
||
| #endif // BITCOIN_UTIL_STD23_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run clang-format to fix style issues.
The pipeline indicates clang-format differences were detected. Please run the formatting script to ensure this file conforms to the project's code style guidelines.
🧰 Tools
🪛 GitHub Actions: Clang Diff Format Check
[error] 1-1: Clang-format differences detected in this file. Run the formatting script to fix code style issues.
🤖 Prompt for AI Agents
In @src/util/std23.h around lines 1 - 107, The file fails clang-format style
checks; run the project's formatting script (or clang-format) on
src/util/std23.h and commit the changes. Ensure formatting is applied
consistently across the entire file, including the to_underlying template,
std23::ranges::contains, std23::ranges::fold_left, and
std23::ranges::views::enumerate definitions and surrounding namespace/brace
alignment so the diffs disappear.
|
I conceptually see no benefits for this refactoring, because once C++23 is introduced, still should be renamed instead of 'ToUnderlying' the other name 'std23::to_underlying` (to 'std::to_underlying'). But downsides - this PR is conflict friendly; all C++23 related changes are in one file; what is not true for std - std::to_underlying in |
| #include <memory> | ||
| #include <optional> | ||
| #include <ranges> | ||
| #include <string_view> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it makes compilation time slower. ranges is very heavy header.
If you just need 1 helper to_string for bool, apparently memory, optional, ranges will be included too.
UdjinM6
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Motivation
The upgrade to C++20 (dash#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:
util/ranges.h(mostly now an alias tostd::rangesafter C++20 migration except forfind_if_opt, which is custom)util/irange.h(equivalent tostd::views::iota, introduced in C++20)util/enumerate.h(equivalent tostd::views::enumerate, introduced in C++23)util/underlying.h(equivalent tostd::to_underlying, introduced in C++23)util/pointer.h(customstd::shared_ptrhelper)This pull requests compacts all of those helpers into two files:
util/helpers.h(custom helpers, replacingutil/irange.h,util/pointer.h,util/ranges.h)util/std23.h(polyfill for C++23, replacingutil/enumerate.handutil/underlying.h)And additionally, introduces additional capabilities utilised in Dash-specific code:
std23::ranges::contains(equivalent tostd::ranges::contains)std23::ranges::fold_left(equivalent tostd::ranges::fold_left)util::to_string(bool)(equivalent tovalue ? "true" : "false")Additional Information
ToUnderlying()needed to be renamed toto_underlying()to match with the standard library naming so we can discontinue the polyfill easily when we migrate to C++23 by just goings/std23/std/g.While
iranges::rangeis equivalent tostd::views::iota, the latter requires both min and max to be of the same type but literal0has a type incompatible withsize_t, requiringsize_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 formaxBreaking Changes
None expected.
Checklist