Skip to content

Commit

Permalink
refactor: Drop llmq split migration logic (dead code)
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Nov 16, 2024
1 parent 9bfb700 commit 4622d9e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 281 deletions.
92 changes: 0 additions & 92 deletions src/llmq/dkgsessionmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chai
return;
}

MigrateDKG();

const Consensus::Params& consensus_params = Params().GetConsensus();
for (const auto& params : consensus_params.llmqs) {
auto session_count = (params.useRotation) ? params.signingActiveQuorumCount : 1;
Expand All @@ -62,96 +60,6 @@ CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chai
}

CDKGSessionManager::~CDKGSessionManager() = default;

void CDKGSessionManager::MigrateDKG()
{
if (!db->IsEmpty()) return;

LogPrint(BCLog::LLMQ, "CDKGSessionManager::%d -- start\n", __func__);

CDBBatch batch(*db);
auto oldDb = std::make_unique<CDBWrapper>(gArgs.GetDataDirNet() / "llmq", 8 << 20);
std::unique_ptr<CDBIterator> pcursor(oldDb->NewIterator());

auto start_vvec = std::make_tuple(DB_VVEC, (Consensus::LLMQType)0, uint256(), uint256());
pcursor->Seek(start_vvec);

while (pcursor->Valid()) {
decltype(start_vvec) k;
std::vector<CBLSPublicKey> v;

if (!pcursor->GetKey(k) || std::get<0>(k) != DB_VVEC) {
break;
}
if (!pcursor->GetValue(v)) {
break;
}

batch.Write(k, v);

if (batch.SizeEstimate() >= (1 << 24)) {
db->WriteBatch(batch);
batch.Clear();
}

pcursor->Next();
}

auto start_contrib = std::make_tuple(DB_SKCONTRIB, (Consensus::LLMQType)0, uint256(), uint256());
pcursor->Seek(start_contrib);

while (pcursor->Valid()) {
decltype(start_contrib) k;
CBLSSecretKey v;

if (!pcursor->GetKey(k) || std::get<0>(k) != DB_SKCONTRIB) {
break;
}
if (!pcursor->GetValue(v)) {
break;
}

batch.Write(k, v);

if (batch.SizeEstimate() >= (1 << 24)) {
db->WriteBatch(batch);
batch.Clear();
}

pcursor->Next();
}

auto start_enc_contrib = std::make_tuple(DB_ENC_CONTRIB, (Consensus::LLMQType)0, uint256(), uint256());
pcursor->Seek(start_enc_contrib);

while (pcursor->Valid()) {
decltype(start_enc_contrib) k;
CBLSIESMultiRecipientObjects<CBLSSecretKey> v;

if (!pcursor->GetKey(k) || std::get<0>(k) != DB_ENC_CONTRIB) {
break;
}
if (!pcursor->GetValue(v)) {
break;
}

batch.Write(k, v);

if (batch.SizeEstimate() >= (1 << 24)) {
db->WriteBatch(batch);
batch.Clear();
}

pcursor->Next();
}

db->WriteBatch(batch);
pcursor.reset();
oldDb.reset();

LogPrint(BCLog::LLMQ, "CDKGSessionManager::%d -- done\n", __func__);
}

void CDKGSessionManager::StartThreads()
{
for (auto& it : dkgSessionHandlers) {
Expand Down
1 change: 0 additions & 1 deletion src/llmq/dkgsessionmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class CDKGSessionManager
void CleanupOldContributions() const;

private:
void MigrateDKG();
void CleanupCache() const;
};
} // namespace llmq
Expand Down
186 changes: 0 additions & 186 deletions src/llmq/signing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,196 +46,10 @@ UniValue CRecoveredSig::ToJson() const
CRecoveredSigsDb::CRecoveredSigsDb(bool fMemory, bool fWipe) :
db(std::make_unique<CDBWrapper>(fMemory ? "" : (gArgs.GetDataDirNet() / "llmq/recsigdb"), 8 << 20, fMemory, fWipe))
{
MigrateRecoveredSigs();
}

CRecoveredSigsDb::~CRecoveredSigsDb() = default;

void CRecoveredSigsDb::MigrateRecoveredSigs()
{
if (!db->IsEmpty()) return;

LogPrint(BCLog::LLMQ, "CRecoveredSigsDb::%d -- start\n", __func__);

CDBBatch batch(*db);
auto oldDb = std::make_unique<CDBWrapper>(gArgs.GetDataDirNet() / "llmq", 8 << 20);
std::unique_ptr<CDBIterator> pcursor(oldDb->NewIterator());

auto start_h = std::make_tuple(std::string("rs_h"), uint256());
pcursor->Seek(start_h);

while (pcursor->Valid()) {
decltype(start_h) k;
std::pair<Consensus::LLMQType, uint256> v;

if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_h") {
break;
}
if (!pcursor->GetValue(v)) {
break;
}

batch.Write(k, v);

if (batch.SizeEstimate() >= (1 << 24)) {
db->WriteBatch(batch);
batch.Clear();
}

pcursor->Next();
}

auto start_r1 = std::make_tuple(std::string("rs_r"), (Consensus::LLMQType)0, uint256());
pcursor->Seek(start_r1);

while (pcursor->Valid()) {
decltype(start_r1) k;
CRecoveredSig v;

if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_r") {
break;
}
if (!pcursor->GetValue(v)) {
break;
}

batch.Write(k, v);

if (batch.SizeEstimate() >= (1 << 24)) {
db->WriteBatch(batch);
batch.Clear();
}

pcursor->Next();
}

auto start_r2 = std::make_tuple(std::string("rs_r"), (Consensus::LLMQType)0, uint256(), uint256());
pcursor->Seek(start_r2);

while (pcursor->Valid()) {
decltype(start_r2) k;
uint32_t v;

if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_r") {
break;
}
if (!pcursor->GetValue(v)) {
break;
}

batch.Write(k, v);

if (batch.SizeEstimate() >= (1 << 24)) {
db->WriteBatch(batch);
batch.Clear();
}

pcursor->Next();
}

auto start_s = std::make_tuple(std::string("rs_s"), uint256());
pcursor->Seek(start_s);

while (pcursor->Valid()) {
decltype(start_s) k;
uint8_t v;

if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_s") {
break;
}
if (!pcursor->GetValue(v)) {
break;
}

batch.Write(k, v);

if (batch.SizeEstimate() >= (1 << 24)) {
db->WriteBatch(batch);
batch.Clear();
}

pcursor->Next();
}

auto start_t = std::make_tuple(std::string("rs_t"), (uint32_t)0, (Consensus::LLMQType)0, uint256());
pcursor->Seek(start_t);

while (pcursor->Valid()) {
decltype(start_t) k;
uint8_t v;

if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_t") {
break;
}
if (!pcursor->GetValue(v)) {
break;
}

batch.Write(k, v);

if (batch.SizeEstimate() >= (1 << 24)) {
db->WriteBatch(batch);
batch.Clear();
}

pcursor->Next();
}

auto start_v = std::make_tuple(std::string("rs_v"), (Consensus::LLMQType)0, uint256());
pcursor->Seek(start_v);

while (pcursor->Valid()) {
decltype(start_v) k;
uint256 v;

if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_v") {
break;
}
if (!pcursor->GetValue(v)) {
break;
}

batch.Write(k, v);

if (batch.SizeEstimate() >= (1 << 24)) {
db->WriteBatch(batch);
batch.Clear();
}

pcursor->Next();
}

auto start_vt = std::make_tuple(std::string("rs_vt"), (uint32_t)0, (Consensus::LLMQType)0, uint256());
pcursor->Seek(start_vt);

while (pcursor->Valid()) {
decltype(start_vt) k;
uint8_t v;

if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_vt") {
break;
}
if (!pcursor->GetValue(v)) {
break;
}

batch.Write(k, v);

if (batch.SizeEstimate() >= (1 << 24)) {
db->WriteBatch(batch);
batch.Clear();
}

pcursor->Next();
}

db->WriteBatch(batch);
pcursor.reset();
oldDb.reset();

LogPrint(BCLog::LLMQ, "CRecoveredSigsDb::%d -- done\n", __func__);
}

bool CRecoveredSigsDb::HasRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash) const
{
auto k = std::make_tuple(std::string("rs_r"), llmqType, id, msgHash);
Expand Down
2 changes: 0 additions & 2 deletions src/llmq/signing.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ class CRecoveredSigsDb
void CleanupOldVotes(int64_t maxAge);

private:
void MigrateRecoveredSigs();

bool ReadRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, CRecoveredSig& ret) const;
void RemoveRecoveredSig(CDBBatch& batch, Consensus::LLMQType llmqType, const uint256& id, bool deleteHashKey, bool deleteTimeKey);
};
Expand Down

0 comments on commit 4622d9e

Please sign in to comment.