Skip to content

Commit a5787c9

Browse files
578be36 merge bitcoin#25388: move policy constants to policy (Kittywhiskers Van Gogh) aca2c0d merge bitcoin#25254: Move minRelayTxFee to policy/settings (Kittywhiskers Van Gogh) 1d82dd8 merge bitcoin#25029: Move fee estimation RPCs to separate file (Kittywhiskers Van Gogh) ad94a30 merge bitcoin#25013: Remove cs_main from verifymessage, move msg utils to new file (Kittywhiskers Van Gogh) 8e42b12 merge bitcoin#24404: Remove confusing P1008R1 violation in ATMPArgs (Kittywhiskers Van Gogh) 006370d merge bitcoin#24582: Move txoutproof RPCs to txoutproof.cpp (Kittywhiskers Van Gogh) dfa4772 merge bitcoin#24537: Split mempool RPCs from blockchain.cpp (Kittywhiskers Van Gogh) 537d3b3 merge bitcoin#24310: docs / fixups from RBF and packages (Kittywhiskers Van Gogh) 8239d5f merge bitcoin#23804: followups for de-duplication of packages (Kittywhiskers Van Gogh) 71b2623 merge bitcoin#22674: mempool validation and submission for packages of 1 child + parents (Kittywhiskers Van Gogh) 8392d23 merge bitcoin#23381: refactoring for package submission (Kittywhiskers Van Gogh) d3c0059 merge bitcoin#22689: deprecate top-level fee fields in getmempool RPCs (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * [bitcoin#23694](bitcoin#23694) (backported in [dash#6256](#6256)) was backported before [bitcoin#22689](bitcoin#22689) and therefore, the formatting changes in the former were not incorporated in the backport. This has been resolved by accommodating them in the latter. * The fields deprecated in [bitcoin#22689](bitcoin#22689) were originally deprecated in [bitcoin#12240](bitcoin#12240) but not gated behind runtime arguments, the backport does so. * This pull request includes multiple backports that include code specific to RBF (BIP 125) and SegWit, which have been removed due to Dash Core not supporting them, comments and documentation (like `doc/policy/packages.md`) have been amended to reflect this accordingly. * When backporting [bitcoin#22674](bitcoin#22674), a new constructor was introduced for submitting `MEMPOOL_ENTRY` `ResultType`, upstream this can be done trivially as it uses function overloading ([source](https://github.com/bitcoin/bitcoin/pull/22674/files#diff-d3c243938494b10666b44404a27af7d84b44a72b85a27431e0c89e181462ca6eR198-R204)) but as Dash Core doesn't accept `replaced_txns`, there is no opportunity to differentiate arguments. * This was resolved by accepting `ResultType` as an argument but always passing `MEMPOOL_ENTRY` as the argument ([source](71b2623#diff-d3c243938494b10666b44404a27af7d84b44a72b85a27431e0c89e181462ca6eR232-R242)) * Unit tests like `package_witness_swap_tests` (introduced in [bitcoin#23804](bitcoin#23804)) have been omitted due to functionality tested not being implemented in Dash Core. Subsequent backports that include modifications to these tests have mirrored similar omissions. ## Breaking Changes * The top-level fee fields `fee`, `modifiedfee`, `ancestorfees` and `descendantfees` returned by RPCs `getmempoolentry`,`getrawmempool(verbose=true)`, `getmempoolancestors(verbose=true)` and `getmempooldescendants(verbose=true)` are deprecated and will be removed in the next major version (use `-deprecated=fees` if needed in this version). The same fee fields can be accessed through the `fees` object in the result. **WARNING: deprecated fields `ancestorfees` and `descendantfees` are denominated in sats, whereas all fields in the `fees` object are denominated in DASH.** ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK 578be36 PastaPastaPasta: utACK 578be36 Tree-SHA512: 38a62ec826f91c349269373463dd47f662cdc14dbb3c82cb5c56e779f22a2623fdce055018f15bcf6b5da029312dbcce0925545650c0eae8e3f5177812b68321
2 parents 6310321 + 578be36 commit a5787c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2055
-1151
lines changed

doc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ The Dash Core repo's [root README](/README.md) contains relevant information on
8080
- [Reduce Memory](reduce-memory.md)
8181
- [Reduce Traffic](reduce-traffic.md)
8282
- [Tor Support](tor.md)
83+
- [Transaction Relay Policy](policy/README.md)
8384
- [ZMQ](zmq.md)
8485

8586
License

doc/policy/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Transaction Relay Policy
2+
3+
Policy is a set of validation rules, in addition to consensus, enforced for unconfirmed
4+
transactions.
5+
6+
This documentation is not an exhaustive list of all policy rules.
7+
8+
- [Packages](packages.md)
9+
10+

doc/policy/packages.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Package Mempool Accept
2+
3+
## Definitions
4+
5+
A **package** is an ordered list of transactions, representable by a connected Directed Acyclic
6+
Graph (a directed edge exists between a transaction that spends the output of another transaction).
7+
8+
For every transaction `t` in a **topologically sorted** package, if any of its parents are present
9+
in the package, they appear somewhere in the list before `t`.
10+
11+
A **child-with-unconfirmed-parents** package is a topologically sorted package that consists of
12+
exactly one child and all of its unconfirmed parents (no other transactions may be present).
13+
The last transaction in the package is the child, and its package can be canonically defined based
14+
on the current state: each of its inputs must be available in the UTXO set as of the current chain
15+
tip or some preceding transaction in the package.
16+
17+
## Package Mempool Acceptance Rules
18+
19+
The following rules are enforced for all packages:
20+
21+
* Packages cannot exceed `MAX_PACKAGE_COUNT=25` count and `MAX_PACKAGE_SIZE=101KvB` total size
22+
(#20833)
23+
24+
- *Rationale*: This is already enforced as mempool ancestor/descendant limits. If
25+
transactions in a package are all related, exceeding this limit would mean that the package
26+
can either be split up or it wouldn't pass individual mempool policy.
27+
28+
- Note that, if these mempool limits change, package limits should be reconsidered. Users may
29+
also configure their mempool limits differently.
30+
31+
* Packages must be topologically sorted. (#20833)
32+
33+
* Packages cannot have conflicting transactions, i.e. no two transactions in a package can spend
34+
the same inputs. Packages cannot have duplicate transactions. (#20833)
35+
36+
* No transaction in a package can conflict with a mempool transaction.
37+
38+
* When packages are evaluated against ancestor/descendant limits, the union of all transactions'
39+
descendants and ancestors is considered. (#21800)
40+
41+
- *Rationale*: This is essentially a "worst case" heuristic intended for packages that are
42+
heavily connected, i.e. some transaction in the package is the ancestor or descendant of all
43+
the other transactions.
44+
45+
The following rules are only enforced for packages to be submitted to the mempool (not enforced for
46+
test accepts):
47+
48+
* Packages must be child-with-unconfirmed-parents packages. This also means packages must contain at
49+
least 2 transactions. (#22674)
50+
51+
* Transactions in the package that have the same txid as another transaction already in the mempool
52+
will be removed from the package prior to submission ("deduplication").
53+
54+
- *Rationale*: Node operators are free to set their mempool policies however they please, nodes
55+
may receive transactions in different orders, and malicious counterparties may try to take
56+
advantage of policy differences to pin or delay propagation of transactions. As such, it's
57+
possible for some package transaction(s) to already be in the mempool, and there is no need to
58+
repeat validation for those transactions or double-count them in fees.
59+
60+
- *Rationale*: We want to prevent potential censorship vectors. We should not reject entire
61+
packages because we already have one of the transactions. Also, if an attacker first broadcasts
62+
a competing package, the honest package should still be considered for acceptance.

doc/release-notes-6499.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Updated RPCs
2+
------------
3+
4+
- The top-level fee fields `fee`, `modifiedfee`, `ancestorfees` and `descendantfees`
5+
returned by RPCs `getmempoolentry`,`getrawmempool(verbose=true)`,
6+
`getmempoolancestors(verbose=true)` and `getmempooldescendants(verbose=true)`
7+
are deprecated and will be removed in the next major version (use
8+
`-deprecated=fees` if needed in this version). The same fee fields can be accessed
9+
through the `fees` object in the result. WARNING: deprecated
10+
fields `ancestorfees` and `descendantfees` are denominated in sats, whereas all
11+
fields in the `fees` object are denominated in DASH.

src/Makefile.am

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ BITCOIN_CORE_H = \
300300
rpc/blockchain.h \
301301
rpc/client.h \
302302
rpc/index_util.h \
303+
rpc/mempool.h \
303304
rpc/mining.h \
304305
rpc/protocol.h \
305306
rpc/rawtransaction_util.h \
@@ -528,8 +529,10 @@ libbitcoin_server_a_SOURCES = \
528529
rpc/blockchain.cpp \
529530
rpc/coinjoin.cpp \
530531
rpc/evo.cpp \
532+
rpc/fees.cpp \
531533
rpc/index_util.cpp \
532534
rpc/masternode.cpp \
535+
rpc/mempool.cpp \
533536
rpc/governance.cpp \
534537
rpc/mining.cpp \
535538
rpc/misc.cpp \
@@ -538,6 +541,8 @@ libbitcoin_server_a_SOURCES = \
538541
rpc/rawtransaction.cpp \
539542
rpc/server.cpp \
540543
rpc/server_util.cpp \
544+
rpc/signmessage.cpp \
545+
rpc/txoutproof.cpp \
541546
script/sigcache.cpp \
542547
shutdown.cpp \
543548
spork.cpp \

src/Makefile.test.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ BITCOIN_TESTS =\
174174
test/torcontrol_tests.cpp \
175175
test/transaction_tests.cpp \
176176
test/txindex_tests.cpp \
177+
test/txpackage_tests.cpp \
177178
test/txreconciliation_tests.cpp \
178179
test/txvalidation_tests.cpp \
179180
test/txvalidationcache_tests.cpp \

src/bench/rpc_mempool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <bench/bench.h>
6-
#include <rpc/blockchain.h>
6+
#include <rpc/mempool.h>
77
#include <txmempool.h>
88

99
#include <univalue.h>

src/net_processing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <node/blockstorage.h>
2323
#include <node/txreconciliation.h>
2424
#include <policy/policy.h>
25+
#include <policy/settings.h>
2526
#include <primitives/block.h>
2627
#include <primitives/transaction.h>
2728
#include <random.h>

src/policy/feerate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6+
#include <consensus/amount.h>
67
#include <policy/feerate.h>
7-
88
#include <tinyformat.h>
99

1010
CFeeRate::CFeeRate(const CAmount& nFeePaid, uint32_t num_bytes)

src/policy/feerate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
#include <consensus/amount.h>
1010
#include <serialize.h>
1111

12+
13+
#include <cstdint>
1214
#include <string>
15+
#include <type_traits>
1316

1417
const std::string CURRENCY_UNIT = "DASH"; // One formatted unit
1518
const std::string CURRENCY_ATOM = "duff"; // One indivisible minimum value unit

0 commit comments

Comments
 (0)