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

feat(rpc)!: Update Emitter::mempool to support evicted_at #1857

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

LagginTimes
Copy link
Contributor

Description

Work for this began as part of #1811, based on this comment.

Emitter::mempool now returns a MempoolEvent which provides the data for tracking evicted_at:

pub struct MempoolEvent {
    /// Unemitted transactions or transactions with ancestors that are unseen by the receiver.
    ///
    /// To understand the second condition, consider a receiver which filters transactions based on
    /// whether it alters the UTXO set of tracked script pubkeys. If an emitted mempool transaction
    /// spends a tracked UTXO which is confirmed at height `h`, but the receiver has only seen up to
    /// block of height `h-1`, we want to re-emit this transaction until the receiver has seen the
    /// block at height `h`.
    pub new_txs: Vec<(Transaction, u64)>,

    /// [`Txid`]s of all transactions currently present in the mempool.
    ///
    /// This is useful to determine whether transactions are evicted from the mempool.
    pub all_txids: HashSet<Txid>,

    /// The latest timestamp of when a transaction entered the mempool.
    ///
    /// This is useful for setting the timestamp for evicted transactions.
    pub latest_update_time: u64,
}

Changelog notice

  • Emitter::mempool now returns a MempoolEvent.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@evanlinjin
Copy link
Member

Instead of rebasing, it's probably best to git switch -c <new-branch> from #1839 and cherry-pick on the new commits.

@LagginTimes LagginTimes marked this pull request as draft February 28, 2025 20:24
@LagginTimes LagginTimes force-pushed the mempool_evicted branch 3 times, most recently from f0b807b to 96053d3 Compare March 3, 2025 20:40
@notmandatory notmandatory added new feature New feature or request api A breaking API change labels Mar 4, 2025
evanlinjin and others added 8 commits March 6, 2025 14:01
This is a set of evicted txs from the mempool.
The evicted-at and last-evicted timestamp informs the `TxGraph` when the
transaction was last deemed as missing (evicted) from the mempool.

The canonicalization algorithm is changed to disregard transactions with
a last-evicted timestamp greater or equal to it's last-seen timestamp.
The exception is when we have a canonical descendant due to rules of
transitivity.

Update rusqlite_impl to persist `last_evicted`.

Also update docs:
* Remove duplicate paragraphs about `ChangeSet`s.
* Add "Canonicalization" section which expands on methods that require
  canonicalization and the associated data types used in the
  canonicalization algorithm.
The spk history returned from Electrum should have these txs present.
Any missing tx will be considered evicted from the mempool.
* `TxGraph::try_list_expected_spk_txids`
* `TxGraph::list_expected_spk_txids`
* `IndexedTxGraph::try_list_expected_spk_txids`
* `IndexedTxGraph::list_expected_spk_txids`

Co-authored-by: valued mammal <[email protected]>
Co-authored-by: Wei Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api A breaking API change new feature New feature or request
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants