Repository navigation
Emit mempool transactions that share a timestamp - #1177
Conversation
|
👋 Thanks for assigning @tnull as a reviewer! |
d12c5fd to
f33bb4c
Compare
tnull
left a comment
There was a problem hiding this comment.
Thanks! It seems there might be simpler ways to address this though. If possible would be good to avoid the parallel HashSet tracking.
f33bb4c to
ea79f25
Compare
@tnull , Thanks for the review. Reworked as suggested: the txid set is replaced by an emitted flag on MempoolEntry, and the select-and-mark logic is one function that the tests drive directly. Force-pushed. |
tnull
left a comment
There was a problem hiding this comment.
Two comments, otherwise looks good.
`get_mempool_transactions_and_timestamp_at_height` decided whether a mempool transaction was already emitted solely by comparing its entry time to the saved cursor. Entry times only have second resolution, so a new transaction sharing the second of an already emitted one was skipped for as long as it stayed unconfirmed, and the wallet missed the unconfirmed payment until it confirmed. Cache each `MempoolEntry` in a `CachedMempoolEntry` that tracks whether we emitted its transaction instead. Entries are only marked once all transactions of a poll were fetched, so a failed poll doesn't mark transactions the receiver never got, and entries that left the mempool are dropped with their flag, so a transaction that re-enters it is emitted again. The selection and marking now live in `emit_new_mempool_txs`, which takes the fetch as a closure so tests can drive it. As the cursor is now only used as the timestamp of evicted transactions, rename it to `mempool_eviction_timestamp`. Fixes lightningdevkit#1140. Prepared with the assistance of Claude Code.
ea79f25 to
1a9e8a3
Compare
Fixes #1140.
get_mempool_transactions_and_timestamp_at_heightdecided whether a mempool transaction had already been emitted only by comparing its entry time to the saved cursor. Bitcoin Core's entry times have one-second resolution, so a new transaction in the same second as an already emitted one was skipped, and stayed skipped while it was unconfirmed. The wallet then missed the unconfirmed payment until it confirmed.We now track whether a transaction was emitted with an
emittedflag on the cachedMempoolEntry:entry.height <= best_processed_heightcheck is unchanged).latest_mempool_timestampis now only used as the timestamp of evicted transactions.Tests: the selection and marking live in
emit_new_mempool_txs, which takes the fetch as a closure, so the tests drive it directly: same-second transaction, lagging ancestors, and a failed fetch followed by a retry. The lib tests pass, and I didn't run the integration tests.AI disclosure: prepared with the assistance of Claude Code.