aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/addrman.h2
-rw-r--r--src/bench/checkblock.cpp4
-rw-r--r--src/bench/nanobench.h98
-rw-r--r--src/bench/pool.cpp3
-rw-r--r--src/bench/verify_script.cpp2
-rw-r--r--src/bitcoin-util.cpp1
-rw-r--r--src/blockencodings.cpp2
-rw-r--r--src/coins.cpp3
-rw-r--r--src/coins.h3
-rw-r--r--src/consensus/validation.h1
-rw-r--r--src/core_read.cpp1
-rw-r--r--src/external_signer.cpp4
-rw-r--r--src/hash.h1
-rw-r--r--src/index/blockfilterindex.cpp4
-rw-r--r--src/kernel/coinstats.cpp1
-rw-r--r--src/net.h1
-rw-r--r--src/net_processing.cpp4
-rw-r--r--src/node/blockstorage.cpp4
-rw-r--r--src/policy/policy.h2
-rw-r--r--src/primitives/transaction.cpp1
-rw-r--r--src/psbt.cpp1
-rw-r--r--src/psbt.h4
-rw-r--r--src/qt/transactiontablemodel.cpp2
-rw-r--r--src/rest.cpp1
-rw-r--r--src/rpc/blockchain.cpp4
-rw-r--r--src/rpc/rawtransaction.cpp1
-rw-r--r--src/rpc/server.cpp2
-rw-r--r--src/rpc/util.cpp2
-rw-r--r--src/rpc/util.h2
-rw-r--r--src/script/bitcoinconsensus.cpp1
-rw-r--r--src/script/interpreter.cpp2
-rw-r--r--src/script/sign.cpp2
-rw-r--r--src/serialize.h35
-rw-r--r--src/signet.cpp1
-rw-r--r--src/support/allocators/pool.h2
-rw-r--r--src/test/flatfile_tests.cpp2
-rw-r--r--src/test/fuzz/FuzzedDataProvider.h2
-rw-r--r--src/test/fuzz/autofile.cpp16
-rw-r--r--src/test/fuzz/buffered_file.cpp14
-rw-r--r--src/test/fuzz/load_external_block_file.cpp2
-rw-r--r--src/test/fuzz/miniscript.cpp2
-rw-r--r--src/test/fuzz/package_eval.cpp22
-rw-r--r--src/test/fuzz/policy_estimator.cpp5
-rw-r--r--src/test/fuzz/policy_estimator_io.cpp8
-rw-r--r--src/test/fuzz/util.h25
-rw-r--r--src/test/fuzz/validation_load_mempool.cpp2
-rw-r--r--src/test/miniscript_tests.cpp2
-rw-r--r--src/test/orphanage_tests.cpp2
-rw-r--r--src/test/pool_tests.cpp24
-rw-r--r--src/test/script_tests.cpp2
-rw-r--r--src/test/serialize_tests.cpp48
-rw-r--r--src/test/uint256_tests.cpp8
-rw-r--r--src/test/util/script.h12
-rw-r--r--src/test/util/setup_common.h1
-rw-r--r--src/test/versionbits_tests.cpp2
-rw-r--r--src/torcontrol.cpp2
-rw-r--r--src/txmempool.h2
-rw-r--r--src/undo.h1
-rw-r--r--src/wallet/feebumper.cpp2
-rw-r--r--src/wallet/rpc/spend.cpp1
-rw-r--r--src/wallet/spend.cpp6
-rw-r--r--src/wallet/wallet.h2
-rw-r--r--src/zmq/zmqpublishnotifier.cpp1
63 files changed, 219 insertions, 203 deletions
diff --git a/src/addrman.h b/src/addrman.h
index 4d44c943ac..67dc7604a4 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -172,7 +172,7 @@ public:
/**
* Returns an information-location pair for all addresses in the selected addrman table.
* If an address appears multiple times in the new table, an information-location pair
- * is returned for each occurence. Addresses only ever appear once in the tried table.
+ * is returned for each occurrence. Addresses only ever appear once in the tried table.
*
* @param[in] from_tried Selects which table to return entries from.
*
diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp
index 9f52a22672..b81878006c 100644
--- a/src/bench/checkblock.cpp
+++ b/src/bench/checkblock.cpp
@@ -18,7 +18,7 @@
static void DeserializeBlockTest(benchmark::Bench& bench)
{
- CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
+ DataStream stream(benchmark::data::block413567);
std::byte a{0};
stream.write({&a, 1}); // Prevent compaction
@@ -32,7 +32,7 @@ static void DeserializeBlockTest(benchmark::Bench& bench)
static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
{
- CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
+ DataStream stream(benchmark::data::block413567);
std::byte a{0};
stream.write({&a, 1}); // Prevent compaction
diff --git a/src/bench/nanobench.h b/src/bench/nanobench.h
index 8b3dc6c71c..127240d3c7 100644
--- a/src/bench/nanobench.h
+++ b/src/bench/nanobench.h
@@ -33,7 +33,7 @@
// see https://semver.org/
#define ANKERL_NANOBENCH_VERSION_MAJOR 4 // incompatible API changes
#define ANKERL_NANOBENCH_VERSION_MINOR 3 // backwards-compatible changes
-#define ANKERL_NANOBENCH_VERSION_PATCH 10 // backwards-compatible bug fixes
+#define ANKERL_NANOBENCH_VERSION_PATCH 11 // backwards-compatible bug fixes
///////////////////////////////////////////////////////////////////////////////////////////////////
// public facing api - as minimal as possible
@@ -120,6 +120,10 @@
# define ANKERL_NANOBENCH_IS_TRIVIALLY_COPYABLE(...) std::is_trivially_copyable<__VA_ARGS__>::value
#endif
+// noexcept may be missing for std::string.
+// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58265
+#define ANKERL_NANOBENCH_PRIVATE_NOEXCEPT_STRING_MOVE() std::is_nothrow_move_assignable<std::string>::value
+
// declarations ///////////////////////////////////////////////////////////////////////////////////
namespace ankerl {
@@ -404,7 +408,7 @@ struct Config {
Config();
~Config();
Config& operator=(Config const& other);
- Config& operator=(Config&& other) noexcept;
+ Config& operator=(Config&& other) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE));
Config(Config const& other);
Config(Config&& other) noexcept;
};
@@ -430,7 +434,7 @@ public:
~Result();
Result& operator=(Result const& other);
- Result& operator=(Result&& other) noexcept;
+ Result& operator=(Result&& other) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE));
Result(Result const& other);
Result(Result&& other) noexcept;
@@ -596,7 +600,7 @@ public:
*
* @return Vector containing the full state:
*/
- std::vector<uint64_t> state() const;
+ ANKERL_NANOBENCH(NODISCARD) std::vector<uint64_t> state() const;
private:
static constexpr uint64_t rotl(uint64_t x, unsigned k) noexcept;
@@ -628,7 +632,7 @@ public:
Bench();
Bench(Bench&& other) noexcept;
- Bench& operator=(Bench&& other) noexcept;
+ Bench& operator=(Bench&& other) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE));
Bench(Bench const& other);
Bench& operator=(Bench const& other);
~Bench() noexcept;
@@ -818,7 +822,7 @@ public:
* Default is zero, so we are fully relying on clockResolutionMultiple(). In most cases this is exactly what you want. If you see
* that the evaluation is unreliable with a high `err%`, you can increase either minEpochTime() or minEpochIterations().
*
- * @see maxEpochTim), minEpochIterations
+ * @see maxEpochTime, minEpochIterations
*
* @param t Minimum time each epoch should take.
*/
@@ -1030,7 +1034,7 @@ void doNotOptimizeAway(T const& val);
// These assembly magic is directly from what Google Benchmark is doing. I have previously used what facebook's folly was doing, but
// this seemed to have compilation problems in some cases. Google Benchmark seemed to be the most well tested anyways.
-// see https://github.com/google/benchmark/blob/master/include/benchmark/benchmark.h#L307
+// see https://github.com/google/benchmark/blob/v1.7.1/include/benchmark/benchmark.h#L443-L446
template <typename T>
void doNotOptimizeAway(T const& val) {
// NOLINTNEXTLINE(hicpp-no-assembler)
@@ -1781,7 +1785,7 @@ bool isEndlessRunning(std::string const& name);
bool isWarningsEnabled();
template <typename T>
-T parseFile(std::string const& filename);
+T parseFile(std::string const& filename, bool* fail);
void gatherStabilityInformation(std::vector<std::string>& warnings, std::vector<std::string>& recommendations);
void printStabilityInformationOnce(std::ostream* outStream);
@@ -1839,7 +1843,7 @@ class Number {
public:
Number(int width, int precision, double value);
Number(int width, int precision, int64_t value);
- std::string to_s() const;
+ ANKERL_NANOBENCH(NODISCARD) std::string to_s() const;
private:
friend std::ostream& operator<<(std::ostream& os, Number const& n);
@@ -1857,11 +1861,11 @@ std::ostream& operator<<(std::ostream& os, Number const& n);
class MarkDownColumn {
public:
- MarkDownColumn(int w, int prec, std::string tit, std::string suff, double val);
- std::string title() const;
- std::string separator() const;
- std::string invalid() const;
- std::string value() const;
+ MarkDownColumn(int w, int prec, std::string tit, std::string suff, double val) noexcept;
+ ANKERL_NANOBENCH(NODISCARD) std::string title() const;
+ ANKERL_NANOBENCH(NODISCARD) std::string separator() const;
+ ANKERL_NANOBENCH(NODISCARD) std::string invalid() const;
+ ANKERL_NANOBENCH(NODISCARD) std::string value() const;
private:
int mWidth;
@@ -1976,9 +1980,9 @@ PerformanceCounters& performanceCounters() {
}
// Windows version of doNotOptimizeAway
-// see https://github.com/google/benchmark/blob/master/include/benchmark/benchmark.h#L307
-// see https://github.com/facebook/folly/blob/master/folly/Benchmark.h#L280
-// see https://docs.microsoft.com/en-us/cpp/preprocessor/optimize
+// see https://github.com/google/benchmark/blob/v1.7.1/include/benchmark/benchmark.h#L514
+// see https://github.com/facebook/folly/blob/v2023.01.30.00/folly/lang/Hint-inl.h#L54-L58
+// see https://learn.microsoft.com/en-us/cpp/preprocessor/optimize
# if defined(_MSC_VER)
# pragma optimize("", off)
void doNotOptimizeAwaySink(void const*) {}
@@ -1986,10 +1990,13 @@ void doNotOptimizeAwaySink(void const*) {}
# endif
template <typename T>
-T parseFile(std::string const& filename) {
+T parseFile(std::string const& filename, bool* fail) {
std::ifstream fin(filename); // NOLINT(misc-const-correctness)
T num{};
fin >> num;
+ if (fail != nullptr) {
+ *fail = fin.fail();
+ }
return num;
}
@@ -2032,16 +2039,15 @@ void gatherStabilityInformation(std::vector<std::string>& warnings, std::vector<
if (nprocs <= 0) {
warnings.emplace_back("couldn't figure out number of processors - no governor, turbo check possible");
} else {
-
// check frequency scaling
for (long id = 0; id < nprocs; ++id) {
auto idStr = detail::fmt::to_s(static_cast<uint64_t>(id));
auto sysCpu = "/sys/devices/system/cpu/cpu" + idStr;
- auto minFreq = parseFile<int64_t>(sysCpu + "/cpufreq/scaling_min_freq");
- auto maxFreq = parseFile<int64_t>(sysCpu + "/cpufreq/scaling_max_freq");
+ auto minFreq = parseFile<int64_t>(sysCpu + "/cpufreq/scaling_min_freq", nullptr);
+ auto maxFreq = parseFile<int64_t>(sysCpu + "/cpufreq/scaling_max_freq", nullptr);
if (minFreq != maxFreq) {
- auto minMHz = static_cast<double>(minFreq) / 1000.0;
- auto maxMHz = static_cast<double>(maxFreq) / 1000.0;
+ auto minMHz = d(minFreq) / 1000.0;
+ auto maxMHz = d(maxFreq) / 1000.0;
warnings.emplace_back("CPU frequency scaling enabled: CPU " + idStr + " between " +
detail::fmt::Number(1, 1, minMHz).to_s() + " and " + detail::fmt::Number(1, 1, maxMHz).to_s() +
" MHz");
@@ -2050,13 +2056,15 @@ void gatherStabilityInformation(std::vector<std::string>& warnings, std::vector<
}
}
- auto currentGovernor = parseFile<std::string>("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor");
- if ("performance" != currentGovernor) {
+ auto fail = false;
+ auto currentGovernor = parseFile<std::string>("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", &fail);
+ if (!fail && "performance" != currentGovernor) {
warnings.emplace_back("CPU governor is '" + currentGovernor + "' but should be 'performance'");
recommendPyPerf = true;
}
- if (0 == parseFile<int>("/sys/devices/system/cpu/intel_pstate/no_turbo")) {
+ auto noTurbo = parseFile<int>("/sys/devices/system/cpu/intel_pstate/no_turbo", &fail);
+ if (!fail && noTurbo == 0) {
warnings.emplace_back("Turbo is enabled, CPU frequency will fluctuate");
recommendPyPerf = true;
}
@@ -2250,10 +2258,9 @@ struct IterationLogic::Impl {
mNumIters = 0;
}
- ANKERL_NANOBENCH_LOG(mBench.name() << ": " << detail::fmt::Number(20, 3, static_cast<double>(elapsed.count())) << " elapsed, "
- << detail::fmt::Number(20, 3, static_cast<double>(mTargetRuntimePerEpoch.count()))
- << " target. oldIters=" << oldIters << ", mNumIters=" << mNumIters
- << ", mState=" << static_cast<int>(mState));
+ ANKERL_NANOBENCH_LOG(mBench.name() << ": " << detail::fmt::Number(20, 3, d(elapsed.count())) << " elapsed, "
+ << detail::fmt::Number(20, 3, d(mTargetRuntimePerEpoch.count())) << " target. oldIters="
+ << oldIters << ", mNumIters=" << mNumIters << ", mState=" << static_cast<int>(mState));
}
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
@@ -2357,7 +2364,7 @@ struct IterationLogic::Impl {
}
os << fmt::MarkDownCode(mBench.name());
if (showUnstable) {
- auto avgIters = static_cast<double>(mTotalNumIters) / static_cast<double>(mBench.epochs());
+ auto avgIters = d(mTotalNumIters) / d(mBench.epochs());
// NOLINTNEXTLINE(bugprone-incorrect-roundings)
auto suggestedIters = static_cast<uint64_t>(avgIters * 10 + 0.5);
@@ -2435,7 +2442,7 @@ public:
bool monitor(perf_sw_ids swId, Target target);
bool monitor(perf_hw_id hwId, Target target);
- bool hasError() const noexcept {
+ ANKERL_NANOBENCH(NODISCARD) bool hasError() const noexcept {
return mHasError;
}
@@ -2691,16 +2698,23 @@ PerformanceCounters::PerformanceCounters()
, mVal()
, mHas() {
- mHas.pageFaults = mPc->monitor(PERF_COUNT_SW_PAGE_FAULTS, LinuxPerformanceCounters::Target(&mVal.pageFaults, true, false));
+ // HW events
mHas.cpuCycles = mPc->monitor(PERF_COUNT_HW_REF_CPU_CYCLES, LinuxPerformanceCounters::Target(&mVal.cpuCycles, true, false));
- mHas.contextSwitches =
- mPc->monitor(PERF_COUNT_SW_CONTEXT_SWITCHES, LinuxPerformanceCounters::Target(&mVal.contextSwitches, true, false));
+ if (!mHas.cpuCycles) {
+ // Fallback to cycles counter, reference cycles not available in many systems.
+ mHas.cpuCycles = mPc->monitor(PERF_COUNT_HW_CPU_CYCLES, LinuxPerformanceCounters::Target(&mVal.cpuCycles, true, false));
+ }
mHas.instructions = mPc->monitor(PERF_COUNT_HW_INSTRUCTIONS, LinuxPerformanceCounters::Target(&mVal.instructions, true, true));
mHas.branchInstructions =
mPc->monitor(PERF_COUNT_HW_BRANCH_INSTRUCTIONS, LinuxPerformanceCounters::Target(&mVal.branchInstructions, true, false));
mHas.branchMisses = mPc->monitor(PERF_COUNT_HW_BRANCH_MISSES, LinuxPerformanceCounters::Target(&mVal.branchMisses, true, false));
// mHas.branchMisses = false;
+ // SW events
+ mHas.pageFaults = mPc->monitor(PERF_COUNT_SW_PAGE_FAULTS, LinuxPerformanceCounters::Target(&mVal.pageFaults, true, false));
+ mHas.contextSwitches =
+ mPc->monitor(PERF_COUNT_SW_CONTEXT_SWITCHES, LinuxPerformanceCounters::Target(&mVal.contextSwitches, true, false));
+
mPc->start();
mPc->calibrate([] {
auto before = ankerl::nanobench::Clock::now();
@@ -2789,7 +2803,7 @@ void StreamStateRestorer::restore() {
Number::Number(int width, int precision, int64_t value)
: mWidth(width)
, mPrecision(precision)
- , mValue(static_cast<double>(value)) {}
+ , mValue(d(value)) {}
Number::Number(int width, int precision, double value)
: mWidth(width)
@@ -2823,7 +2837,7 @@ std::ostream& operator<<(std::ostream& os, Number const& n) {
return n.write(os);
}
-MarkDownColumn::MarkDownColumn(int w, int prec, std::string tit, std::string suff, double val)
+MarkDownColumn::MarkDownColumn(int w, int prec, std::string tit, std::string suff, double val) noexcept
: mWidth(w)
, mPrecision(prec)
, mTitle(std::move(tit))
@@ -2884,14 +2898,14 @@ std::ostream& operator<<(std::ostream& os, MarkDownCode const& mdCode) {
Config::Config() = default;
Config::~Config() = default;
Config& Config::operator=(Config const&) = default;
-Config& Config::operator=(Config&&) noexcept = default;
+Config& Config::operator=(Config&&) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE)) = default;
Config::Config(Config const&) = default;
Config::Config(Config&&) noexcept = default;
// provide implementation here so it's only generated once
Result::~Result() = default;
Result& Result::operator=(Result const&) = default;
-Result& Result::operator=(Result&&) noexcept = default;
+Result& Result::operator=(Result&&) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE)) = default;
Result::Result(Result const&) = default;
Result::Result(Result&&) noexcept = default;
@@ -2992,7 +3006,7 @@ double Result::medianAbsolutePercentError(Measure m) const {
auto data = mNameToMeasurements[detail::u(m)];
// calculates MdAPE which is the median of percentage error
- // see https://www.spiderfinancial.com/support/documentation/numxl/reference-manual/forecasting-performance/mdape
+ // see https://support.numxl.com/hc/en-us/articles/115001223503-MdAPE-Median-Absolute-Percentage-Error
auto med = calcMedian(data);
// transform the data to absolute error
@@ -3106,7 +3120,7 @@ Bench::Bench() {
}
Bench::Bench(Bench&&) noexcept = default;
-Bench& Bench::operator=(Bench&&) noexcept = default;
+Bench& Bench::operator=(Bench&&) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE)) = default;
Bench::Bench(Bench const&) = default;
Bench& Bench::operator=(Bench const&) = default;
Bench::~Bench() noexcept = default;
@@ -3423,7 +3437,7 @@ BigO::BigO(std::string bigOName, RangeMeasure const& rangeMeasure)
sumMeasure += rm.second;
}
- auto n = static_cast<double>(rangeMeasure.size());
+ auto n = detail::d(rangeMeasure.size());
auto mean = sumMeasure / n;
mNormalizedRootMeanSquare = std::sqrt(err / n) / mean;
}
diff --git a/src/bench/pool.cpp b/src/bench/pool.cpp
index b3e54d85a2..b2a5f8debf 100644
--- a/src/bench/pool.cpp
+++ b/src/bench/pool.cpp
@@ -37,8 +37,7 @@ static void PoolAllocator_StdUnorderedMapWithPoolResource(benchmark::Bench& benc
std::hash<uint64_t>,
std::equal_to<uint64_t>,
PoolAllocator<std::pair<const uint64_t, uint64_t>,
- sizeof(std::pair<const uint64_t, uint64_t>) + 4 * sizeof(void*),
- alignof(void*)>>;
+ sizeof(std::pair<const uint64_t, uint64_t>) + 4 * sizeof(void*)>>;
// make sure the resource supports large enough pools to hold the node. We do this by adding the size of a few pointers to it.
auto pool_resource = Map::allocator_type::ResourceType();
diff --git a/src/bench/verify_script.cpp b/src/bench/verify_script.cpp
index e1a0bf138e..3682b33518 100644
--- a/src/bench/verify_script.cpp
+++ b/src/bench/verify_script.cpp
@@ -61,7 +61,7 @@ static void VerifyScriptBench(benchmark::Bench& bench)
assert(success);
#if defined(HAVE_CONSENSUS_LIB)
- CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
+ DataStream stream;
stream << TX_WITH_WITNESS(txSpend);
int csuccess = bitcoinconsensus_verify_script_with_amount(
txCredit.vout[0].scriptPubKey.data(),
diff --git a/src/bitcoin-util.cpp b/src/bitcoin-util.cpp
index 8b68d04b2b..96387e8c71 100644
--- a/src/bitcoin-util.cpp
+++ b/src/bitcoin-util.cpp
@@ -19,7 +19,6 @@
#include <util/exception.h>
#include <util/strencodings.h>
#include <util/translation.h>
-#include <version.h>
#include <atomic>
#include <cstdio>
diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp
index 29306b2229..1e940e8f03 100644
--- a/src/blockencodings.cpp
+++ b/src/blockencodings.cpp
@@ -164,7 +164,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
break;
}
- LogPrint(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock, PROTOCOL_VERSION));
+ LogPrint(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock));
return READ_STATUS_OK;
}
diff --git a/src/coins.cpp b/src/coins.cpp
index b44d920ee1..f576fae748 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -8,7 +8,6 @@
#include <logging.h>
#include <random.h>
#include <util/trace.h>
-#include <version.h>
bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { return false; }
uint256 CCoinsView::GetBestBlock() const { return uint256(); }
@@ -339,7 +338,7 @@ void CCoinsViewCache::SanityCheck() const
assert(recomputed_usage == cachedCoinsUsage);
}
-static const size_t MIN_TRANSACTION_OUTPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxOut(), PROTOCOL_VERSION);
+static const size_t MIN_TRANSACTION_OUTPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxOut());
static const size_t MAX_OUTPUTS_PER_BLOCK = MAX_BLOCK_WEIGHT / MIN_TRANSACTION_OUTPUT_WEIGHT;
const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)
diff --git a/src/coins.h b/src/coins.h
index a6cbb03133..bbf9e3895f 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -145,8 +145,7 @@ using CCoinsMap = std::unordered_map<COutPoint,
SaltedOutpointHasher,
std::equal_to<COutPoint>,
PoolAllocator<std::pair<const COutPoint, CCoinsCacheEntry>,
- sizeof(std::pair<const COutPoint, CCoinsCacheEntry>) + sizeof(void*) * 4,
- alignof(void*)>>;
+ sizeof(std::pair<const COutPoint, CCoinsCacheEntry>) + sizeof(void*) * 4>>;
using CCoinsMapMemoryResource = CCoinsMap::allocator_type::ResourceType;
diff --git a/src/consensus/validation.h b/src/consensus/validation.h
index 3fdc01e66b..1556c7888f 100644
--- a/src/consensus/validation.h
+++ b/src/consensus/validation.h
@@ -7,7 +7,6 @@
#define BITCOIN_CONSENSUS_VALIDATION_H
#include <string>
-#include <version.h>
#include <consensus/consensus.h>
#include <primitives/transaction.h>
#include <primitives/block.h>
diff --git a/src/core_read.cpp b/src/core_read.cpp
index bffb9e9042..e32e46d1b9 100644
--- a/src/core_read.cpp
+++ b/src/core_read.cpp
@@ -12,7 +12,6 @@
#include <streams.h>
#include <util/result.h>
#include <util/strencodings.h>
-#include <version.h>
#include <algorithm>
#include <string>
diff --git a/src/external_signer.cpp b/src/external_signer.cpp
index 102c58b56a..15024f6e0f 100644
--- a/src/external_signer.cpp
+++ b/src/external_signer.cpp
@@ -2,12 +2,14 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include <external_signer.h>
+
#include <chainparams.h>
#include <common/run_command.h>
#include <core_io.h>
#include <psbt.h>
#include <util/strencodings.h>
-#include <external_signer.h>
+#include <version.h>
#include <algorithm>
#include <stdexcept>
diff --git a/src/hash.h b/src/hash.h
index 132e1a9fb3..52babf8b1d 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -14,7 +14,6 @@
#include <serialize.h>
#include <span.h>
#include <uint256.h>
-#include <version.h>
#include <string>
#include <vector>
diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp
index 5fda798efd..58f777b326 100644
--- a/src/index/blockfilterindex.cpp
+++ b/src/index/blockfilterindex.cpp
@@ -174,8 +174,8 @@ size_t BlockFilterIndex::WriteFilterToDisk(FlatFilePos& pos, const BlockFilter&
assert(filter.GetFilterType() == GetFilterType());
size_t data_size =
- GetSerializeSize(filter.GetBlockHash(), CLIENT_VERSION) +
- GetSerializeSize(filter.GetEncodedFilter(), CLIENT_VERSION);
+ GetSerializeSize(filter.GetBlockHash()) +
+ GetSerializeSize(filter.GetEncodedFilter());
// If writing the filter would overflow the file, flush and move to the next one.
if (pos.nPos + data_size > MAX_FLTR_FILE_SIZE) {
diff --git a/src/kernel/coinstats.cpp b/src/kernel/coinstats.cpp
index 9bd755ed27..302638cdbe 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>
diff --git a/src/net.h b/src/net.h
index 16312cf72d..aa75df075d 100644
--- a/src/net.h
+++ b/src/net.h
@@ -30,6 +30,7 @@
#include <util/check.h>
#include <util/sock.h>
#include <util/threadinterrupt.h>
+#include <version.h>
#include <atomic>
#include <condition_variable>
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index c1c60b59d2..1556dc7e67 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2449,7 +2449,7 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
// of transactions relevant to them, without having to download the
// entire memory pool.
// Also, other nodes can use these messages to automatically request a
- // transaction from some other peer that annnounced it, and stop
+ // transaction from some other peer that announced it, and stop
// waiting for us to respond.
// In normal operation, we often send NOTFOUND messages for parents of
// transactions that we relay; if a peer is missing a parent, they may
@@ -3594,7 +3594,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
return;
}
- // Log succesful connections unconditionally for outbound, but not for inbound as those
+ // Log successful connections unconditionally for outbound, but not for inbound as those
// can be triggered by an attacker at high rate.
if (!pfrom.IsInboundConn() || LogAcceptCategory(BCLog::NET, BCLog::Level::Debug)) {
const auto mapped_as{m_connman.GetMappedAS(pfrom.addr)};
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index 1108cc676b..c066d1c939 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -662,7 +662,7 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
}
// Write index header
- unsigned int nSize = GetSerializeSize(blockundo, CLIENT_VERSION);
+ unsigned int nSize = GetSerializeSize(blockundo);
fileout << GetParams().MessageStart() << nSize;
// Write undo data
@@ -979,7 +979,7 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid
// Write undo information to disk
if (block.GetUndoPos().IsNull()) {
FlatFilePos _pos;
- if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo, CLIENT_VERSION) + 40)) {
+ if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo) + 40)) {
return error("ConnectBlock(): FindUndoPos failed");
}
if (!UndoWriteToDisk(blockundo, _pos, block.pprev->GetBlockHash())) {
diff --git a/src/policy/policy.h b/src/policy/policy.h
index d1c8148800..6a7980c312 100644
--- a/src/policy/policy.h
+++ b/src/policy/policy.h
@@ -98,7 +98,7 @@ static constexpr unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS{SCRIPT_VERIFY_P2SH |
* Standard script verification flags that standard transactions will comply
* with. However we do not ban/disconnect nodes that forward txs violating
* the additional (non-mandatory) rules here, to improve forwards and
- * backwards compatability.
+ * backwards compatibility.
*/
static constexpr unsigned int STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRIPT_VERIFY_FLAGS |
SCRIPT_VERIFY_STRICTENC |
diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp
index 6650277c2b..82fb59d349 100644
--- a/src/primitives/transaction.cpp
+++ b/src/primitives/transaction.cpp
@@ -13,7 +13,6 @@
#include <uint256.h>
#include <util/strencodings.h>
#include <util/transaction_identifier.h>
-#include <version.h>
#include <cassert>
#include <stdexcept>
diff --git a/src/psbt.cpp b/src/psbt.cpp
index 76a2fd8241..e46032f5d5 100644
--- a/src/psbt.cpp
+++ b/src/psbt.cpp
@@ -8,6 +8,7 @@
#include <script/signingprovider.h>
#include <util/check.h>
#include <util/strencodings.h>
+#include <version.h>
PartiallySignedTransaction::PartiallySignedTransaction(const CMutableTransaction& tx) : tx(tx)
diff --git a/src/psbt.h b/src/psbt.h
index 1fd186f6a5..a14df03837 100644
--- a/src/psbt.h
+++ b/src/psbt.h
@@ -89,7 +89,9 @@ struct PSBTProprietary
template<typename Stream, typename... X>
void SerializeToVector(Stream& s, const X&... args)
{
- WriteCompactSize(s, GetSerializeSizeMany(s.GetVersion(), args...));
+ SizeComputer sizecomp;
+ SerializeMany(sizecomp, args...);
+ WriteCompactSize(s, sizecomp.size());
SerializeMany(s, args...);
}
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 486e51c777..d4267fcf61 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -219,7 +219,7 @@ public:
// If a status update is needed (blocks came in since last check),
// try to update the status of this transaction from the wallet.
- // Otherwise, simply re-use the cached status.
+ // Otherwise, simply reuse the cached status.
interfaces::WalletTxStatus wtx;
int numBlocks;
int64_t block_time;
diff --git a/src/rest.cpp b/src/rest.cpp
index f86c47ee6b..3894b5141d 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -28,7 +28,6 @@
#include <util/check.h>
#include <util/strencodings.h>
#include <validation.h>
-#include <version.h>
#include <any>
#include <string>
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 9a29b73bee..6a3aa397d9 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -1861,7 +1861,7 @@ static RPCHelpMan getblockstats()
for (const CTxOut& out : tx->vout) {
tx_total_out += out.nValue;
- size_t out_size = GetSerializeSize(out, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD;
+ size_t out_size = GetSerializeSize(out) + PER_UTXO_OVERHEAD;
utxo_size_inc += out_size;
// The Genesis block and the repeated BIP30 block coinbases don't change the UTXO
@@ -1913,7 +1913,7 @@ static RPCHelpMan getblockstats()
const CTxOut& prevoutput = coin.out;
tx_total_in += prevoutput.nValue;
- size_t prevout_size = GetSerializeSize(prevoutput, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD;
+ size_t prevout_size = GetSerializeSize(prevoutput) + PER_UTXO_OVERHEAD;
utxo_size_inc -= prevout_size;
utxo_size_inc_actual -= prevout_size;
}
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index 397ece08c0..e8bcbd8a2b 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -40,6 +40,7 @@
#include <util/vector.h>
#include <validation.h>
#include <validationinterface.h>
+#include <version.h>
#include <numeric>
#include <stdint.h>
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 5de05e2e67..7adc28f416 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -409,7 +409,7 @@ static inline JSONRPCRequest transformNamedArguments(const JSONRPCRequest& in, c
}
// Process expected parameters. If any parameters were left unspecified in
// the request before a parameter that was specified, null values need to be
- // inserted at the unspecifed parameter positions, and the "hole" variable
+ // inserted at the unspecified parameter positions, and the "hole" variable
// below tracks the number of null values that need to be inserted.
// The "initial_hole_size" variable stores the size of the initial hole,
// i.e. how many initial positional arguments were left unspecified. This is
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index 63618ad202..cf48ee11e7 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -1089,7 +1089,7 @@ UniValue RPCResult::MatchesType(const UniValue& result) const
if (UniValue::VARR == result.getType()) {
UniValue errors(UniValue::VOBJ);
for (size_t i{0}; i < result.get_array().size(); ++i) {
- // If there are more results than documented, re-use the last doc_inner.
+ // If there are more results than documented, reuse the last doc_inner.
const RPCResult& doc_inner{m_inner.at(std::min(m_inner.size() - 1, i))};
UniValue match{doc_inner.MatchesType(result.get_array()[i])};
if (!match.isTrue()) errors.pushKV(strprintf("%d", i), match);
diff --git a/src/rpc/util.h b/src/rpc/util.h
index d2137993de..e2d5ed333c 100644
--- a/src/rpc/util.h
+++ b/src/rpc/util.h
@@ -402,7 +402,7 @@ public:
* RPC method implementations. The helper internally checks whether the
* user-passed argument isNull() and parses (from JSON) and returns the
* user-passed argument, or the default value derived from the RPCArg
- * documention, or a falsy value if no default was given.
+ * documentation, or a falsy value if no default was given.
*
* Use Arg<Type>(i) to get the argument or its default value. Otherwise,
* use MaybeArg<Type>(i) to get the optional argument or a falsy value.
diff --git a/src/script/bitcoinconsensus.cpp b/src/script/bitcoinconsensus.cpp
index 2ca8dac48c..c4eccacf41 100644
--- a/src/script/bitcoinconsensus.cpp
+++ b/src/script/bitcoinconsensus.cpp
@@ -8,7 +8,6 @@
#include <primitives/transaction.h>
#include <pubkey.h>
#include <script/interpreter.h>
-#include <version.h>
namespace {
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 5f4a1aceb2..c969ce45f1 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -1934,7 +1934,7 @@ static bool VerifyWitnessProgram(const CScriptWitness& witness, int witversion,
if ((control[0] & TAPROOT_LEAF_MASK) == TAPROOT_LEAF_TAPSCRIPT) {
// Tapscript (leaf version 0xc0)
exec_script = CScript(script.begin(), script.end());
- execdata.m_validation_weight_left = ::GetSerializeSize(witness.stack, PROTOCOL_VERSION) + VALIDATION_WEIGHT_OFFSET;
+ execdata.m_validation_weight_left = ::GetSerializeSize(witness.stack) + VALIDATION_WEIGHT_OFFSET;
execdata.m_validation_weight_left_init = true;
return ExecuteWitnessScript(stack, exec_script, flags, SigVersion::TAPSCRIPT, checker, execdata, serror);
}
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index 251a8420f7..be4b357568 100644
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -379,7 +379,7 @@ static bool SignTaproot(const SigningProvider& provider, const BaseSignatureCrea
result_stack.emplace_back(std::begin(script), std::end(script)); // Push the script
result_stack.push_back(*control_blocks.begin()); // Push the smallest control block
if (smallest_result_stack.size() == 0 ||
- GetSerializeSize(result_stack, PROTOCOL_VERSION) < GetSerializeSize(smallest_result_stack, PROTOCOL_VERSION)) {
+ GetSerializeSize(result_stack) < GetSerializeSize(smallest_result_stack)) {
smallest_result_stack = std::move(result_stack);
}
}
diff --git a/src/serialize.h b/src/serialize.h
index b09d6fbe60..83715866f5 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -124,7 +124,7 @@ template<typename Stream> inline uint64_t ser_readdata64(Stream &s)
// i.e. anything that supports .read(Span<std::byte>) and .write(Span<const std::byte>)
//
-class CSizeComputer;
+class SizeComputer;
enum
{
@@ -324,7 +324,7 @@ constexpr inline unsigned int GetSizeOfCompactSize(uint64_t nSize)
else return sizeof(unsigned char) + sizeof(uint64_t);
}
-inline void WriteCompactSize(CSizeComputer& os, uint64_t nSize);
+inline void WriteCompactSize(SizeComputer& os, uint64_t nSize);
template<typename Stream>
void WriteCompactSize(Stream& os, uint64_t nSize)
@@ -450,7 +450,7 @@ inline unsigned int GetSizeOfVarInt(I n)
}
template<typename I>
-inline void WriteVarInt(CSizeComputer& os, I n);
+inline void WriteVarInt(SizeComputer& os, I n);
template<typename Stream, VarIntMode Mode, typename I>
void WriteVarInt(Stream& os, I n)
@@ -1070,22 +1070,21 @@ struct ActionUnserialize {
/* ::GetSerializeSize implementations
*
* Computing the serialized size of objects is done through a special stream
- * object of type CSizeComputer, which only records the number of bytes written
+ * object of type SizeComputer, which only records the number of bytes written
* to it.
*
* If your Serialize or SerializationOp method has non-trivial overhead for
* serialization, it may be worthwhile to implement a specialized version for
- * CSizeComputer, which uses the s.seek() method to record bytes that would
+ * SizeComputer, which uses the s.seek() method to record bytes that would
* be written instead.
*/
-class CSizeComputer
+class SizeComputer
{
protected:
size_t nSize{0};
- const int nVersion;
public:
- explicit CSizeComputer(int nVersionIn) : nVersion(nVersionIn) {}
+ SizeComputer() {}
void write(Span<const std::byte> src)
{
@@ -1099,7 +1098,7 @@ public:
}
template<typename T>
- CSizeComputer& operator<<(const T& obj)
+ SizeComputer& operator<<(const T& obj)
{
::Serialize(*this, obj);
return (*this);
@@ -1108,33 +1107,23 @@ public:
size_t size() const {
return nSize;
}
-
- int GetVersion() const { return nVersion; }
};
template<typename I>
-inline void WriteVarInt(CSizeComputer &s, I n)
+inline void WriteVarInt(SizeComputer &s, I n)
{
s.seek(GetSizeOfVarInt<I>(n));
}
-inline void WriteCompactSize(CSizeComputer &s, uint64_t nSize)
+inline void WriteCompactSize(SizeComputer &s, uint64_t nSize)
{
s.seek(GetSizeOfCompactSize(nSize));
}
template <typename T>
-size_t GetSerializeSize(const T& t, int nVersion = 0)
-{
- return (CSizeComputer(nVersion) << t).size();
-}
-
-template <typename... T>
-size_t GetSerializeSizeMany(int nVersion, const T&... t)
+size_t GetSerializeSize(const T& t)
{
- CSizeComputer sc(nVersion);
- SerializeMany(sc, t...);
- return sc.size();
+ return (SizeComputer() << t).size();
}
/** Wrapper that overrides the GetParams() function of a stream (and hides GetVersion/GetType). */
diff --git a/src/signet.cpp b/src/signet.cpp
index ef0faaa5f8..d6a3a44d91 100644
--- a/src/signet.cpp
+++ b/src/signet.cpp
@@ -22,6 +22,7 @@
#include <streams.h>
#include <uint256.h>
#include <util/strencodings.h>
+#include <version.h>
static constexpr uint8_t SIGNET_HEADER[4] = {0xec, 0xc7, 0xda, 0xa2};
diff --git a/src/support/allocators/pool.h b/src/support/allocators/pool.h
index c8e70ebacf..873e260b65 100644
--- a/src/support/allocators/pool.h
+++ b/src/support/allocators/pool.h
@@ -272,7 +272,7 @@ public:
/**
* Forwards all allocations/deallocations to the PoolResource.
*/
-template <class T, std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES>
+template <class T, std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
class PoolAllocator
{
PoolResource<MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES>* m_resource;
diff --git a/src/test/flatfile_tests.cpp b/src/test/flatfile_tests.cpp
index 3874b38f61..21a36d9d43 100644
--- a/src/test/flatfile_tests.cpp
+++ b/src/test/flatfile_tests.cpp
@@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE(flatfile_open)
"lost if a trusted third party is still required to prevent double-spending.");
size_t pos1 = 0;
- size_t pos2 = pos1 + GetSerializeSize(line1, CLIENT_VERSION);
+ size_t pos2 = pos1 + GetSerializeSize(line1);
// Write first line to file.
{
diff --git a/src/test/fuzz/FuzzedDataProvider.h b/src/test/fuzz/FuzzedDataProvider.h
index 8a8214bd99..5903ed8379 100644
--- a/src/test/fuzz/FuzzedDataProvider.h
+++ b/src/test/fuzz/FuzzedDataProvider.h
@@ -158,7 +158,7 @@ FuzzedDataProvider::ConsumeRandomLengthString(size_t max_length) {
// picking its contents.
std::string result;
- // Reserve the anticipated capaticity to prevent several reallocations.
+ // Reserve the anticipated capacity to prevent several reallocations.
result.reserve(std::min(max_length, remaining_bytes_));
for (size_t i = 0; i < max_length && remaining_bytes_ != 0; ++i) {
char next = ConvertUnsignedToSigned<char>(data_ptr_[0]);
diff --git a/src/test/fuzz/autofile.cpp b/src/test/fuzz/autofile.cpp
index a7b41370a8..45316b6b21 100644
--- a/src/test/fuzz/autofile.cpp
+++ b/src/test/fuzz/autofile.cpp
@@ -2,24 +2,28 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include <span.h>
#include <streams.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <array>
-#include <cstdint>
+#include <cstddef>
+#include <cstdio>
#include <iostream>
-#include <optional>
-#include <string>
#include <vector>
FUZZ_TARGET(autofile)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
- FuzzedAutoFileProvider fuzzed_auto_file_provider = ConsumeAutoFile(fuzzed_data_provider);
- AutoFile auto_file{fuzzed_auto_file_provider.open()};
- LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
+ AutoFile auto_file{
+ fuzzed_file_provider.open(),
+ ConsumeRandomLengthByteVector<std::byte>(fuzzed_data_provider),
+ };
+ LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 100)
+ {
CallOneOf(
fuzzed_data_provider,
[&] {
diff --git a/src/test/fuzz/buffered_file.cpp b/src/test/fuzz/buffered_file.cpp
index 636f11b381..813af63738 100644
--- a/src/test/fuzz/buffered_file.cpp
+++ b/src/test/fuzz/buffered_file.cpp
@@ -2,31 +2,37 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include <span.h>
#include <streams.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <array>
+#include <cstddef>
#include <cstdint>
#include <iostream>
#include <optional>
-#include <string>
#include <vector>
FUZZ_TARGET(buffered_file)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
- FuzzedFileProvider fuzzed_file_provider = ConsumeFile(fuzzed_data_provider);
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
std::optional<BufferedFile> opt_buffered_file;
- CAutoFile fuzzed_file{fuzzed_file_provider.open(), 0};
+ CAutoFile fuzzed_file{
+ fuzzed_file_provider.open(),
+ 0,
+ ConsumeRandomLengthByteVector<std::byte>(fuzzed_data_provider),
+ };
try {
opt_buffered_file.emplace(fuzzed_file, fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096), fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096));
} catch (const std::ios_base::failure&) {
}
if (opt_buffered_file && !fuzzed_file.IsNull()) {
bool setpos_fail = false;
- LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
+ LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 100)
+ {
CallOneOf(
fuzzed_data_provider,
[&] {
diff --git a/src/test/fuzz/load_external_block_file.cpp b/src/test/fuzz/load_external_block_file.cpp
index fc903e5ec2..ae4f5d089b 100644
--- a/src/test/fuzz/load_external_block_file.cpp
+++ b/src/test/fuzz/load_external_block_file.cpp
@@ -27,7 +27,7 @@ void initialize_load_external_block_file()
FUZZ_TARGET(load_external_block_file, .init = initialize_load_external_block_file)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
- FuzzedFileProvider fuzzed_file_provider = ConsumeFile(fuzzed_data_provider);
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
CAutoFile fuzzed_block_file{fuzzed_file_provider.open(), CLIENT_VERSION};
if (fuzzed_block_file.IsNull()) {
return;
diff --git a/src/test/fuzz/miniscript.cpp b/src/test/fuzz/miniscript.cpp
index 8c73edfa9d..0d0ee59ab3 100644
--- a/src/test/fuzz/miniscript.cpp
+++ b/src/test/fuzz/miniscript.cpp
@@ -1121,7 +1121,7 @@ void TestNode(const MsCtx script_ctx, const NodeRef& node, FuzzedDataProvider& p
assert(mal_success);
assert(stack_nonmal == stack_mal);
// Compute witness size (excluding script push, control block, and witness count encoding).
- const size_t wit_size = GetSerializeSize(stack_nonmal, PROTOCOL_VERSION) - GetSizeOfCompactSize(stack_nonmal.size());
+ const size_t wit_size = GetSerializeSize(stack_nonmal) - GetSizeOfCompactSize(stack_nonmal.size());
assert(wit_size <= *node->GetWitnessSize());
// Test non-malleable satisfaction.
diff --git a/src/test/fuzz/package_eval.cpp b/src/test/fuzz/package_eval.cpp
index 8d316134cc..8658c0b45a 100644
--- a/src/test/fuzz/package_eval.cpp
+++ b/src/test/fuzz/package_eval.cpp
@@ -40,7 +40,7 @@ void initialize_tx_pool()
g_setup = testing_setup.get();
for (int i = 0; i < 2 * COINBASE_MATURITY; ++i) {
- COutPoint prevout{MineBlock(g_setup->m_node, P2WSH_OP_TRUE)};
+ COutPoint prevout{MineBlock(g_setup->m_node, P2WSH_EMPTY)};
if (i < COINBASE_MATURITY) {
// Remember the txids to avoid expensive disk access later on
g_outpoints_coinbase_init_mature.push_back(prevout);
@@ -195,7 +195,8 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
// Create input
const auto sequence = ConsumeSequence(fuzzed_data_provider);
const auto script_sig = CScript{};
- const auto script_wit_stack = std::vector<std::vector<uint8_t>>{WITNESS_STACK_ELEM_OP_TRUE};
+ const auto script_wit_stack = fuzzed_data_provider.ConsumeBool() ? P2WSH_EMPTY_TRUE_STACK : P2WSH_EMPTY_TWO_STACK;
+
CTxIn in;
in.prevout = outpoint;
in.nSequence = sequence;
@@ -204,17 +205,30 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
tx_mut.vin.push_back(in);
}
+
+ // Duplicate an input
+ bool dup_input = fuzzed_data_provider.ConsumeBool();
+ if (dup_input) {
+ tx_mut.vin.push_back(tx_mut.vin.back());
+ }
+
+ // Refer to a non-existant input
+ if (fuzzed_data_provider.ConsumeBool()) {
+ tx_mut.vin.emplace_back();
+ }
+
const auto amount_fee = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(0, amount_in);
const auto amount_out = (amount_in - amount_fee) / num_out;
for (int i = 0; i < num_out; ++i) {
- tx_mut.vout.emplace_back(amount_out, P2WSH_OP_TRUE);
+ tx_mut.vout.emplace_back(amount_out, P2WSH_EMPTY);
}
// TODO vary transaction sizes to catch size-related issues
auto tx = MakeTransactionRef(tx_mut);
// Restore previously removed outpoints, except in-package outpoints
if (!last_tx) {
for (const auto& in : tx->vin) {
- Assert(outpoints.insert(in.prevout).second);
+ // It's a fake input, or a new input, or a duplicate
+ Assert(in == CTxIn() || outpoints.insert(in.prevout).second || dup_input);
}
// Cache the in-package outpoints being made
for (size_t i = 0; i < tx->vout.size(); ++i) {
diff --git a/src/test/fuzz/policy_estimator.cpp b/src/test/fuzz/policy_estimator.cpp
index a6275d2fd2..220799be41 100644
--- a/src/test/fuzz/policy_estimator.cpp
+++ b/src/test/fuzz/policy_estimator.cpp
@@ -13,6 +13,7 @@
#include <test/fuzz/util/mempool.h>
#include <test/util/setup_common.h>
+#include <memory>
#include <optional>
#include <vector>
@@ -81,8 +82,8 @@ FUZZ_TARGET(policy_estimator, .init = initialize_policy_estimator)
(void)block_policy_estimator.HighestTargetTracked(fuzzed_data_provider.PickValueInArray(ALL_FEE_ESTIMATE_HORIZONS));
}
{
- FuzzedAutoFileProvider fuzzed_auto_file_provider = ConsumeAutoFile(fuzzed_data_provider);
- AutoFile fuzzed_auto_file{fuzzed_auto_file_provider.open()};
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
+ AutoFile fuzzed_auto_file{fuzzed_file_provider.open()};
block_policy_estimator.Write(fuzzed_auto_file);
block_policy_estimator.Read(fuzzed_auto_file);
}
diff --git a/src/test/fuzz/policy_estimator_io.cpp b/src/test/fuzz/policy_estimator_io.cpp
index c04ef8f5b0..3e7d093343 100644
--- a/src/test/fuzz/policy_estimator_io.cpp
+++ b/src/test/fuzz/policy_estimator_io.cpp
@@ -4,13 +4,13 @@
#include <policy/fees.h>
#include <policy/fees_args.h>
+#include <streams.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <test/util/setup_common.h>
-#include <cstdint>
-#include <vector>
+#include <memory>
namespace {
const BasicTestingSetup* g_setup;
@@ -25,8 +25,8 @@ void initialize_policy_estimator_io()
FUZZ_TARGET(policy_estimator_io, .init = initialize_policy_estimator_io)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
- FuzzedAutoFileProvider fuzzed_auto_file_provider = ConsumeAutoFile(fuzzed_data_provider);
- AutoFile fuzzed_auto_file{fuzzed_auto_file_provider.open()};
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
+ AutoFile fuzzed_auto_file{fuzzed_file_provider.open()};
// Re-using block_policy_estimator across runs to avoid costly creation of CBlockPolicyEstimator object.
static CBlockPolicyEstimator block_policy_estimator{FeeestPath(*g_setup->m_node.args), DEFAULT_ACCEPT_STALE_FEE_ESTIMATES};
if (block_policy_estimator.Read(fuzzed_auto_file)) {
diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h
index 95d910b64d..0ad2ed6128 100644
--- a/src/test/fuzz/util.h
+++ b/src/test/fuzz/util.h
@@ -263,31 +263,6 @@ public:
static int close(void* cookie);
};
-[[nodiscard]] inline FuzzedFileProvider ConsumeFile(FuzzedDataProvider& fuzzed_data_provider) noexcept
-{
- return {fuzzed_data_provider};
-}
-
-class FuzzedAutoFileProvider
-{
- FuzzedFileProvider m_fuzzed_file_provider;
-
-public:
- FuzzedAutoFileProvider(FuzzedDataProvider& fuzzed_data_provider) : m_fuzzed_file_provider{fuzzed_data_provider}
- {
- }
-
- AutoFile open()
- {
- return AutoFile{m_fuzzed_file_provider.open()};
- }
-};
-
-[[nodiscard]] inline FuzzedAutoFileProvider ConsumeAutoFile(FuzzedDataProvider& fuzzed_data_provider) noexcept
-{
- return {fuzzed_data_provider};
-}
-
#define WRITE_TO_STREAM_CASE(type, consume) \
[&] { \
type o = consume; \
diff --git a/src/test/fuzz/validation_load_mempool.cpp b/src/test/fuzz/validation_load_mempool.cpp
index 5d020b4d59..00678742c9 100644
--- a/src/test/fuzz/validation_load_mempool.cpp
+++ b/src/test/fuzz/validation_load_mempool.cpp
@@ -38,7 +38,7 @@ FUZZ_TARGET(validation_load_mempool, .init = initialize_validation_load_mempool)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
SetMockTime(ConsumeTime(fuzzed_data_provider));
- FuzzedFileProvider fuzzed_file_provider = ConsumeFile(fuzzed_data_provider);
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
CTxMemPool pool{MemPoolOptionsForTest(g_setup->m_node)};
diff --git a/src/test/miniscript_tests.cpp b/src/test/miniscript_tests.cpp
index 996c379962..1f28e61bc9 100644
--- a/src/test/miniscript_tests.cpp
+++ b/src/test/miniscript_tests.cpp
@@ -369,7 +369,7 @@ void TestSatisfy(const KeyConverter& converter, const std::string& testcase, con
CScriptWitness witness_nonmal;
const bool nonmal_success = node->Satisfy(satisfier, witness_nonmal.stack, true) == miniscript::Availability::YES;
// Compute witness size (excluding script push, control block, and witness count encoding).
- const size_t wit_size = GetSerializeSize(witness_nonmal.stack, PROTOCOL_VERSION) - GetSizeOfCompactSize(witness_nonmal.stack.size());
+ const size_t wit_size = GetSerializeSize(witness_nonmal.stack) - GetSizeOfCompactSize(witness_nonmal.stack.size());
SatisfactionToWitness(converter.MsContext(), witness_nonmal, script, builder);
if (nonmal_success) {
diff --git a/src/test/orphanage_tests.cpp b/src/test/orphanage_tests.cpp
index d374497a45..b51de30cb2 100644
--- a/src/test/orphanage_tests.cpp
+++ b/src/test/orphanage_tests.cpp
@@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
}
SignatureData empty;
BOOST_CHECK(SignSignature(keystore, *txPrev, tx, 0, SIGHASH_ALL, empty));
- // Re-use same signature for other inputs
+ // Reuse same signature for other inputs
// (they don't have to be valid for this test)
for (unsigned int j = 1; j < tx.vin.size(); j++)
tx.vin[j].scriptSig = tx.vin[0].scriptSig;
diff --git a/src/test/pool_tests.cpp b/src/test/pool_tests.cpp
index 8a07e09a44..5ad4afa3a1 100644
--- a/src/test/pool_tests.cpp
+++ b/src/test/pool_tests.cpp
@@ -156,21 +156,20 @@ BOOST_AUTO_TEST_CASE(random_allocations)
BOOST_AUTO_TEST_CASE(memusage_test)
{
- auto std_map = std::unordered_map<int, int>{};
-
- using Map = std::unordered_map<int,
- int,
- std::hash<int>,
- std::equal_to<int>,
- PoolAllocator<std::pair<const int, int>,
- sizeof(std::pair<const int, int>) + sizeof(void*) * 4,
- alignof(void*)>>;
+ auto std_map = std::unordered_map<int64_t, int64_t>{};
+
+ using Map = std::unordered_map<int64_t,
+ int64_t,
+ std::hash<int64_t>,
+ std::equal_to<int64_t>,
+ PoolAllocator<std::pair<const int64_t, int64_t>,
+ sizeof(std::pair<const int64_t, int64_t>) + sizeof(void*) * 4>>;
auto resource = Map::allocator_type::ResourceType(1024);
PoolResourceTester::CheckAllDataAccountedFor(resource);
{
- auto resource_map = Map{0, std::hash<int>{}, std::equal_to<int>{}, &resource};
+ auto resource_map = Map{0, std::hash<int64_t>{}, std::equal_to<int64_t>{}, &resource};
// can't have the same resource usage
BOOST_TEST(memusage::DynamicUsage(std_map) != memusage::DynamicUsage(resource_map));
@@ -182,6 +181,11 @@ BOOST_AUTO_TEST_CASE(memusage_test)
// Eventually the resource_map should have a much lower memory usage because it has less malloc overhead
BOOST_TEST(memusage::DynamicUsage(resource_map) <= memusage::DynamicUsage(std_map) * 90 / 100);
+
+ // Make sure the pool is actually used by the nodes
+ auto max_nodes_per_chunk = resource.ChunkSizeBytes() / sizeof(Map::value_type);
+ auto min_num_allocated_chunks = resource_map.size() / max_nodes_per_chunk + 1;
+ BOOST_TEST(resource.NumAllocatedChunks() >= min_num_allocated_chunks);
}
PoolResourceTester::CheckAllDataAccountedFor(resource);
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index b05a6da804..874f3e51f7 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -1112,7 +1112,7 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23)
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
keys.clear();
- keys.push_back(key2); keys.push_back(key2); // Can't re-use sig
+ keys.push_back(key2); keys.push_back(key2); // Can't reuse sig
CScript badsig1 = sign_multisig(scriptPubKey23, keys, CTransaction(txTo23));
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, nullptr, gFlags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue, MissingDataBehavior::ASSERT_FAIL), &err));
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp
index 6d5a14ad9e..d75eb499b4 100644
--- a/src/test/serialize_tests.cpp
+++ b/src/test/serialize_tests.cpp
@@ -62,31 +62,31 @@ public:
BOOST_AUTO_TEST_CASE(sizes)
{
- BOOST_CHECK_EQUAL(sizeof(unsigned char), GetSerializeSize((unsigned char)0, 0));
- BOOST_CHECK_EQUAL(sizeof(int8_t), GetSerializeSize(int8_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(uint8_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(int16_t), GetSerializeSize(int16_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(uint16_t), GetSerializeSize(uint16_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(int32_t), GetSerializeSize(int32_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(uint32_t), GetSerializeSize(uint32_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(int64_t), GetSerializeSize(int64_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(uint64_t), GetSerializeSize(uint64_t(0), 0));
+ BOOST_CHECK_EQUAL(sizeof(unsigned char), GetSerializeSize((unsigned char)0));
+ BOOST_CHECK_EQUAL(sizeof(int8_t), GetSerializeSize(int8_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(uint8_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(int16_t), GetSerializeSize(int16_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(uint16_t), GetSerializeSize(uint16_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(int32_t), GetSerializeSize(int32_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(uint32_t), GetSerializeSize(uint32_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(int64_t), GetSerializeSize(int64_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(uint64_t), GetSerializeSize(uint64_t(0)));
// Bool is serialized as uint8_t
- BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(bool(0), 0));
+ BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(bool(0)));
// Sanity-check GetSerializeSize and c++ type matching
- BOOST_CHECK_EQUAL(GetSerializeSize((unsigned char)0, 0), 1U);
- BOOST_CHECK_EQUAL(GetSerializeSize(int8_t(0), 0), 1U);
- BOOST_CHECK_EQUAL(GetSerializeSize(uint8_t(0), 0), 1U);
- BOOST_CHECK_EQUAL(GetSerializeSize(int16_t(0), 0), 2U);
- BOOST_CHECK_EQUAL(GetSerializeSize(uint16_t(0), 0), 2U);
- BOOST_CHECK_EQUAL(GetSerializeSize(int32_t(0), 0), 4U);
- BOOST_CHECK_EQUAL(GetSerializeSize(uint32_t(0), 0), 4U);
- BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0), 0), 8U);
- BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0), 0), 8U);
- BOOST_CHECK_EQUAL(GetSerializeSize(bool(0), 0), 1U);
- BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 1>{0}, 0), 1U);
- BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 2>{0, 0}, 0), 2U);
+ BOOST_CHECK_EQUAL(GetSerializeSize((unsigned char)0), 1U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(int8_t(0)), 1U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(uint8_t(0)), 1U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(int16_t(0)), 2U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(uint16_t(0)), 2U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(int32_t(0)), 4U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(uint32_t(0)), 4U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0)), 8U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0)), 8U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(bool(0)), 1U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 1>{0}), 1U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 2>{0, 0}), 2U);
}
BOOST_AUTO_TEST_CASE(varints)
@@ -97,13 +97,13 @@ BOOST_AUTO_TEST_CASE(varints)
DataStream::size_type size = 0;
for (int i = 0; i < 100000; i++) {
ss << VARINT_MODE(i, VarIntMode::NONNEGATIVE_SIGNED);
- size += ::GetSerializeSize(VARINT_MODE(i, VarIntMode::NONNEGATIVE_SIGNED), 0);
+ size += ::GetSerializeSize(VARINT_MODE(i, VarIntMode::NONNEGATIVE_SIGNED));
BOOST_CHECK(size == ss.size());
}
for (uint64_t i = 0; i < 100000000000ULL; i += 999999937) {
ss << VARINT(i);
- size += ::GetSerializeSize(VARINT(i), 0);
+ size += ::GetSerializeSize(VARINT(i));
BOOST_CHECK(size == ss.size());
}
diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp
index 9caefe43e2..933988dd7a 100644
--- a/src/test/uint256_tests.cpp
+++ b/src/test/uint256_tests.cpp
@@ -184,8 +184,8 @@ BOOST_AUTO_TEST_CASE( methods ) // GetHex SetHex begin() end() size() GetLow64 G
BOOST_CHECK(OneL.begin() + 32 == OneL.end());
BOOST_CHECK(MaxL.begin() + 32 == MaxL.end());
BOOST_CHECK(TmpL.begin() + 32 == TmpL.end());
- BOOST_CHECK(GetSerializeSize(R1L, PROTOCOL_VERSION) == 32);
- BOOST_CHECK(GetSerializeSize(ZeroL, PROTOCOL_VERSION) == 32);
+ BOOST_CHECK(GetSerializeSize(R1L) == 32);
+ BOOST_CHECK(GetSerializeSize(ZeroL) == 32);
DataStream ss{};
ss << R1L;
@@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE( methods ) // GetHex SetHex begin() end() size() GetLow64 G
BOOST_CHECK(OneS.begin() + 20 == OneS.end());
BOOST_CHECK(MaxS.begin() + 20 == MaxS.end());
BOOST_CHECK(TmpS.begin() + 20 == TmpS.end());
- BOOST_CHECK(GetSerializeSize(R1S, PROTOCOL_VERSION) == 20);
- BOOST_CHECK(GetSerializeSize(ZeroS, PROTOCOL_VERSION) == 20);
+ BOOST_CHECK(GetSerializeSize(R1S) == 20);
+ BOOST_CHECK(GetSerializeSize(ZeroS) == 20);
ss << R1S;
BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+20));
diff --git a/src/test/util/script.h b/src/test/util/script.h
index 428b3e10b3..96c4d55e5a 100644
--- a/src/test/util/script.h
+++ b/src/test/util/script.h
@@ -18,6 +18,18 @@ static const CScript P2WSH_OP_TRUE{
return hash;
}())};
+static const std::vector<uint8_t> EMPTY{};
+static const CScript P2WSH_EMPTY{
+ CScript{}
+ << OP_0
+ << ToByteVector([] {
+ uint256 hash;
+ CSHA256().Write(EMPTY.data(), EMPTY.size()).Finalize(hash.begin());
+ return hash;
+ }())};
+static const std::vector<std::vector<uint8_t>> P2WSH_EMPTY_TRUE_STACK{{static_cast<uint8_t>(OP_TRUE)}, {}};
+static const std::vector<std::vector<uint8_t>> P2WSH_EMPTY_TWO_STACK{{static_cast<uint8_t>(OP_2)}, {}};
+
/** Flags that are not forbidden by an assert in script validation */
bool IsValidFlagCombination(unsigned flags);
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
index 4e1a26f303..b60cf7e4fd 100644
--- a/src/test/util/setup_common.h
+++ b/src/test/util/setup_common.h
@@ -17,6 +17,7 @@
#include <util/fs.h>
#include <util/string.h>
#include <util/vector.h>
+#include <version.h>
#include <functional>
#include <type_traits>
diff --git a/src/test/versionbits_tests.cpp b/src/test/versionbits_tests.cpp
index 9e69992752..f462895edb 100644
--- a/src/test/versionbits_tests.cpp
+++ b/src/test/versionbits_tests.cpp
@@ -424,7 +424,7 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
uint32_t chain_all_vbits{0};
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) {
const auto dep = static_cast<Consensus::DeploymentPos>(i);
- // Check that no bits are re-used (within the same chain). This is
+ // Check that no bits are reused (within the same chain). This is
// disallowed because the transition to FAILED (on timeout) does
// not take precedence over STARTED/LOCKED_IN. So all softforks on
// the same bit might overlap, even when non-overlapping start-end
diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp
index 60cf31a964..11d13d050a 100644
--- a/src/torcontrol.cpp
+++ b/src/torcontrol.cpp
@@ -251,7 +251,7 @@ std::map<std::string,std::string> ParseTorReplyMapping(const std::string &s)
/**
* Unescape value. Per https://spec.torproject.org/control-spec section 2.1.1:
*
- * For future-proofing, controller implementors MAY use the following
+ * For future-proofing, controller implementers MAY use the following
* rules to be compatible with buggy Tor implementations and with
* future ones that implement the spec as intended:
*
diff --git a/src/txmempool.h b/src/txmempool.h
index 122bac09b1..aed6acd9da 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -478,7 +478,7 @@ public:
void removeRecursive(const CTransaction& tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
/** After reorg, filter the entries that would no longer be valid in the next block, and update
* the entries' cached LockPoints if needed. The mempool does not have any knowledge of
- * consensus rules. It just appplies the callable function and removes the ones for which it
+ * consensus rules. It just applies the callable function and removes the ones for which it
* returns true.
* @param[in] filter_final_and_mature Predicate that checks the relevant validation rules
* and updates an entry's LockPoints.
diff --git a/src/undo.h b/src/undo.h
index a98f046735..1fb9ac0688 100644
--- a/src/undo.h
+++ b/src/undo.h
@@ -11,7 +11,6 @@
#include <consensus/consensus.h>
#include <primitives/transaction.h>
#include <serialize.h>
-#include <version.h>
/** Formatter for undo information for a CTxIn
*
diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp
index f0fd789c96..d9a08310a8 100644
--- a/src/wallet/feebumper.cpp
+++ b/src/wallet/feebumper.cpp
@@ -170,7 +170,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
return Result::INVALID_PARAMETER;
}
- // We are going to modify coin control later, copy to re-use
+ // We are going to modify coin control later, copy to reuse
CCoinControl new_coin_control(coin_control);
LOCK(wallet.cs_wallet);
diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp
index 0f7a882034..6519504618 100644
--- a/src/wallet/rpc/spend.cpp
+++ b/src/wallet/rpc/spend.cpp
@@ -19,6 +19,7 @@
#include <wallet/rpc/util.h>
#include <wallet/spend.h>
#include <wallet/wallet.h>
+#include <version.h>
#include <univalue.h>
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index ed0134375c..d586f6d4aa 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -1081,7 +1081,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
CTxOut txout(recipient.nAmount, GetScriptForDestination(recipient.dest));
// Include the fee cost for outputs.
- coin_selection_params.tx_noinputs_size += ::GetSerializeSize(txout, PROTOCOL_VERSION);
+ coin_selection_params.tx_noinputs_size += ::GetSerializeSize(txout);
if (IsDust(txout, wallet.chain().relayDustFee())) {
return util::Error{_("Transaction amount too small")};
@@ -1257,7 +1257,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
}
// Before we return success, we assume any change key will be used to prevent
- // accidental re-use.
+ // accidental reuse.
reservedest.KeepDestination();
wallet.WalletLogPrintf("Fee Calculation: Fee:%d Bytes:%u Tgt:%d (requested %d) Reason:\"%s\" Decay %.5f: Estimation: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out) Fail: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out)\n",
@@ -1299,7 +1299,7 @@ util::Result<CreatedTransactionResult> CreateTransaction(
CCoinControl tmp_cc = coin_control;
tmp_cc.m_avoid_partial_spends = true;
- // Re-use the change destination from the first creation attempt to avoid skipping BIP44 indexes
+ // Reuse the change destination from the first creation attempt to avoid skipping BIP44 indexes
const int ungrouped_change_pos = txr_ungrouped.change_pos;
if (ungrouped_change_pos != -1) {
ExtractDestination(txr_ungrouped.tx->vout[ungrouped_change_pos].scriptPubKey, tmp_cc.destChange);
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 0832887159..bc45010200 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -178,7 +178,7 @@ static const std::map<std::string,WalletFlags> WALLET_FLAG_MAP{
* Instantiating a ReserveDestination does not reserve an address. To do so,
* GetReservedDestination() needs to be called on the object. Once an address has been
* reserved, call KeepDestination() on the ReserveDestination object to make sure it is not
- * returned. Call ReturnDestination() to return the address so it can be re-used (for
+ * returned. Call ReturnDestination() to return the address so it can be reused (for
* example, if the address was used in a new transaction
* and that transaction was not completed and needed to be aborted).
*
diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp
index a4fb915d71..54d125e47b 100644
--- a/src/zmq/zmqpublishnotifier.cpp
+++ b/src/zmq/zmqpublishnotifier.cpp
@@ -19,7 +19,6 @@
#include <streams.h>
#include <sync.h>
#include <uint256.h>
-#include <version.h>
#include <zmq/zmqutil.h>
#include <zmq.h>