@sipa @sdaftuar @jtimon @petertodd OK, this is the best combination of approaches I could put together.
I took #6455 and I removed the floating relay fee commit. I really like that idea, but it needs to be much slower acting I think and not subject to potential abuse. That can be a later improvement.
I added 3 things:
- Reserved space between the soft cap and hard cap. The soft cap is currently set to 70% of the hard cap. Once the soft cap is hit, you first try to evict as in 6455, but if you fail, you have another chance to get in if you are still under the hard cap. There are 10 “rate zones” between the hard cap and soft cap and the effective minRelayRate to get into the mempool doubles for each additional zone.
- Any required minRelayFee for your transaction alone is considered inside the StageTrimToSize loop.
- Periodically (once a second) we use the knowledge that surplus fees over the minRelayRate must have been paid if the size of the mempool is over the soft cap. We use these fees in aggregate to try to trim from the bottom of the mempool. This allows us to aggregate many small high fee transactions to evict a low paying large transaction or long chain.
The reject rates in my test setup have dropped to 0.3% for 30k feerate tx’s and 0.05% for 60k feerate tx’s. (See other results in #6455).
I made an attempt to tweak the looping parameters in StageTrimToSize to something that I think made sense, but with the contrived test setup, and only one set of simulation data, they are probably best evaluated on the basis of intuition and not relying entirely on the resulting rejection rates.
It turns out the slowest part of StageTrimToSize was GetRand() by a long shot, so I hacked it out, but I’m sure @sipa will want to replace my hack with something nicer.
The code works as is, but could still use some work, but I think its time to get more eyes on this suggestion for a plan forward.