Skip to content
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

fix: Improve quorum data caching and cleanup #5731

Merged
merged 10 commits into from
Nov 29, 2023
1 change: 1 addition & 0 deletions src/llmq/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ void CQuorumManager::CleanupOldQuorumData(const CBlockIndex* pIndex) const
// Unlike for other quorum types we want to keep data (secret key shares and vvec)
// for Platform quorums for at least 2 months because Platform can be restarted and
// it must be able to re-sign stuff. During a month, 24 * 30 quorums are created.
// NOTE: when changing this make sure to update InitQuorumsCache() accordingly
constexpr auto numPlatformQuorumsDataToKeep = 24 * 30 * 2;

for (const auto& params : Params().GetConsensus().llmqs) {
Expand Down
6 changes: 5 additions & 1 deletion src/llmq/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,9 +1087,13 @@ std::map<Consensus::LLMQType, QvvecSyncMode> GetEnabledQuorumVvecSyncEntries()
template <typename CacheType>
void InitQuorumsCache(CacheType& cache)
{
// NOTE: See CQuorumManager::CleanupOldQuorumData() for more info
constexpr auto numPlatformQuorumsDataToKeep = 24 * 30 * 2;
knst marked this conversation as resolved.
Show resolved Hide resolved
const auto llmqTypePlatform = Params().GetConsensus().llmqTypePlatform;
for (const auto& llmq : Params().GetConsensus().llmqs) {
const auto nQuorumsToKeep = llmq.type == llmqTypePlatform ? numPlatformQuorumsDataToKeep : llmq.keepOldConnections;
cache.emplace(std::piecewise_construct, std::forward_as_tuple(llmq.type),
std::forward_as_tuple(llmq.keepOldConnections));
std::forward_as_tuple(nQuorumsToKeep));
}
}
template void InitQuorumsCache<std::map<Consensus::LLMQType, unordered_lru_cache<uint256, bool, StaticSaltedHasher>>>(std::map<Consensus::LLMQType, unordered_lru_cache<uint256, bool, StaticSaltedHasher>>& cache);
Expand Down