@@ -403,10 +403,16 @@ bool CInstantSendManager::ProcessTx(const CTransaction& tx, const Consensus::Par
403403 }
404404
405405 if (!CheckCanLock (tx, true , params)) {
406+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s: CheckCanLock returned false\n " , __func__,
407+ tx.GetHash ().ToString ());
406408 return false ;
407409 }
408410
409- if (IsConflicted (tx)) {
411+ auto conflictingLock = GetConflictingLock (tx);
412+ if (conflictingLock) {
413+ auto islockHash = ::SerializeHash (*conflictingLock);
414+ LogPrintf (" CInstantSendManager::%s -- txid=%s: conflicts with islock %s, txid=%s\n " , __func__,
415+ tx.GetHash ().ToString (), islockHash.ToString (), conflictingLock->txid .ToString ());
410416 return false ;
411417 }
412418
@@ -421,7 +427,7 @@ bool CInstantSendManager::ProcessTx(const CTransaction& tx, const Consensus::Par
421427 uint256 otherTxHash;
422428 if (quorumSigningManager->GetVoteForId (llmqType, id, otherTxHash)) {
423429 if (otherTxHash != tx.GetHash ()) {
424- LogPrintf (" CInstantSendManager::%s -- txid=%s: input %s is conflicting with islock %s\n " , __func__,
430+ LogPrintf (" CInstantSendManager::%s -- txid=%s: input %s is conflicting with previous vote for tx %s\n " , __func__,
425431 tx.GetHash ().ToString (), in.prevout .ToStringShort (), otherTxHash.ToString ());
426432 return false ;
427433 }
@@ -430,19 +436,28 @@ bool CInstantSendManager::ProcessTx(const CTransaction& tx, const Consensus::Par
430436
431437 // don't even try the actual signing if any input is conflicting
432438 if (quorumSigningManager->IsConflicting (llmqType, id, tx.GetHash ())) {
439+ LogPrintf (" CInstantSendManager::%s -- txid=%s: quorumSigningManager->IsConflicting returned true. id=%s\n " , __func__,
440+ tx.GetHash ().ToString (), id.ToString ());
433441 return false ;
434442 }
435443 }
436444 if (alreadyVotedCount == ids.size ()) {
445+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s: already voted on all inputs, bailing out\n " , __func__,
446+ tx.GetHash ().ToString ());
437447 return true ;
438448 }
439449
450+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s: trying to vote on %d inputs\n " , __func__,
451+ tx.GetHash ().ToString (), tx.vin .size ());
452+
440453 for (size_t i = 0 ; i < tx.vin .size (); i++) {
441454 auto & in = tx.vin [i];
442455 auto & id = ids[i];
443456 inputRequestIds.emplace (id);
457+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s: trying to vote on input %s with id %s\n " , __func__,
458+ tx.GetHash ().ToString (), in.prevout .ToStringShort (), id.ToString ());
444459 if (quorumSigningManager->AsyncSignIfMember (llmqType, id, tx.GetHash ())) {
445- LogPrintf ( " CInstantSendManager::%s -- txid=%s: voted on input %s with id %s\n " , __func__,
460+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s: voted on input %s with id %s\n " , __func__,
446461 tx.GetHash ().ToString (), in.prevout .ToStringShort (), id.ToString ());
447462 }
448463 }
@@ -915,6 +930,10 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, const uint256& has
915930
916931 // This will also add children TXs to pendingRetryTxs
917932 RemoveNonLockedTx (islock.txid , true );
933+
934+ // We don't need the recovered sigs for the inputs anymore. This prevents unnecessary propagation of these sigs.
935+ // We only need the ISLOCK from now on to detect conflicts
936+ TruncateRecoveredSigsForInputs (islock);
918937 }
919938
920939 CInv inv (MSG_ISLOCK, hash);
@@ -1036,6 +1055,9 @@ void CInstantSendManager::AddNonLockedTx(const CTransactionRef& tx, const CBlock
10361055 nonLockedTxsByInputs.emplace (in.prevout .hash , std::make_pair (in.prevout .n , tx->GetHash ()));
10371056 }
10381057 }
1058+
1059+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, pindexMined=%s\n " , __func__,
1060+ tx->GetHash ().ToString (), pindexMined ? pindexMined->GetBlockHash ().ToString () : " " );
10391061}
10401062
10411063void CInstantSendManager::RemoveNonLockedTx (const uint256& txid, bool retryChildren)
@@ -1048,10 +1070,12 @@ void CInstantSendManager::RemoveNonLockedTx(const uint256& txid, bool retryChild
10481070 }
10491071 auto & info = it->second ;
10501072
1073+ size_t retryChildrenCount = 0 ;
10511074 if (retryChildren) {
10521075 // TX got locked, so we can retry locking children
10531076 for (auto & childTxid : info.children ) {
10541077 pendingRetryTxs.emplace (childTxid);
1078+ retryChildrenCount++;
10551079 }
10561080 }
10571081
@@ -1078,6 +1102,9 @@ void CInstantSendManager::RemoveNonLockedTx(const uint256& txid, bool retryChild
10781102 }
10791103
10801104 nonLockedTxs.erase (it);
1105+
1106+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, retryChildren=%d, retryChildrenCount=%d\n " , __func__,
1107+ txid.ToString (), retryChildren, retryChildrenCount);
10811108}
10821109
10831110void CInstantSendManager::RemoveConflictedTx (const CTransaction& tx)
@@ -1091,6 +1118,17 @@ void CInstantSendManager::RemoveConflictedTx(const CTransaction& tx)
10911118 }
10921119}
10931120
1121+ void CInstantSendManager::TruncateRecoveredSigsForInputs (const llmq::CInstantSendLock& islock)
1122+ {
1123+ auto & consensusParams = Params ().GetConsensus ();
1124+
1125+ for (auto & in : islock.inputs ) {
1126+ auto inputRequestId = ::SerializeHash (std::make_pair (INPUTLOCK_REQUESTID_PREFIX, in));
1127+ inputRequestIds.erase (inputRequestId);
1128+ quorumSigningManager->TruncateRecoveredSig (consensusParams.llmqTypeInstantSend , inputRequestId);
1129+ }
1130+ }
1131+
10941132void CInstantSendManager::NotifyChainLock (const CBlockIndex* pindexChainLock)
10951133{
10961134 HandleFullyConfirmedBlock (pindexChainLock);
@@ -1131,17 +1169,13 @@ void CInstantSendManager::HandleFullyConfirmedBlock(const CBlockIndex* pindex)
11311169 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s: removed islock as it got fully confirmed\n " , __func__,
11321170 islock->txid .ToString (), islockHash.ToString ());
11331171
1134- for (auto & in : islock->inputs ) {
1135- auto inputRequestId = ::SerializeHash (std::make_pair (INPUTLOCK_REQUESTID_PREFIX, in));
1136- inputRequestIds.erase (inputRequestId);
1137-
1138- // no need to keep recovered sigs for fully confirmed IS locks, as there is no chance for conflicts
1139- // from now on. All inputs are spent now and can't be spend in any other TX.
1140- quorumSigningManager->RemoveRecoveredSig (consensusParams.llmqTypeInstantSend , inputRequestId);
1141- }
1172+ // No need to keep recovered sigs for fully confirmed IS locks, as there is no chance for conflicts
1173+ // from now on. All inputs are spent now and can't be spend in any other TX.
1174+ TruncateRecoveredSigsForInputs (*islock);
11421175
1143- // same as in the loop
1144- quorumSigningManager->RemoveRecoveredSig (consensusParams.llmqTypeInstantSend , islock->GetRequestId ());
1176+ // And we don't need the recovered sig for the ISLOCK anymore, as the block in which it got mined is considered
1177+ // fully confirmed now
1178+ quorumSigningManager->TruncateRecoveredSig (consensusParams.llmqTypeInstantSend , islock->GetRequestId ());
11451179 }
11461180
11471181 // Find all previously unlocked TXs that got locked by this fully confirmed (ChainLock) block and remove them
0 commit comments