dash/test/functional/test_framework
fanquake 1a8268770c
Merge bitcoin/bitcoin#21800: mempool/validation: mempool ancestor/descendant limits for packages
accf3d5868460b4b14ab607fd66ac985b086fbb3 [test] mempool package ancestor/descendant limits (glozow)
2b6b26e57c24d2f0abd442c1c33098e3121572ce [test] parameterizable fee for make_chain and create_child_with_parents (glozow)
313c09f7b7beddfdb74c284720d209c81dfdb94f [test] helper function to increase transaction weight (glozow)
f8253d69d6f02850995a11eeb71fedc22e6f6575 extract/rename helper functions from rpc_packages.py (glozow)
3cd663a5d33aa7ef87994e452bced7f192d021a0 [policy] ancestor/descendant limits for packages (glozow)
c6e016aa139c8363e9b38bbc1ba0dca55700b8a7 [mempool] check ancestor/descendant limits for packages (glozow)
f551841d3ec080a2d7a7988c7b35088dff6c5830 [refactor] pass size/count instead of entry to CalculateAncestorsAndCheckLimits (glozow)
97dd1c729d2bbedf9527b914c0cc8267b8a7c21b MOVEONLY: add helper function for calculating ancestors and checking limits (glozow)
f95bbf58aaf72aab8a9c5827b1f162f3b8ac38f4 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
Signed-off-by: Vijay <vijaydas.mp@gmail.com>
2024-08-29 10:01:28 +05:30
..
crypto merge bitcoin#28374: python cryptography required for BIP 324 functional tests 2024-03-05 21:43:22 +00:00
__init__.py
address.py Merge bitcoin#22593: remove hex_str_to_bytes helper 2024-08-25 07:55:20 +05:30
authproxy.py
bdb.py Merge bitcoin/bitcoin#22619: test: refactor: use consistent bytes <-> hex-string conversion in functional test framework 2024-08-25 07:55:13 +05:30
bip340_test_vectors.csv
blockfilter.py merge bitcoin#28374: python cryptography required for BIP 324 functional tests 2024-03-05 21:43:22 +00:00
blocktools.py Merge #6071: backport: Merge bitcoin#22619, 22593 2024-08-28 12:17:01 -05:00
coverage.py
descriptors.py
governance.py refactor: move common duplicated code to test_framework/governance.py 2024-08-14 15:33:53 +07:00
key.py Merge #19239: tests: move generate_wif_key to wallet_util.py 2024-03-09 03:00:27 +07:00
messages.py Merge bitcoin/bitcoin#21800: mempool/validation: mempool ancestor/descendant limits for packages 2024-08-29 10:01:28 +05:30
netutil.py Merge bitcoin/bitcoin#22619: test: refactor: use consistent bytes <-> hex-string conversion in functional test framework 2024-08-25 07:55:13 +05:30
p2p.py Merge #5978: backport: merge bitcoin#21594, #21843, #22306, #22211, #22387, #21528, #22616, #22604, #22960, #23218 (networking backports: part 3) 2024-04-15 10:49:14 -05:00
script_util.py Merge bitcoin#22593: remove hex_str_to_bytes helper 2024-08-25 07:55:20 +05:30
script.py merge bitcoin#28374: python cryptography required for BIP 324 functional tests 2024-03-05 21:43:22 +00:00
socks5.py
test_framework.py Merge #6071: backport: Merge bitcoin#22619, 22593 2024-08-28 12:17:01 -05:00
test_node.py fix: createwallet to require 'load_on_startup' for descriptor wallets 2024-07-07 21:56:16 +07:00
test_shell.py
util.py Merge bitcoin#22593: remove hex_str_to_bytes helper 2024-08-25 07:55:20 +05:30
wallet_util.py Merge bitcoin#22593: remove hex_str_to_bytes helper 2024-08-25 07:55:20 +05:30
wallet.py Merge bitcoin/bitcoin#21800: mempool/validation: mempool ancestor/descendant limits for packages 2024-08-29 10:01:28 +05:30