mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
instantsend: Postpone mempool related cleanup fixes until dip0020 activation (#4159)
* instantsend: Upgrade IS db on dip0020 activation * instantsend: Do not remove islocks for txes removed from mempool until dip0020 is activated * refactor: introduce fUpgradedDB to avoid excessive locking and checking the state * llmq: Decouple `fUpgradedDB` from `cs` * Update src/llmq/quorums_instantsend.cpp Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Fix deadlock Upgrade locks cs_main via GetTransaction Co-authored-by: xdustinface <xdustinfacex@gmail.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
This commit is contained in:
parent
288f5976a8
commit
a02f8302d9
@ -52,7 +52,6 @@ uint256 CInstantSendLock::GetRequestId() const
|
|||||||
|
|
||||||
CInstantSendDb::CInstantSendDb(CDBWrapper& _db) : db(_db)
|
CInstantSendDb::CInstantSendDb(CDBWrapper& _db) : db(_db)
|
||||||
{
|
{
|
||||||
Upgrade();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInstantSendDb::Upgrade()
|
void CInstantSendDb::Upgrade()
|
||||||
@ -1072,7 +1071,7 @@ void CInstantSendManager::TransactionAddedToMempool(const CTransactionRef& tx)
|
|||||||
|
|
||||||
void CInstantSendManager::TransactionRemovedFromMempool(const CTransactionRef& tx)
|
void CInstantSendManager::TransactionRemovedFromMempool(const CTransactionRef& tx)
|
||||||
{
|
{
|
||||||
if (tx->vin.empty()) {
|
if (tx->vin.empty() || !fUpgradedDB) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1217,6 +1216,14 @@ void CInstantSendManager::NotifyChainLock(const CBlockIndex* pindexChainLock)
|
|||||||
|
|
||||||
void CInstantSendManager::UpdatedBlockTip(const CBlockIndex* pindexNew)
|
void CInstantSendManager::UpdatedBlockTip(const CBlockIndex* pindexNew)
|
||||||
{
|
{
|
||||||
|
if (!fUpgradedDB) {
|
||||||
|
LOCK(cs_main);
|
||||||
|
if (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0020, versionbitscache) == ThresholdState::ACTIVE) {
|
||||||
|
db.Upgrade();
|
||||||
|
fUpgradedDB = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool fDIP0008Active = pindexNew->pprev && pindexNew->pprev->nHeight >= Params().GetConsensus().DIP0008Height;
|
bool fDIP0008Active = pindexNew->pprev && pindexNew->pprev->nHeight >= Params().GetConsensus().DIP0008Height;
|
||||||
|
|
||||||
if (AreChainLocksEnabled() && fDIP0008Active) {
|
if (AreChainLocksEnabled() && fDIP0008Active) {
|
||||||
|
@ -55,11 +55,11 @@ private:
|
|||||||
void WriteInstantSendLockMined(CDBBatch& batch, const uint256& hash, int nHeight);
|
void WriteInstantSendLockMined(CDBBatch& batch, const uint256& hash, int nHeight);
|
||||||
void RemoveInstantSendLockMined(CDBBatch& batch, const uint256& hash, int nHeight);
|
void RemoveInstantSendLockMined(CDBBatch& batch, const uint256& hash, int nHeight);
|
||||||
|
|
||||||
void Upgrade();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CInstantSendDb(CDBWrapper& _db);
|
explicit CInstantSendDb(CDBWrapper& _db);
|
||||||
|
|
||||||
|
void Upgrade();
|
||||||
|
|
||||||
void WriteNewInstantSendLock(const uint256& hash, const CInstantSendLock& islock);
|
void WriteNewInstantSendLock(const uint256& hash, const CInstantSendLock& islock);
|
||||||
void RemoveInstantSendLock(CDBBatch& batch, const uint256& hash, CInstantSendLockPtr islock, bool keep_cache = true);
|
void RemoveInstantSendLock(CDBBatch& batch, const uint256& hash, CInstantSendLockPtr islock, bool keep_cache = true);
|
||||||
|
|
||||||
@ -87,6 +87,8 @@ private:
|
|||||||
mutable CCriticalSection cs;
|
mutable CCriticalSection cs;
|
||||||
CInstantSendDb db;
|
CInstantSendDb db;
|
||||||
|
|
||||||
|
std::atomic<bool> fUpgradedDB{false};
|
||||||
|
|
||||||
std::thread workThread;
|
std::thread workThread;
|
||||||
CThreadInterrupt workInterrupt;
|
CThreadInterrupt workInterrupt;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user