Part of #30289.
Before, the implicit ordering of transactions in a TxGraph’s main graph is sorted by:
- feerate, high to low
Cluster
, low to highm_sequence
- linearization order within clusters
However, since m_sequence
values are assigned deterministically and predictably, the ordering of same-feerate distinct-Cluster transactions can reveal something about the order they were inserted into TxGraph
.
In #28676, this ordering (through TxGraph::CompareMainOrder
) is used to decide the order of to-be-announced transactions. These should not expose information about insertion order.
To deal with this, do not compare the m_sequence
values directly, but hash them with a fixed but random key first. In case this yields a collision (which needs ~192000 clusters to have a probability of 10^-9 of existing), fall back to comparing the m_sequence
values directly.
Alternatives: we could instead use the pre-cluster-mempool approach of sorting by wtxid in case of ties, which is equally non-revealing, and deterministic. I find it cleaner to have a randomized internal total ordering rather than needing a partial ordering within TxGraph
that needs to be complemented by tie-breaking logic inside the mempool, however, and I don’t think the determinism is that valuable.
For context: #28676 (review)