Skip to content

Commit 6fd67aa

Browse files
committed
Merge rwconf_policy-28+knots
2 parents 40f673f + 2b7871d commit 6fd67aa

20 files changed

+1180
-28
lines changed

src/init.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ using util::Join;
140140
using util::ReplaceAll;
141141
using util::ToString;
142142

143+
static constexpr bool DEFAULT_COREPOLICY{false};
143144
static constexpr bool DEFAULT_PROXYRANDOMIZE{true};
144145
static constexpr bool DEFAULT_REST_ENABLE{false};
145146
static constexpr bool DEFAULT_I2P_ACCEPT_INCOMING{true};
@@ -494,6 +495,7 @@ void SetupServerArgs(ArgsManager& argsman)
494495
argsman.AddArg("-coinstatsindex", strprintf("Maintain coinstats index used by the gettxoutsetinfo RPC (default: %u)", DEFAULT_COINSTATSINDEX), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
495496
argsman.AddArg("-conf=<file>", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
496497
argsman.AddArg("-confrw=<file>", strprintf("Specify read/write configuration file. Relative paths will be prefixed by the network-specific datadir location (default: %s)", BITCOIN_RW_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
498+
argsman.AddArg("-corepolicy", strprintf("Use Bitcoin Core policy defaults (default: %u)", DEFAULT_COREPOLICY), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
497499
argsman.AddArg("-datadir=<dir>", "Specify data directory", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
498500
argsman.AddArg("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", nDefaultDbBatchSize), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS);
499501
argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (%d to %d, default: %d). In addition, unused mempool memory is shared for this cache (see -maxmempool).", nMinDbCache, nMaxDbCache, nDefaultDbCache), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
@@ -694,7 +696,7 @@ void SetupServerArgs(ArgsManager& argsman)
694696
argsman.AddArg("-maxscriptsize", strprintf("Maximum size of scripts we relay and mine, in bytes (default: %s)", DEFAULT_SCRIPT_SIZE_POLICY_LIMIT), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
695697
argsman.AddArg("-mempoolfullrbf", strprintf("Accept transaction replace-by-fee without requiring replaceability signaling (default: %u)", (DEFAULT_MEMPOOL_RBF_POLICY == RBFPolicy::Always)), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
696698
argsman.AddArg("-mempoolreplacement", strprintf("Set to 0 to disable RBF entirely, \"fee,optin\" to honour RBF opt-out signal, or \"fee,-optin\" to always RBF aka full RBF (default: %s)", "fee,-optin"), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
697-
argsman.AddArg("-mempooltruc", strprintf("Behaviour for transactions requesting TRUC limits: \"reject\" the transactions entirely, \"accept\" them just like any other, or \"enforce\" to impose their requested restrictions (default: %s)", "enforce"), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
699+
argsman.AddArg("-mempooltruc", strprintf("Behaviour for transactions requesting TRUC limits: \"reject\" the transactions entirely, \"accept\" them just like any other, or \"enforce\" to impose their requested restrictions (default: %s)", "accept"), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
698700
argsman.AddArg("-permitbarepubkey", strprintf("Relay legacy pubkey outputs (default: %u)", DEFAULT_PERMIT_BAREPUBKEY), ArgsManager::ALLOW_ANY,
699701
OptionsCategory::NODE_RELAY);
700702
argsman.AddArg("-permitbaremultisig", strprintf("Relay transactions creating non-P2SH multisig outputs (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY,
@@ -801,6 +803,23 @@ static bool AppInitServers(NodeContext& node)
801803
// Parameter interaction based on rules
802804
void InitParameterInteraction(ArgsManager& args)
803805
{
806+
if (args.GetBoolArg("-corepolicy", DEFAULT_COREPOLICY)) {
807+
args.SoftSetArg("-acceptnonstddatacarrier", "1");
808+
args.SoftSetArg("-bytespersigopstrict", "0");
809+
args.SoftSetArg("-permitbarepubkey", "1");
810+
args.SoftSetArg("-permitbaremultisig", "1");
811+
args.SoftSetArg("-rejectparasites", "0");
812+
args.SoftSetArg("-datacarriercost", "0.25");
813+
args.SoftSetArg("-datacarrierfullcount", "0");
814+
args.SoftSetArg("-datacarriersize", "83");
815+
args.SoftSetArg("-maxscriptsize", strprintf("%s", std::numeric_limits<unsigned int>::max()));
816+
args.SoftSetArg("-mempooltruc", "enforce");
817+
args.SoftSetArg("-spkreuse", "allow");
818+
args.SoftSetArg("-blockprioritysize", "0");
819+
args.SoftSetArg("-blockmaxsize", "4000000");
820+
args.SoftSetArg("-blockmaxweight", "3996000");
821+
}
822+
804823
// when specifying an explicit binding address, you want to listen on it
805824
// even when -connect or -proxy is specified
806825
if (args.IsArgSet("-bind")) {

src/interfaces/node.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
class BanMan;
2727
class CFeeRate;
2828
class CNodeStats;
29+
class CTxMemPool;
2930
class Coin;
3031
class RPCTimerInterface;
3132
class UniValue;
@@ -157,6 +158,8 @@ class Node
157158
//! Get total bytes sent.
158159
virtual int64_t getTotalBytesSent() = 0;
159160

161+
virtual CTxMemPool& mempool() = 0;
162+
160163
//! Get mempool size.
161164
virtual size_t getMempoolSize() = 0;
162165

src/kernel/mempool_options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ static constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS{336};
2929
/** Default for -mempoolreplacement; must update docs in init.cpp manually */
3030
static constexpr RBFPolicy DEFAULT_MEMPOOL_RBF_POLICY{RBFPolicy::Always};
3131
/** Default for -mempooltruc; must update docs in init.cpp manually */
32-
static constexpr TRUCPolicy DEFAULT_MEMPOOL_TRUC_POLICY{TRUCPolicy::Enforce};
32+
static constexpr TRUCPolicy DEFAULT_MEMPOOL_TRUC_POLICY{TRUCPolicy::Accept};
3333
/** Whether to fall back to legacy V1 serialization when writing mempool.dat */
3434
static constexpr bool DEFAULT_PERSIST_V1_DAT{false};
3535
/** Default for -acceptnonstddatacarrier */
36-
static constexpr bool DEFAULT_ACCEPT_NON_STD_DATACARRIER{true};
36+
static constexpr bool DEFAULT_ACCEPT_NON_STD_DATACARRIER{false};
3737
/** Default for -acceptnonstdtxn */
3838
static constexpr bool DEFAULT_ACCEPT_NON_STD_TXN{false};
3939

src/net_processing.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ class PeerManagerImpl final : public PeerManager
520520
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
521521
std::vector<TxOrphanage::OrphanTxBase> GetOrphanTransactions() override EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
522522
PeerManagerInfo GetInfo() const override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
523+
void LimitOrphanTxSize(unsigned int nMaxOrphans) override EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
523524
void SendPings() override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
524525
void RelayTransaction(const uint256& txid, const uint256& wtxid) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
525526
void SetBestBlock(int height, std::chrono::seconds time) override
@@ -1952,6 +1953,13 @@ PeerManagerInfo PeerManagerImpl::GetInfo() const
19521953
};
19531954
}
19541955

1956+
void PeerManagerImpl::LimitOrphanTxSize(unsigned int nMaxOrphans)
1957+
{
1958+
LOCK(g_msgproc_mutex);
1959+
LOCK2(cs_main, m_tx_download_mutex);
1960+
m_orphanage.LimitOrphans(nMaxOrphans, m_rng);
1961+
}
1962+
19551963
int PeerManagerImpl::GetNumberOfPeersWithValidatedDownloads() const
19561964
{
19571965
AssertLockHeld(m_chainman.GetMutex());

src/net_processing.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define BITCOIN_NET_PROCESSING_H
88

99
#include <net.h>
10+
#include <threadsafety.h>
1011
#include <txorphanage.h>
1112
#include <validationinterface.h>
1213

@@ -95,6 +96,7 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
9596

9697
/** Get statistics from node state */
9798
virtual bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const = 0;
99+
virtual void LimitOrphanTxSize(unsigned int nMaxOrphans) = 0;
98100

99101
virtual std::vector<TxOrphanage::OrphanTxBase> GetOrphanTransactions() = 0;
100102

src/node/interfaces.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ class NodeImpl : public Node
425425
}
426426
ArgsManager& args() { return *Assert(Assert(m_context)->args); }
427427
ChainstateManager& chainman() { return *Assert(m_context->chainman); }
428+
CTxMemPool& mempool() override { return *Assert(m_context->mempool); }
428429
NodeContext* m_context{nullptr};
429430
};
430431

src/node/miner.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ BlockCreateOptions BlockCreateOptions::Clamped() const
7373
constexpr size_t theoretical_min_gentx_sz = 1+4+1+36+1+1+4+1+4;
7474
constexpr size_t theoretical_min_gentx_weight = theoretical_min_gentx_sz * WITNESS_SCALE_FACTOR;
7575
CHECK_NONFATAL(options.coinbase_max_additional_size <= MAX_BLOCK_SERIALIZED_SIZE - 1000);
76-
CHECK_NONFATAL(options.coinbase_max_additional_weight <= DEFAULT_BLOCK_MAX_WEIGHT);
76+
CHECK_NONFATAL(options.coinbase_max_additional_weight <= MAX_BLOCK_WEIGHT - 4000);
7777
CHECK_NONFATAL(options.coinbase_max_additional_weight >= theoretical_min_gentx_weight);
7878
CHECK_NONFATAL(options.coinbase_output_max_additional_sigops <= MAX_BLOCK_SIGOPS_COST);
7979
// Limit size to between coinbase_max_additional_size and MAX_BLOCK_SERIALIZED_SIZE-1K for sanity:
8080
options.nBlockMaxSize = std::clamp<size_t>(options.nBlockMaxSize, options.coinbase_max_additional_size, MAX_BLOCK_SERIALIZED_SIZE - 1000);
81-
// Limit weight to between coinbase_max_additional_weight and DEFAULT_BLOCK_MAX_WEIGHT for sanity:
81+
// Limit weight to between coinbase_max_additional_weight and MAX_BLOCK_WEIGHT for sanity:
8282
// Coinbase (reserved) outputs can safely exceed -blockmaxweight, but the rest of the block template will be empty.
83-
options.nBlockMaxWeight = std::clamp<size_t>(options.nBlockMaxWeight, options.coinbase_max_additional_weight, DEFAULT_BLOCK_MAX_WEIGHT);
83+
options.nBlockMaxWeight = std::clamp<size_t>(options.nBlockMaxWeight, options.coinbase_max_additional_weight, MAX_BLOCK_WEIGHT);
8484
return options;
8585
}
8686

src/policy/policy.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ struct MemPoolOptions;
2525
};
2626

2727
/** Default for -blockmaxsize, which controls the maximum size of block the mining code will create **/
28-
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = MAX_BLOCK_SERIALIZED_SIZE;
28+
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 300000;
2929
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
30-
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 0;
30+
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 100000;
3131
/** Minimum priority for transactions to be accepted into the priority area **/
3232
static const double MINIMUM_TX_PRIORITY = COIN * 144 / 250;
3333
/** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/
34-
static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{MAX_BLOCK_WEIGHT - 4000};
34+
static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{DEFAULT_BLOCK_MAX_SIZE * WITNESS_SCALE_FACTOR};
3535
/** Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code **/
3636
static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1000};
3737
/** The maximum weight for transactions we're willing to relay/mine */
@@ -45,21 +45,21 @@ static constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/
4545
/** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or replacement **/
4646
static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{1000};
4747
/** Default for -maxscriptsize */
48-
static constexpr unsigned int DEFAULT_SCRIPT_SIZE_POLICY_LIMIT{std::numeric_limits<unsigned int>::max()};
48+
static constexpr unsigned int DEFAULT_SCRIPT_SIZE_POLICY_LIMIT{1650};
4949
/** Default for -bytespersigop */
5050
static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20};
5151
/** Default for -bytespersigopstrict */
5252
static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP_STRICT{20};
5353
/** Default for -datacarriercost (multiplied by WITNESS_SCALE_FACTOR) */
54-
static constexpr unsigned int DEFAULT_WEIGHT_PER_DATA_BYTE{1};
54+
static constexpr unsigned int DEFAULT_WEIGHT_PER_DATA_BYTE{4};
5555
/** Default for -rejecttokens */
5656
static constexpr bool DEFAULT_REJECT_TOKENS{false};
5757
/** Default for -permitbarepubkey */
58-
static constexpr bool DEFAULT_PERMIT_BAREPUBKEY{true};
58+
static constexpr bool DEFAULT_PERMIT_BAREPUBKEY{false};
5959
/** Default for -permitbaremultisig */
60-
static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true};
60+
static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{false};
6161
/** Default for -rejectparasites */
62-
static constexpr bool DEFAULT_REJECT_PARASITES{false};
62+
static constexpr bool DEFAULT_REJECT_PARASITES{true};
6363
/** The maximum number of witness stack items in a standard P2WSH script */
6464
static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100};
6565
/** The maximum size in bytes of each witness stack item in a standard P2WSH script */
@@ -92,12 +92,12 @@ static constexpr unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT_KVB{101};
9292
/** Default for -datacarrier */
9393
static const bool DEFAULT_ACCEPT_DATACARRIER = true;
9494
/**
95-
* Default setting for -datacarriersize. 80 bytes of data, +1 for OP_RETURN,
96-
* +2 for the pushdata opcodes.
95+
* Default setting for -datacarriersize. 40 bytes of data, +1 for OP_RETURN,
96+
* +1 for the pushdata opcode.
9797
*/
98-
static const unsigned int MAX_OP_RETURN_RELAY = 83;
98+
static constexpr unsigned int MAX_OP_RETURN_RELAY{42};
9999
/** Default for -datacarrierfullcount */
100-
static constexpr bool DEFAULT_DATACARRIER_FULLCOUNT{false};
100+
static constexpr bool DEFAULT_DATACARRIER_FULLCOUNT{true};
101101
/**
102102
* An extra transaction can be added to a package, as long as it only has one
103103
* ancestor and is no larger than this. Not really any reason to make this

0 commit comments

Comments
 (0)