aboutsummaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/chainparams.cpp4
-rw-r--r--src/kernel/chainstatemanager_opts.h2
-rw-r--r--src/kernel/coinstats.cpp5
-rw-r--r--src/kernel/mempool_entry.h20
-rw-r--r--src/kernel/mempool_options.h3
-rw-r--r--src/kernel/mempool_persist.cpp40
6 files changed, 52 insertions, 22 deletions
diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp
index 73ba330ff0..56cb3a63a0 100644
--- a/src/kernel/chainparams.cpp
+++ b/src/kernel/chainparams.cpp
@@ -136,7 +136,7 @@ public:
vSeeds.emplace_back("dnsseed.bitcoin.dashjr.org."); // Luke Dashjr
vSeeds.emplace_back("seed.bitcoinstats.com."); // Christian Decker, supports x1 - xf
vSeeds.emplace_back("seed.bitcoin.jonasschnelli.ch."); // Jonas Schnelli, only supports x1, x5, x9, and xd
- vSeeds.emplace_back("seed.btc.petertodd.org."); // Peter Todd, only supports x1, x5, x9, and xd
+ vSeeds.emplace_back("seed.btc.petertodd.net."); // Peter Todd, only supports x1, x5, x9, and xd
vSeeds.emplace_back("seed.bitcoin.sprovoost.nl."); // Sjors Provoost
vSeeds.emplace_back("dnsseed.emzy.de."); // Stephan Oeste
vSeeds.emplace_back("seed.bitcoin.wiz.biz."); // Jason Maurice
@@ -243,7 +243,7 @@ public:
vSeeds.clear();
// nodes with support for servicebits filtering should be at the top
vSeeds.emplace_back("testnet-seed.bitcoin.jonasschnelli.ch.");
- vSeeds.emplace_back("seed.tbtc.petertodd.org.");
+ vSeeds.emplace_back("seed.tbtc.petertodd.net.");
vSeeds.emplace_back("seed.testnet.bitcoin.sprovoost.nl.");
vSeeds.emplace_back("testnet-seed.bluematt.me."); // Just a static list of stable node(s), only supports x9
diff --git a/src/kernel/chainstatemanager_opts.h b/src/kernel/chainstatemanager_opts.h
index 917f7d226c..ee20eabd79 100644
--- a/src/kernel/chainstatemanager_opts.h
+++ b/src/kernel/chainstatemanager_opts.h
@@ -45,6 +45,8 @@ struct ChainstateManagerOpts {
DBOptions coins_db{};
CoinsViewOptions coins_view{};
Notifications& notifications;
+ //! Number of script check worker threads. Zero means no parallel verification.
+ int worker_threads_num{0};
};
} // namespace kernel
diff --git a/src/kernel/coinstats.cpp b/src/kernel/coinstats.cpp
index 9bd755ed27..ff8a33e804 100644
--- a/src/kernel/coinstats.cpp
+++ b/src/kernel/coinstats.cpp
@@ -21,7 +21,6 @@
#include <util/check.h>
#include <util/overflow.h>
#include <validation.h>
-#include <version.h>
#include <cassert>
#include <iosfwd>
@@ -90,7 +89,7 @@ static void ApplyCoinHash(std::nullptr_t, const COutPoint& outpoint, const Coin&
//! construction could cause a previously invalid (and potentially malicious)
//! UTXO snapshot to be considered valid.
template <typename T>
-static void ApplyHash(T& hash_obj, const uint256& hash, const std::map<uint32_t, Coin>& outputs)
+static void ApplyHash(T& hash_obj, const Txid& hash, const std::map<uint32_t, Coin>& outputs)
{
for (auto it = outputs.begin(); it != outputs.end(); ++it) {
COutPoint outpoint = COutPoint(hash, it->first);
@@ -119,7 +118,7 @@ static bool ComputeUTXOStats(CCoinsView* view, CCoinsStats& stats, T hash_obj, c
std::unique_ptr<CCoinsViewCursor> pcursor(view->Cursor());
assert(pcursor);
- uint256 prevkey;
+ Txid prevkey;
std::map<uint32_t, Coin> outputs;
while (pcursor->Valid()) {
if (interruption_point) interruption_point();
diff --git a/src/kernel/mempool_entry.h b/src/kernel/mempool_entry.h
index 1f175a5ccf..b5c0499012 100644
--- a/src/kernel/mempool_entry.h
+++ b/src/kernel/mempool_entry.h
@@ -71,6 +71,11 @@ public:
typedef std::set<CTxMemPoolEntryRef, CompareIteratorByHash> Children;
private:
+ CTxMemPoolEntry(const CTxMemPoolEntry&) = default;
+ struct ExplicitCopyTag {
+ explicit ExplicitCopyTag() = default;
+ };
+
const CTransactionRef tx;
mutable Parents m_parents;
mutable Children m_children;
@@ -83,7 +88,7 @@ private:
const bool spendsCoinbase; //!< keep track of transactions that spend a coinbase
const int64_t sigOpCost; //!< Total sigop cost
CAmount m_modified_fee; //!< Used for determining the priority of the transaction for mining in a block
- LockPoints lockPoints; //!< Track the height and time at which tx was final
+ mutable LockPoints lockPoints; //!< Track the height and time at which tx was final
// Information about descendants of this transaction that are in the
// mempool; if we remove this transaction we must remove all of these
@@ -122,6 +127,13 @@ public:
nModFeesWithAncestors{nFee},
nSigOpCostWithAncestors{sigOpCost} {}
+ CTxMemPoolEntry(ExplicitCopyTag, const CTxMemPoolEntry& entry) : CTxMemPoolEntry(entry) {}
+ CTxMemPoolEntry& operator=(const CTxMemPoolEntry&) = delete;
+ CTxMemPoolEntry(CTxMemPoolEntry&&) = delete;
+ CTxMemPoolEntry& operator=(CTxMemPoolEntry&&) = delete;
+
+ static constexpr ExplicitCopyTag ExplicitCopy{};
+
const CTransaction& GetTx() const { return *this->tx; }
CTransactionRef GetSharedTx() const { return this->tx; }
const CAmount& GetFee() const { return nFee; }
@@ -151,7 +163,7 @@ public:
}
// Update the LockPoints after a reorg
- void UpdateLockPoints(const LockPoints& lp)
+ void UpdateLockPoints(const LockPoints& lp) const
{
lockPoints = lp;
}
@@ -172,8 +184,10 @@ public:
Parents& GetMemPoolParents() const { return m_parents; }
Children& GetMemPoolChildren() const { return m_children; }
- mutable size_t vTxHashesIdx; //!< Index in mempool's vTxHashes
+ mutable size_t idx_randomized; //!< Index in mempool's txns_randomized
mutable Epoch::Marker m_epoch_marker; //!< epoch when last touched, useful for graph algorithms
};
+using CTxMemPoolEntryRef = CTxMemPoolEntry::CTxMemPoolEntryRef;
+
#endif // BITCOIN_KERNEL_MEMPOOL_ENTRY_H
diff --git a/src/kernel/mempool_options.h b/src/kernel/mempool_options.h
index 757be41b3c..d09fd2ba35 100644
--- a/src/kernel/mempool_options.h
+++ b/src/kernel/mempool_options.h
@@ -23,6 +23,8 @@ static constexpr unsigned int DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB{5};
static constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS{336};
/** Default for -mempoolfullrbf, if the transaction replaceability signaling is ignored */
static constexpr bool DEFAULT_MEMPOOL_FULL_RBF{false};
+/** Whether to fall back to legacy V1 serialization when writing mempool.dat */
+static constexpr bool DEFAULT_PERSIST_V1_DAT{false};
/** Default for -acceptnonstdtxn */
static constexpr bool DEFAULT_ACCEPT_NON_STD_TXN{false};
@@ -56,6 +58,7 @@ struct MemPoolOptions {
bool permit_bare_multisig{DEFAULT_PERMIT_BAREMULTISIG};
bool require_standard{true};
bool full_rbf{DEFAULT_MEMPOOL_FULL_RBF};
+ bool persist_v1_dat{DEFAULT_PERSIST_V1_DAT};
MemPoolLimits limits{};
};
} // namespace kernel
diff --git a/src/kernel/mempool_persist.cpp b/src/kernel/mempool_persist.cpp
index ff655c5ffa..0808d42452 100644
--- a/src/kernel/mempool_persist.cpp
+++ b/src/kernel/mempool_persist.cpp
@@ -8,6 +8,7 @@
#include <consensus/amount.h>
#include <logging.h>
#include <primitives/transaction.h>
+#include <random.h>
#include <serialize.h>
#include <streams.h>
#include <sync.h>
@@ -34,14 +35,14 @@ using fsbridge::FopenFn;
namespace kernel {
-static const uint64_t MEMPOOL_DUMP_VERSION = 1;
+static const uint64_t MEMPOOL_DUMP_VERSION_NO_XOR_KEY{1};
+static const uint64_t MEMPOOL_DUMP_VERSION{2};
bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active_chainstate, ImportMempoolOptions&& opts)
{
if (load_path.empty()) return false;
- FILE* filestr{opts.mockable_fopen_function(load_path, "rb")};
- CAutoFile file{filestr, CLIENT_VERSION};
+ AutoFile file{opts.mockable_fopen_function(load_path, "rb")};
if (file.IsNull()) {
LogPrintf("Failed to open mempool file from disk. Continuing anyway.\n");
return false;
@@ -57,9 +58,15 @@ bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active
try {
uint64_t version;
file >> version;
- if (version != MEMPOOL_DUMP_VERSION) {
+ std::vector<std::byte> xor_key;
+ if (version == MEMPOOL_DUMP_VERSION_NO_XOR_KEY) {
+ // Leave XOR-key empty
+ } else if (version == MEMPOOL_DUMP_VERSION) {
+ file >> xor_key;
+ } else {
return false;
}
+ file.SetXor(xor_key);
uint64_t num;
file >> num;
while (num) {
@@ -67,7 +74,7 @@ bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active
CTransactionRef tx;
int64_t nTime;
int64_t nFeeDelta;
- file >> tx;
+ file >> TX_WITH_WITNESS(tx);
file >> nTime;
file >> nFeeDelta;
@@ -151,20 +158,25 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, FopenFn mock
auto mid = SteadyClock::now();
- try {
- FILE* filestr{mockable_fopen_function(dump_path + ".new", "wb")};
- if (!filestr) {
- return false;
- }
-
- CAutoFile file{filestr, CLIENT_VERSION};
+ AutoFile file{mockable_fopen_function(dump_path + ".new", "wb")};
+ if (file.IsNull()) {
+ return false;
+ }
- uint64_t version = MEMPOOL_DUMP_VERSION;
+ try {
+ const uint64_t version{pool.m_persist_v1_dat ? MEMPOOL_DUMP_VERSION_NO_XOR_KEY : MEMPOOL_DUMP_VERSION};
file << version;
+ std::vector<std::byte> xor_key(8);
+ if (!pool.m_persist_v1_dat) {
+ FastRandomContext{}.fillrand(xor_key);
+ file << xor_key;
+ }
+ file.SetXor(xor_key);
+
file << (uint64_t)vinfo.size();
for (const auto& i : vinfo) {
- file << *(i.tx);
+ file << TX_WITH_WITNESS(*(i.tx));
file << int64_t{count_seconds(i.m_time)};
file << int64_t{i.nFeeDelta};
mapDeltas.erase(i.tx->GetHash());