Skip to content

Mempool: snapshotFromValidTxs rebuilds the GenTxId set on every snapshot #2111

Description

@dnadales

snapshotFromValidTxs builds txIds = Set.fromList (map txId validTxs) for snapshotHasTx on every snapshot.
getSnapshot calls it per invocation, and the tx-submission mempool reader snapshots on every read, so the O(n log n) rebuild runs often.

The InternalState already maintains isTxIds :: Set (GenTxId blk) incrementally.
The snapshotFromIS/getSnapshot path could reuse it instead of rebuilding.
(The revalidation path computeSnapshot builds a fresh tx list, so it would still rebuild.)

Orthogonal to #2003: this is about how often the set is built, not the per-comparison cost.
Found while analysing #2003.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions