Skip to content

mempool cache: use a fast hash #2187

@ValarDragon

Description

@ValarDragon

Tx hashes aren't consensus critical. AFAIK, they are only used to know if your transaction appeared on chain. A second use case being considered is within the mempool to save on memory stored.

For the latter use-case, it definitely makes sense to use a faster hash. We could use https://en.wikipedia.org/wiki/HighwayHash, which is 30x faster than the standard SHA2. (Source: https://blog.minio.io/highwayhash-fast-hashing-at-over-10-gb-s-per-core-in-golang-fee938b5218a?gi=34fcf777b99e). Its not a cryptographic hash (as it hasn't received enough review / analysis yet), however I believe that the authors are currently analyzing it, and have proven security against differential analysis. Using something fast for the mempool is likely safe, since the worst that can happen is one tx gets marked as a duplicate (and which one gets marked as dupe depends on order received, so its likely that one proposer will eventually get one correct one).

Its significantly harder to find collisions between txs than it is to find collisions in random messages, since signatures bottleneck the amount of txs you can create. Because of this, it may be worth considering even using HighwayHash for normal TxHashes. This is a much more minute point, so we should use the faster hash for the mempool cache at least.

Highway hash is 10x faster than blake2b on a single core. For language support, highway hash has bindings for C, Golang, Rust, Python3, JS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C:mempoolComponent: MempoolT:perfType: Performancestalefor use by stalebot

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions