Skip to content

Reset InMempool txs to Inactive before connecting to the node#2051

Open
OBorce wants to merge 1 commit intomasterfrom
fix/wallet-reset-inmempool-txs
Open

Reset InMempool txs to Inactive before connecting to the node#2051
OBorce wants to merge 1 commit intomasterfrom
fix/wallet-reset-inmempool-txs

Conversation

@OBorce
Copy link
Copy Markdown
Contributor

@OBorce OBorce commented Apr 30, 2026

We reset all InMempool transactions back to Inactive on

  1. wallet load,
  2. every time the mempool notifications channel is closed
    so that we can rescan them from the node when we connect back.

Copy link
Copy Markdown
Contributor

@ImplOfAnImpl ImplOfAnImpl left a comment

Choose a reason for hiding this comment

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

As I mentioned earlier, mempool can evict transactions - there is a size limit for the entire mempool and an expiration time for each tx. Though at this memoment it's unlikely to happen (the size limit is 300Mb and expiration time 2 weeks), it's better to fix the problem fully from the beginning. At this moment eviction only happens after a new tx has been added to the mempool. So the fix could be that whenever the wallet receives a NewTransaction event, it would obtain all InMempool tx ids from the output cache, check which of them are no longer in mempool and reset their status. (though it's better not to use MempoolRpc::contains_tx for checking and instead introduce an additional method that would operate on a set of ids, to avoid the rpc calls overhead).


// add 10 random txs
for _ in 0..10 {
add_random_transfer_tx(&mut output_cache, &chain_config, &mut rng);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Plz don't create random transactions, create ones with InMempool state explicitly.

For this you can factor out the corresponding logic from add_random_transfer_tx into a separate func add_random_transfer_tx_with_state and call it here and inside add_random_transfer_tx.

Comment on lines 1462 to +1463
// after the first successful sync to the tip fetch all mempool transactions
if !self.finished_initial_sync.test() {
if self.should_resecan_mempool_txs {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The comment is outdated, as mempool fetching is now performed not only after the first successful sync

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.

2 participants