From 1c30728b9ea25c718852c7fa135a4b65889334a6 Mon Sep 17 00:00:00 2001 From: kamilsa Date: Thu, 12 Jun 2025 11:51:16 +0500 Subject: [PATCH] [feat] add TTL for grandpa historical votes and update storage spaces --- core/consensus/grandpa/impl/grandpa_impl.cpp | 4 ++-- core/injector/application_injector.cpp | 3 ++- core/storage/rocksdb/rocksdb_spaces.cpp | 3 ++- core/storage/spaces.hpp | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/consensus/grandpa/impl/grandpa_impl.cpp b/core/consensus/grandpa/impl/grandpa_impl.cpp index 1f93fa419e..e524966653 100644 --- a/core/consensus/grandpa/impl/grandpa_impl.cpp +++ b/core/consensus/grandpa/impl/grandpa_impl.cpp @@ -68,7 +68,7 @@ namespace kagome::consensus::grandpa { constexpr std::chrono::milliseconds kGossipDuration{1000}; inline auto historicalVotesKey(AuthoritySetId set, RoundNumber round) { - auto key = storage::kGrandpaHistoricalVotesPrefix; + common::Buffer key; key.putUint64(set); key.putUint64(round); return key; @@ -102,7 +102,7 @@ namespace kagome::consensus::grandpa { reputation_repository_(std::move(reputation_repository)), timeline_{timeline}, chain_sub_{std::move(chain_sub_engine)}, - db_{db.getSpace(storage::Space::kDefault)}, + db_{db.getSpace(storage::Space::kGrandpaHistoricalVotes)}, main_pool_handler_{main_thread_pool.handler(*app_state_manager)}, grandpa_pool_handler_{poolHandlerReadyMake( this, app_state_manager, grandpa_thread_pool, logger_)}, diff --git a/core/injector/application_injector.cpp b/core/injector/application_injector.cpp index e214a20d93..ba60a25789 100644 --- a/core/injector/application_injector.cpp +++ b/core/injector/application_injector.cpp @@ -282,7 +282,8 @@ namespace { options.max_open_files = soft_limit.value() / 2; const std::unordered_map column_ttl = { - {"avaliability_storage", 25 * 60 * 60}}; // 25 hours + {"avaliability_storage", 25 * 60 * 60}, // 25 hours + {"grandpa_historical_votes", 2 * 60}}; // 2 minutes auto db_res = storage::RocksDb::create(app_config.databasePath(chain_spec->id()), options, diff --git a/core/storage/rocksdb/rocksdb_spaces.cpp b/core/storage/rocksdb/rocksdb_spaces.cpp index aef0ba0fba..e86f099402 100644 --- a/core/storage/rocksdb/rocksdb_spaces.cpp +++ b/core/storage/rocksdb/rocksdb_spaces.cpp @@ -22,7 +22,8 @@ namespace kagome::storage { "dispute_data", "beefy_justification", "avaliability_storage", - "audi_peers"}; + "audi_peers", + "grandpa_historical_votes"}; static_assert(kNames.size() == Space::kTotal - 1); std::string spaceName(Space space) { diff --git a/core/storage/spaces.hpp b/core/storage/spaces.hpp index 45cce8598e..4bc19e48e9 100644 --- a/core/storage/spaces.hpp +++ b/core/storage/spaces.hpp @@ -24,6 +24,7 @@ namespace kagome::storage { kBeefyJustification, kAvaliabilityStorage, kAudiPeers, + kGrandpaHistoricalVotes, kTotal };