v29.4-roots.4 · Commit 3: [PATCH 03/37] policy: restore conservative relay and network controls
src/policy/policy.h
Before: src/policy/policy.h · After: src/policy/policy.h
File metadata
index a6ce608bcfad04dd1d5f9d854f29321890c77419..a03289133ac818684799c0091dc0e80b851a6cc8 100644
Download original patch · Release notes
Diff rows 1–146 of 146. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
src/policy/policy.h
CHANGED
|
@@ -14,13 +14,26 @@
|
|
|
14
14
|
|
|
15
15
|
#include <cstdint>
|
|
16
16
|
#include <string>
|
|
17
|
+
#include <unordered_set>
|
|
18
|
+
#include <utility>
|
|
17
19
|
|
|
18
20
|
class CCoinsViewCache;
|
|
19
21
|
class CFeeRate;
|
|
20
22
|
class CScript;
|
|
21
|
-
|
|
23
|
+
namespace kernel {
|
|
24
|
+
struct MemPoolOptions;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** Default for -blockmaxsize, which controls the maximum size of block the mining code will create **/
|
|
28
|
+
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 300000;
|
|
29
|
+
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
|
|
30
|
+
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 100000;
|
|
31
|
+
/** Minimum priority for transactions to be accepted into the priority area **/
|
|
32
|
+
static const double MINIMUM_TX_PRIORITY = COIN * 144 / 250;
|
|
22
33
|
/** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/
|
|
23
|
-
static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{MAX_BLOCK_WEIGHT};
|
|
34
|
+
static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{DEFAULT_BLOCK_MAX_SIZE * WITNESS_SCALE_FACTOR};
|
|
35
|
+
/** Default for BlockCreateOptions.block_reserved_size **/
|
|
36
|
+
static constexpr unsigned int DEFAULT_BLOCK_RESERVED_SIZE{1000};
|
|
24
37
|
/** Default for -blockreservedweight **/
|
|
25
38
|
static constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT{8000};
|
|
26
39
|
/** This accounts for the block header, var_int encoding of the transaction count and a minimally viable
|
|
@@ -29,7 +42,7 @@ static constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT{8000};
|
|
|
29
42
|
* Setting a lower value is prevented at startup. */
|
|
30
43
|
static constexpr unsigned int MINIMUM_BLOCK_RESERVED_WEIGHT{2000};
|
|
31
44
|
/** Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code **/
|
|
32
|
-
static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1};
|
|
45
|
+
static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1000};
|
|
33
46
|
/** The maximum weight for transactions we're willing to relay/mine */
|
|
34
47
|
static constexpr int32_t MAX_STANDARD_TX_WEIGHT{400000};
|
|
35
48
|
/** The minimum non-witness size for transactions we're willing to relay/mine: one larger than 64 */
|
|
@@ -41,11 +54,37 @@ static constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/
|
|
|
41
54
|
/** The maximum number of potentially executed legacy signature operations in a single standard tx */
|
|
42
55
|
static constexpr unsigned int MAX_TX_LEGACY_SIGOPS{2'500};
|
|
43
56
|
/** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or replacement **/
|
|
44
|
-
static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{100};
|
|
57
|
+
static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{1000};
|
|
58
|
+
static constexpr CAmount CORE_INCREMENTAL_RELAY_FEE{100};
|
|
59
|
+
/** Default for -maxscriptsize */
|
|
60
|
+
static constexpr unsigned int DEFAULT_SCRIPT_SIZE_POLICY_LIMIT{1650};
|
|
45
61
|
/** Default for -bytespersigop */
|
|
46
62
|
static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20};
|
|
63
|
+
/** Default for -bytespersigopstrict */
|
|
64
|
+
static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP_STRICT{20};
|
|
65
|
+
/** Default for -datacarriercost (multiplied by WITNESS_SCALE_FACTOR) */
|
|
66
|
+
static constexpr unsigned int DEFAULT_WEIGHT_PER_DATA_BYTE{4};
|
|
67
|
+
/** Default for -rejecttokens */
|
|
68
|
+
static constexpr bool DEFAULT_REJECT_TOKENS{false};
|
|
69
|
+
/** Default for -subdustfeepenalty */
|
|
70
|
+
static constexpr bool DEFAULT_SUBDUSTFEEPENALTY{true};
|
|
71
|
+
|
|
72
|
+
// NOTE: Changes to these three require manually adjusting doc in init.cpp
|
|
73
|
+
/** Default for -permitephemeral=send */
|
|
74
|
+
static constexpr bool DEFAULT_PERMITEPHEMERAL_SEND{false};
|
|
75
|
+
/** Default for -permitephemeral=dust */
|
|
76
|
+
static constexpr bool DEFAULT_PERMITEPHEMERAL_DUST{false};
|
|
77
|
+
/** Default for -permitephemeral=anchor */
|
|
78
|
+
static constexpr bool DEFAULT_PERMITEPHEMERAL_ANCHOR{true};
|
|
79
|
+
|
|
80
|
+
/** Default for -permitbareanchor */
|
|
81
|
+
static constexpr bool DEFAULT_PERMITBAREANCHOR{true};
|
|
82
|
+
/** Default for -permitbarepubkey */
|
|
83
|
+
static constexpr bool DEFAULT_PERMIT_BAREPUBKEY{false};
|
|
47
84
|
/** Default for -permitbaremultisig */
|
|
48
|
-
static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true};
|
|
85
|
+
static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{false};
|
|
86
|
+
/** Default for -rejectparasites */
|
|
87
|
+
static constexpr bool DEFAULT_REJECT_PARASITES{true};
|
|
49
88
|
/** The maximum number of witness stack items in a standard P2WSH script */
|
|
50
89
|
static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100};
|
|
51
90
|
/** The maximum size in bytes of each witness stack item in a standard P2WSH script */
|
|
@@ -62,8 +101,11 @@ static constexpr unsigned int MAX_STANDARD_SCRIPTSIG_SIZE{1650};
|
|
|
62
101
|
* only increase the dust limit after prior releases were already not creating
|
|
63
102
|
* outputs below the new threshold */
|
|
64
103
|
static constexpr unsigned int DUST_RELAY_TX_FEE{3000};
|
|
104
|
+
static const std::string DEFAULT_DUST_DYNAMIC{"off"};
|
|
105
|
+
static const int DEFAULT_DUST_RELAY_MULTIPLIER{3'000};
|
|
106
|
+
static const std::string DEFAULT_SPKREUSE{"allow"};
|
|
65
107
|
/** Default for -minrelaytxfee, minimum relay fee for transactions */
|
|
66
|
-
static constexpr unsigned int DEFAULT_MIN_RELAY_TX_FEE{100};
|
|
108
|
+
static constexpr unsigned int DEFAULT_MIN_RELAY_TX_FEE{1000};
|
|
67
109
|
/** Default for -limitancestorcount, max number of in-mempool ancestors */
|
|
68
110
|
static constexpr unsigned int DEFAULT_ANCESTOR_LIMIT{25};
|
|
69
111
|
/** Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors */
|
|
@@ -78,7 +120,11 @@ static const bool DEFAULT_ACCEPT_DATACARRIER = true;
|
|
|
78
120
|
* Default setting for -datacarriersize. 80 bytes of data, +1 for OP_RETURN,
|
|
79
121
|
* +2 for the pushdata opcodes.
|
|
80
122
|
*/
|
|
123
|
+
/** Default for -permitbaredatacarrier */
|
|
124
|
+
static const bool DEFAULT_PERMITBAREDATACARRIER{false};
|
|
81
125
|
static const unsigned int MAX_OP_RETURN_RELAY = 83;
|
|
126
|
+
/** Default for -datacarrierfullcount */
|
|
127
|
+
static constexpr bool DEFAULT_DATACARRIER_FULLCOUNT{true};
|
|
82
128
|
/**
|
|
83
129
|
* An extra transaction can be added to a package, as long as it only has one
|
|
84
130
|
* ancestor and is no larger than this. Not really any reason to make this
|
|
@@ -134,6 +180,9 @@ static constexpr unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS{STANDARD_SCRIP
|
|
|
134
180
|
/** Used as the flags parameter to sequence and nLocktime checks in non-consensus code. */
|
|
135
181
|
static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQUENCE};
|
|
136
182
|
|
|
183
|
+
typedef std::unordered_set<std::string> ignore_rejects_type;
|
|
184
|
+
static const ignore_rejects_type empty_ignore_rejects{};
|
|
185
|
+
|
|
137
186
|
CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee);
|
|
138
187
|
|
|
139
188
|
bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee);
|
|
@@ -152,13 +201,19 @@ static constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3};
|
|
|
152
201
|
* Check for standard transaction types
|
|
153
202
|
* @return True if all outputs (scriptPubKeys) use only standard transaction forms
|
|
154
203
|
*/
|
|
155
|
-
bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, std::string& reason);
|
|
204
|
+
bool IsStandardTx(const CTransaction& tx, const kernel::MemPoolOptions& opts, std::string& out_reason, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects);
|
|
205
|
+
// Compatibility entry point for existing unit tests. Production admission uses
|
|
206
|
+
// the MemPoolOptions overload above so every policy setting is explicit.
|
|
207
|
+
bool IsStandardTx(const CTransaction& tx, unsigned int max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_feerate, std::string& out_reason);
|
|
156
208
|
/**
|
|
157
209
|
* Check for standard transaction types
|
|
158
210
|
* @param[in] mapInputs Map of previous transactions that have outputs we're spending
|
|
159
211
|
* @return True if all inputs (scriptSigs) use only standard transaction forms
|
|
160
212
|
*/
|
|
161
|
-
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs);
|
|
213
|
+
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, const kernel::MemPoolOptions& opts, const std::string& reason_prefix, std::string& out_reason, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects);
|
|
214
|
+
|
|
215
|
+
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& map_inputs);
|
|
216
|
+
|
|
162
217
|
/**
|
|
163
218
|
* Check if the transaction is over standard P2WSH resources limit:
|
|
164
219
|
* 3600bytes witnessScript size, 80bytes per witness stack element, 100 witness stack elements
|
|
@@ -166,7 +221,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
|
|
|
166
221
|
*
|
|
167
222
|
* Also enforce a maximum stack item size limit and no annexes for tapscript spends.
|
|
168
223
|
*/
|
|
169
|
-
bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs);
|
|
224
|
+
bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, const std::string& reason_prefix, std::string& out_reason, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects);
|
|
170
225
|
/**
|
|
171
226
|
* Check whether this transaction spends any witness program but P2A, including not-yet-defined ones.
|
|
172
227
|
* May return `false` early for consensus-invalid transactions.
|
|
@@ -188,4 +243,10 @@ static inline int64_t GetVirtualTransactionInputSize(const CTxIn& tx)
|
|
|
188
243
|
return GetVirtualTransactionInputSize(tx, 0, 0);
|
|
189
244
|
}
|
|
190
245
|
|
|
246
|
+
std::pair<CScript, unsigned int> GetScriptForTransactionInput(CScript prevScript, const CTxIn&);
|
|
247
|
+
|
|
248
|
+
std::pair<size_t, size_t> DatacarrierBytes(const CTransaction& tx, const CCoinsViewCache& view);
|
|
249
|
+
|
|
250
|
+
int32_t CalculateExtraTxWeight(const CTransaction& tx, const CCoinsViewCache& view, const unsigned int weight_per_data_byte);
|
|
251
|
+
|
|
191
252
|
#endif // BITCOIN_POLICY_POLICY_H
|