Skip to content

Commit b4adc5a

Browse files
committed
[bugfix] update lockpoints correctly during reorg
During a reorg, we re-check timelocks on all mempool entries using CheckSequenceLocks(useExistingLockPoints=false) and remove any now-invalid entries. CheckSequenceLocks() also mutates the LockPoints passed in, and we update valid entries' LockPoints using update_lock_points. Thus, update_lock_points(lp) needs to be called right after CheckSequenceLocks(lp), otherwise we lose the data in lp. commit bedf246 introduced a bug by separating those two loops.
1 parent b6002b0 commit b4adc5a

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/txmempool.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,7 @@ void CTxMemPool::removeForReorg(CChain& chain, std::function<bool(txiter)> check
639639
}
640640
RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG);
641641
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
642-
const LockPoints lp{it->GetLockPoints()};
643-
if (!TestLockPointValidity(chain, lp)) {
644-
mapTx.modify(it, update_lock_points(lp));
645-
}
642+
assert(TestLockPointValidity(chain, it->GetLockPoints()));
646643
}
647644
}
648645

src/validation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ void CChainState::MaybeUpdateMempoolForReorg(
378378
}
379379
}
380380
}
381+
// CheckSequenceLocks updates lp. Update the mempool entry LockPoints.
382+
if (!validLP) m_mempool->mapTx.modify(it, update_lock_points(lp));
381383
return should_remove;
382384
};
383385

0 commit comments

Comments
 (0)