0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00
bitcoin-core/src
fanquake 21438d55d5
Merge bitcoin/bitcoin#21800: mempool/validation: mempool ancestor/descendant limits for packages
accf3d5868 [test] mempool package ancestor/descendant limits (glozow)
2b6b26e57c [test] parameterizable fee for make_chain and create_child_with_parents (glozow)
313c09f7b7 [test] helper function to increase transaction weight (glozow)
f8253d69d6 extract/rename helper functions from rpc_packages.py (glozow)
3cd663a5d3 [policy] ancestor/descendant limits for packages (glozow)
c6e016aa13 [mempool] check ancestor/descendant limits for packages (glozow)
f551841d3e [refactor] pass size/count instead of entry to CalculateAncestorsAndCheckLimits (glozow)
97dd1c729d MOVEONLY: add helper function for calculating ancestors and checking limits (glozow)
f95bbf58aa misc package validation doc improvements (glozow)

Pull request description:

  This PR implements a function to calculate mempool ancestors for a package and enforces ancestor/descendant limits on them as a whole. It reuses a portion of `CalculateMemPoolAncestors()`; there's also a small refactor to move the reused code into a generic helper function. Instead of calculating ancestors and descendants on every single transaction in the package and their ancestors, we use a "worst case" heuristic, treating every transaction in the package as each other's ancestor and descendant. This may overestimate everyone's counts, but is still pretty accurate in the our main package use cases, in which at least one of the transactions in the package is directly related to all the others (e.g. 1 parent + 1 child, multiple parents with 1 child, or chains).

  Note on Terminology: While "package" is often used to describe groups of related transactions _within_ the mempool, here, I only use package to mean the group of not-in-mempool transactions we are currently validating.

  #### Motivation

  It would be a potential DoS vector to allow submission of packages to mempool without a proper guard for mempool ancestors/descendants. In general, the purpose of mempool ancestor/descendant limits is to limit the computational complexity of dealing with families during removals and additions. We want to be able to validate multiple transactions on top of the mempool, but also avoid these scenarios:

  - We underestimate the ancestors/descendants during package validation and end up with extremely complex families in our mempool (potentially a DoS vector).
  - We expend an unreasonable amount of resources calculating everyone's ancestors and descendants during package validation.

ACKs for top commit:
  JeremyRubin:
    utACK accf3d5
  ariard:
    ACK accf3d5.

Tree-SHA512: 0d18ce4b77398fe872e0b7c2cc66d3aac2135e561b64029584339e1f4de2a6a16ebab3dd5784f376e119cbafc4d50168b28d3bd95d0b3d01158714ade2e3624d
2021-08-09 12:23:39 +08:00
..
bench Merge bitcoin/bitcoin#22232: refactor: Pass interpreter flags as uint32_t instead of signed int 2021-07-20 15:36:23 +02:00
compat Remove support for double serialization 2021-05-24 16:15:05 -07:00
config
consensus consensus/params: simplify ValidDeployment check to avoid gcc warning 2021-08-02 23:48:32 +10:00
crc32c
crypto
index Merge bitcoin/bitcoin#22047: index, rpc: Coinstatsindex follow-ups 2021-07-28 15:19:34 +02:00
init Make SetupServerArgs callable without NodeContext 2021-06-10 09:58:45 -05:00
interfaces Merge bitcoin/bitcoin#22218: multiprocess: Add ipc::Context and ipc::capnp::Context structs 2021-07-22 08:26:30 +02:00
ipc Add ipc::Context and ipc::capnp::Context structs 2021-06-10 09:58:45 -05:00
leveldb
logging
node [GetTransaction] remove unneeded cs_main lock acquire 2021-08-02 18:31:02 +02:00
policy MOVEONLY: context-free package policies 2021-06-02 17:26:44 +01:00
primitives
qt Merge bitcoin-core/gui#396: Ensure external signer option remains disabled without signers 2021-08-06 19:17:09 +03:00
rpc Merge bitcoin/bitcoin#21800: mempool/validation: mempool ancestor/descendant limits for packages 2021-08-09 12:23:39 +08:00
script Merge bitcoin/bitcoin#22337: wallet: Use bilingual_str for errors 2021-08-09 14:45:12 +12:00
secp256k1 Update secp256k1 subtree to latest upstream + adapt API 2021-07-14 14:43:45 -07:00
support
test Merge bitcoin/bitcoin#22337: wallet: Use bilingual_str for errors 2021-08-09 14:45:12 +12:00
univalue
util Merge bitcoin/bitcoin#22337: wallet: Use bilingual_str for errors 2021-08-09 14:45:12 +12:00
wallet Merge bitcoin/bitcoin#22337: wallet: Use bilingual_str for errors 2021-08-09 14:45:12 +12:00
zmq zmq: use msg: prefix over errno= in zmqError 2021-06-09 19:25:13 +08:00
.clang-format
addrdb.cpp Ignore banlist.dat 2021-07-30 11:21:51 +02:00
addrdb.h Ignore banlist.dat 2021-07-30 11:21:51 +02:00
addrman.cpp Merge bitcoin/bitcoin#22496: addrman: Remove addrman hotfixes 2021-08-03 15:40:32 +08:00
addrman.h Merge bitcoin/bitcoin#21129: fuzz: check that ser+unser produces the same AddrMan 2021-08-05 15:17:50 +02:00
amount.h
arith_uint256.cpp
arith_uint256.h
attributes.h
banman.cpp Ignore banlist.dat 2021-07-30 11:21:51 +02:00
banman.h Ignore banlist.dat 2021-07-30 11:21:51 +02:00
base58.cpp
base58.h
bech32.cpp
bech32.h
bitcoin-cli-res.rc
bitcoin-cli.cpp cli: Implement human readable -getinfo. 2021-07-21 19:27:04 +08:00
bitcoin-tx-res.rc
bitcoin-tx.cpp Add support for SIGHASH_DEFAULT in RPCs, and make it default 2021-06-12 12:38:17 -07:00
bitcoin-util-res.rc
bitcoin-util.cpp refactor: Pass grind args vector as const reference 2021-06-18 20:10:07 +02:00
bitcoin-wallet-res.rc
bitcoin-wallet.cpp Remove unused OptionsCategory arg from AddCommand 2021-06-18 20:09:23 +02:00
bitcoind-res.rc
bitcoind.cpp Make SetupServerArgs callable without NodeContext 2021-06-10 09:58:45 -05:00
blockencodings.cpp
blockencodings.h
blockfilter.cpp
blockfilter.h
bloom.cpp
bloom.h
chain.cpp
chain.h doc: Various validation doc fixups 2021-06-03 13:53:31 +02:00
chainparams.cpp Merge bitcoin/bitcoin#16333: test: Set BIP34Height = 2 for regtest 2021-08-03 10:10:43 +02:00
chainparams.h net: distinguish default port per network 2021-07-09 11:19:36 +02:00
chainparamsbase.cpp [p2p] remove unused segwitheight=-1 option 2021-07-07 22:13:01 -07:00
chainparamsbase.h
chainparamsseeds.h contrib, p2p: update I2P hardcoded seeds 2021-07-30 11:03:44 +02:00
checkqueue.h
clientversion.cpp
clientversion.h
coins.cpp refactor: wrap CCoinsViewCursor in unique_ptr 2021-06-17 09:47:08 -04:00
coins.h refactor: wrap CCoinsViewCursor in unique_ptr 2021-06-17 09:47:08 -04:00
compat.h
compressor.cpp refactor: Use CPubKey vector constructor where possible 2021-05-04 06:53:32 +02:00
compressor.h
core_io.h
core_memusage.h
core_read.cpp Add support for SIGHASH_DEFAULT in RPCs, and make it default 2021-06-12 12:38:17 -07:00
core_write.cpp
cuckoocache.h
dbwrapper.cpp refactor: Use only one temporary buffer in CreateObfuscateKey 2021-05-04 06:53:37 +02:00
dbwrapper.h
deploymentinfo.cpp deploymentinfo: Add DeploymentName() 2021-06-30 08:19:12 +10:00
deploymentinfo.h deploymentinfo: Add DeploymentName() 2021-06-30 08:19:12 +10:00
deploymentstatus.cpp consensus/params: simplify ValidDeployment check to avoid gcc warning 2021-08-02 23:48:32 +10:00
deploymentstatus.h Use DeploymentEnabled to hide VB deployments 2021-07-01 20:20:52 +02:00
dummywallet.cpp
external_signer.cpp refactor: make ExternalSigner NetworkArg() and m_chain private 2021-06-16 10:48:58 +02:00
external_signer.h refactor: make ExternalSigner NetworkArg() and m_chain private 2021-06-16 10:48:58 +02:00
flatfile.cpp
flatfile.h
fs.cpp
fs.h
hash.cpp Use C++17 [[fallthrough]] attribute, and drop -Wno-implicit-fallthrough 2021-07-05 08:59:38 +03:00
hash.h
httprpc.cpp
httprpc.h
httpserver.cpp refactor: Make httpserver work queue a unique_ptr 2021-06-28 11:47:05 +02:00
httpserver.h
i2p.cpp net: do not connect to I2P hosts on port!=0 2021-07-09 11:19:37 +02:00
i2p.h
indirectmap.h
init.cpp Merge bitcoin/bitcoin#22577: Close minor startup race between main and scheduler threads 2021-08-04 16:37:12 +02:00
init.h init: remove straggling boost thread_group code 2021-07-12 21:46:59 +08:00
key.cpp Update secp256k1 subtree to latest upstream + adapt API 2021-07-14 14:43:45 -07:00
key.h Add CKey::SignSchnorr function for BIP 340/341 signing 2021-06-12 12:25:28 -07:00
key_io.cpp Separate WitnessV1Taproot variant in CTxDestination 2021-05-24 12:14:16 -07:00
key_io.h
logging.cpp log, refactor: use guard clause in LogCategoriesList() 2021-07-22 23:09:52 +02:00
logging.h log: sort LogCategoriesList and LogCategoriesString alphabetically 2021-07-22 23:09:42 +02:00
Makefile.am Merge bitcoin/bitcoin#22218: multiprocess: Add ipc::Context and ipc::capnp::Context structs 2021-07-22 08:26:30 +02:00
Makefile.bench.include bench: add peer eviction protection benchmarks 2021-07-08 12:28:23 +02:00
Makefile.crc32c.include
Makefile.leveldb.include Use C++17 [[fallthrough]] attribute, and drop -Wno-implicit-fallthrough 2021-07-05 08:59:38 +03:00
Makefile.qt.include qt, refactor: Move InitExecutor class into its own module 2021-07-14 21:54:32 +03:00
Makefile.qt_locale.include
Makefile.qttest.include
Makefile.test.include Merge bitcoin/bitcoin#21882: build: Fix undefined reference to __mulodi4 2021-07-29 20:53:36 +08:00
Makefile.test_fuzz.include
Makefile.test_util.include
mapport.cpp
mapport.h
memusage.h
merkleblock.cpp
merkleblock.h
miner.cpp [refactor] Move ComputeBlockVersion into VersionBitsCache 2021-06-30 08:19:12 +10:00
miner.h miner: Pass in chainman to RegenerateCommitments 2021-05-27 13:50:11 -04:00
net.cpp tracing: Tracepoints for in- and outbound P2P msgs 2021-07-27 17:12:16 +02:00
net.h Merge bitcoin/bitcoin#22098: [test, init] DNS seed querying logic 2021-08-03 11:21:15 +08:00
net_permissions.cpp p2p: pass strings to NetPermissions::TryParse functions by const ref 2021-05-19 19:41:05 +02:00
net_permissions.h Rate limit the processing of incoming addr messages 2021-07-15 12:52:38 -07:00
net_processing.cpp Merge bitcoin/bitcoin#22618: [p2p] Small follow-ups to 21528 2021-08-05 09:29:54 +02:00
net_processing.h Merge bitcoin/bitcoin#22577: Close minor startup race between main and scheduler threads 2021-08-04 16:37:12 +02:00
net_types.h
netaddress.cpp Merge bitcoin/bitcoin#22179: Torv2 removal followups 2021-07-08 17:20:35 +02:00
netaddress.h Fix whitespace in touched files 2021-07-30 11:24:59 +02:00
netbase.cpp
netbase.h
netmessagemaker.h
noui.cpp
noui.h
outputtype.cpp make ParseOutputType return a std::optional<OutputType> 2021-08-04 19:20:32 +08:00
outputtype.h make ParseOutputType return a std::optional<OutputType> 2021-08-04 19:20:32 +08:00
pow.cpp
pow.h
prevector.h
protocol.cpp refactor: Replace memset calls with array initialization 2021-05-13 12:42:21 +01:00
protocol.h Add roundtrip fuzz tests for CAddress serialization 2021-05-24 18:06:35 -07:00
psbt.cpp Make GetInputUTXO safer: verify non-witness UTXO match 2021-06-12 12:25:28 -07:00
psbt.h Construct and use PrecomputedTransactionData in PSBT signing 2021-06-12 12:25:28 -07:00
pubkey.cpp Update secp256k1 subtree to latest upstream + adapt API 2021-07-14 14:43:45 -07:00
pubkey.h Add CKey::SignSchnorr function for BIP 340/341 signing 2021-06-12 12:25:28 -07:00
random.cpp refactor: Replace &foo[0] with foo.data() 2021-05-04 06:55:31 +02:00
random.h
randomenv.cpp
randomenv.h
rest.cpp Use C++17 [[fallthrough]] attribute, and drop -Wno-implicit-fallthrough 2021-07-05 08:59:38 +03:00
reverse_iterator.h
scheduler.cpp test: Fix off-by-one in mockscheduler test RPC 2021-05-14 12:49:16 +02:00
scheduler.h
serialize.h refactor: Switch serialize to uint8_t (1/n) 2021-05-31 14:56:17 +02:00
shutdown.cpp
shutdown.h
signet.cpp
signet.h
span.h
streams.h streams: Accept URef obj for VectorReader unserialize 2021-05-05 20:19:03 +02:00
sync.cpp
sync.h
threadinterrupt.cpp
threadinterrupt.h
threadsafety.h
timedata.cpp
timedata.h
tinyformat.h Use C++17 [[fallthrough]] attribute, and drop -Wno-implicit-fallthrough 2021-07-05 08:59:38 +03:00
torcontrol.cpp torcontrol: Resolve Tor control plane address 2021-06-27 19:27:25 +02:00
torcontrol.h
txdb.cpp doc: add comment about CCoinsViewDBCursor constructor 2021-06-18 14:15:39 -04:00
txdb.h move-only(ish): don't expose CCoinsViewDBCursor 2021-06-18 14:14:15 -04:00
txmempool.cpp [mempool] check ancestor/descendant limits for packages 2021-08-05 12:37:28 +01:00
txmempool.h [mempool] check ancestor/descendant limits for packages 2021-08-05 12:37:28 +01:00
txorphanage.cpp
txorphanage.h [net processing] Add Orphanage empty consistency check 2021-07-20 13:12:42 +01:00
txrequest.cpp
txrequest.h
uint256.cpp
uint256.h Make XOnlyPubKey act like byte container 2021-05-24 12:14:16 -07:00
undo.h
validation.cpp [policy] ancestor/descendant limits for packages 2021-08-06 10:04:59 +01:00
validation.h misc package validation doc improvements 2021-08-05 12:37:28 +01:00
validationinterface.cpp
validationinterface.h
version.h
versionbits.cpp [refactor] Move ComputeBlockVersion into VersionBitsCache 2021-06-30 08:19:12 +10:00
versionbits.h [refactor] Move ComputeBlockVersion into VersionBitsCache 2021-06-30 08:19:12 +10:00
walletinitinterface.h
warnings.cpp
warnings.h