Add virtualsize computation to mempool


Add virtualsize computation to mempool

This adds virtualsize to the mempool, which will be used for modifying
the mining/eviction priority of transactions (which matters under conditions
of mempool congestion.)
The virtual size is conceptually the actual transaction/package size with
added fudge factors to represent consumption of other block-limited resources
besides block space. Currently, just SigOps.

In Core, they don't separately track virtual size but rather use virtual size
in place of the size itself. (Core's defines it as:
size_mempool = virtualsize_mempool = max(virtualsize_bip141, sigopscount*20)

We cannot just copy Core here for two important reasons:

  • Our sigops limit varies with block size -- see comment in miner.cpp which means if we used virtualsize everywhere then we could generate invalid block templates where it it thought it had more sigops than are actually available. (this problem will be addressed with sigchecks upgrade, where the limit is flat)
  • On BCH we avoid sudden changes in basic policy rules, because we want to keep consistent mempool policy. If we changed the min feerate from sat/byte to sat/vbyte this would introduce an easy double spend vector just like if we were to suddenly raise the unconf chain length limit.

(this Diff merely adds the virtualsize computation, which is as-yet unused)

Depends on D4896 and D4905

This is an alternative to D4897, with slightly more accurate behaviour for
calculating the virtual size of packages and slightly less memory usage.
(only requires one additional tracking variable -- descendant sigops)

Test Plan: ninja check

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D4906


Mark Lundeberg <markblundeberg@users.noreply.github.com>Authored on Jan 11 2020, 06:28
markblundebergPushed on Jan 18 2020, 07:15
Restricted Project
Differential Revision
D4906: Add virtualsize computation to mempool
rABC387e98cfdff9: track descendant sigops count in mempool

Event Timeline

Mark Lundeberg <markblundeberg@users.noreply.github.com> committed rABC622df4ff0609: Add virtualsize computation to mempool (authored by Mark Lundeberg <markblundeberg@users.noreply.github.com>).Jan 18 2020, 07:15