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

Make sure mempool txes are properly processed by CChainLocksHandler despite node restarts #3226

Merged
merged 2 commits into from
Dec 7, 2019

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Dec 6, 2019

Pls see individual commits.

Note: the way txes are synced via signals has changed a lot since 0.14, so I propose to backport
06e20a8 to fix the same issue there while avoiding merge conflicts in the future
it will need its own fix.

Otherwise the "first seen" time is way off after node restart
…is not synced yet

Otherwise txes from mempool.dat won't be processed there
@UdjinM6 UdjinM6 added this to the 15 milestone Dec 6, 2019
return false;
}
LOCK(cs);
txFirstSeenTime.emplace(txid, info.nTime);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I really don't like IsXXX methods with side effects. I'd prefer to not have this commit at all to be honest. Instead, we should maybe just do this on v0.14.0.x:

diff --git a/src/llmq/quorums_chainlocks.cpp b/src/llmq/quorums_chainlocks.cpp
index cdb5d99ac1..221b8d0a9c 100644
--- a/src/llmq/quorums_chainlocks.cpp
+++ b/src/llmq/quorums_chainlocks.cpp
@@ -347,10 +347,6 @@ void CChainLocksHandler::TrySignChainTip()
 
 void CChainLocksHandler::SyncTransaction(const CTransaction& tx, const CBlockIndex* pindex, int posInBlock)
 {
-    if (!masternodeSync.IsBlockchainSynced()) {
-        return;
-    }
-
     bool handleTx = true;
     if (tx.IsCoinBase() || tx.vin.empty()) {
         handleTx = false;
@@ -363,6 +359,10 @@ void CChainLocksHandler::SyncTransaction(const CTransaction& tx, const CBlockInd
         txFirstSeenTime.emplace(tx.GetHash(), curTime);
     }
 
+    if (!masternodeSync.IsBlockchainSynced()) {
+        return;
+    }
+
     // We listen for SyncTransaction so that we can collect all TX ids of all included TXs of newly received blocks
     // We need this information later when we try to sign a new tip, so that we can determine if all included TXs are
     // safe.

It'll cause TXs to linger in the mempool for 10 minutes, but that's still a lot better then never mining them.

Copy link
Author

@UdjinM6 UdjinM6 Dec 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Dropped this commit and updated PR description.

Copy link

@codablock codablock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@UdjinM6 UdjinM6 merged commit 91a996e into dashpay:develop Dec 7, 2019
barrystyle pushed a commit to PACGlobalOfficial/PAC that referenced this pull request Jan 22, 2020
…espite node restarts (dashpay#3226)

* Pass nAcceptTime via TransactionAddedToMempool and use it for ChainLocks

Otherwise the "first seen" time is way off after node restart

* Don't skip TransactionAddedToMempool for chainlocks while blockchain is not synced yet

Otherwise txes from mempool.dat won't be processed there
FornaxA pushed a commit to ioncoincore/ion that referenced this pull request Jul 6, 2020
…espite node restarts (dashpay#3226)

* Pass nAcceptTime via TransactionAddedToMempool and use it for ChainLocks

Otherwise the "first seen" time is way off after node restart

* Don't skip TransactionAddedToMempool for chainlocks while blockchain is not synced yet

Otherwise txes from mempool.dat won't be processed there

Signed-off-by: cevap <[email protected]>
@UdjinM6 UdjinM6 deleted the fixtxfirstseen branch November 26, 2020 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants