Page MenuHomePhabricator

Add virtualsize computation to mempool
ClosedPublic

Authored by markblundeberg on Jan 12 2020, 05:07.

Details

Summary

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

Diff Detail

Repository
rABC Bitcoin ABC
Branch
virtualsize-comp
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 8883
Build 15741: Default Diff Build & Tests
Build 15740: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Jan 12 2020, 14:56