mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 00:05:13 +02:00
Merge bitcoin/bitcoin#28451: refactor: Remove unused SER_DISK, SER_NETWORK, CDataStream
fa98a097a3Rename version.h to node/protocol_version.h (MarcoFalke)fa4fbd5816Remove unused version.h include (MarcoFalke)fa0ae22ff2Remove unused SER_NETWORK, SER_DISK (MarcoFalke)fae00fe9c2Remove unused CDataStream (MarcoFalke)fa7eb4f5c3fuzz: Drop unused version from fuzz input format (MarcoFalke) Pull request description: Seems odd to have code that is completely dead. Fix this by removing all of it. ACKs for top commit: sipa: utACKfa98a097a3ajtowns: ACKfa98a097a3ryanofsky: Seems odd to not code review ACKfa98a097a3(looks good) Tree-SHA512: 9f1b9d9f92bda0512610bda6653e892756f637860362a9abfa439faab62de233cbad94b7df78ebacc160d9667aadfed4d9df08c0edefa618c040a049050fb913
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
@@ -25,12 +24,9 @@ void initialize_block()
|
||||
|
||||
FUZZ_TARGET(block, .init = initialize_block)
|
||||
{
|
||||
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||
DataStream ds{buffer};
|
||||
CBlock block;
|
||||
try {
|
||||
int nVersion;
|
||||
ds >> nVersion;
|
||||
ds.SetVersion(nVersion);
|
||||
ds >> TX_WITH_WITNESS(block);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
return;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <test/fuzz/util.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <undo.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <exception>
|
||||
#include <optional>
|
||||
@@ -91,15 +90,15 @@ void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj, const P& params
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
CDataStream Serialize(const T& obj)
|
||||
DataStream Serialize(const T& obj)
|
||||
{
|
||||
CDataStream ds{SER_NETWORK, INIT_PROTO_VERSION};
|
||||
DataStream ds{};
|
||||
ds << obj;
|
||||
return ds;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Deserialize(CDataStream ds)
|
||||
T Deserialize(DataStream ds)
|
||||
{
|
||||
T obj;
|
||||
ds >> obj;
|
||||
@@ -109,16 +108,7 @@ T Deserialize(CDataStream ds)
|
||||
template <typename T>
|
||||
void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj)
|
||||
{
|
||||
CDataStream ds{buffer, SER_NETWORK, INIT_PROTO_VERSION};
|
||||
{
|
||||
try {
|
||||
int version;
|
||||
ds >> version;
|
||||
ds.SetVersion(version);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
throw invalid_fuzzing_input_exception();
|
||||
}
|
||||
}
|
||||
DataStream ds{buffer};
|
||||
try {
|
||||
ds >> obj;
|
||||
} catch (const std::ios_base::failure&) {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <util/serfloat.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <util/overflow.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include <util/time.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
#include <version.h>
|
||||
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdlib>
|
||||
@@ -82,7 +80,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
|
||||
SetMockTime(mock_time);
|
||||
|
||||
// fuzzed_data_provider is fully consumed after this call, don't use it
|
||||
CDataStream random_bytes_data_stream{fuzzed_data_provider.ConsumeRemainingBytes<unsigned char>(), SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream random_bytes_data_stream{fuzzed_data_provider.ConsumeRemainingBytes<unsigned char>()};
|
||||
try {
|
||||
g_setup->m_node.peerman->ProcessMessage(p2p_node, random_message_type, random_bytes_data_stream,
|
||||
GetTime<std::chrono::microseconds>(), std::atomic<bool>{false});
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <script/script.h>
|
||||
#include <streams.h>
|
||||
#include <util/check.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
@@ -254,7 +254,7 @@ std::string ConsumeScalarRPCArgument(FuzzedDataProvider& fuzzed_data_provider, b
|
||||
good_data = false;
|
||||
return;
|
||||
}
|
||||
CDataStream data_stream{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream data_stream{};
|
||||
data_stream << TX_WITH_WITNESS(*opt_block);
|
||||
r = HexStr(data_stream);
|
||||
},
|
||||
@@ -288,7 +288,7 @@ std::string ConsumeScalarRPCArgument(FuzzedDataProvider& fuzzed_data_provider, b
|
||||
good_data = false;
|
||||
return;
|
||||
}
|
||||
CDataStream data_stream{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream data_stream{};
|
||||
data_stream << *opt_psbt;
|
||||
r = EncodeBase64(data_stream);
|
||||
},
|
||||
|
||||
@@ -36,14 +36,13 @@ FUZZ_TARGET(script_sign, .init = initialize_script_sign)
|
||||
const std::vector<uint8_t> key = ConsumeRandomLengthByteVector(fuzzed_data_provider, 128);
|
||||
|
||||
{
|
||||
DataStream stream{ConsumeDataStream(fuzzed_data_provider)};
|
||||
CDataStream random_data_stream{stream, SER_NETWORK, INIT_PROTO_VERSION}; // temporary copy, to be removed along with the version flag SERIALIZE_TRANSACTION_NO_WITNESS
|
||||
DataStream random_data_stream{ConsumeDataStream(fuzzed_data_provider)};
|
||||
std::map<CPubKey, KeyOriginInfo> hd_keypaths;
|
||||
try {
|
||||
DeserializeHDKeypaths(random_data_stream, key, hd_keypaths);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
}
|
||||
CDataStream serialized{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream serialized{};
|
||||
SerializeHDKeypaths(serialized, hd_keypaths, CompactSizeWriter(fuzzed_data_provider.ConsumeIntegral<uint8_t>()));
|
||||
}
|
||||
|
||||
@@ -60,7 +59,7 @@ FUZZ_TARGET(script_sign, .init = initialize_script_sign)
|
||||
}
|
||||
hd_keypaths[*pub_key] = *key_origin_info;
|
||||
}
|
||||
CDataStream serialized{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream serialized{};
|
||||
try {
|
||||
SerializeHDKeypaths(serialized, hd_keypaths, CompactSizeWriter(fuzzed_data_provider.ConsumeIntegral<uint8_t>()));
|
||||
} catch (const std::ios_base::failure&) {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <util/chaintype.h>
|
||||
#include <util/rbf.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
@@ -29,14 +28,7 @@ void initialize_transaction()
|
||||
|
||||
FUZZ_TARGET(transaction, .init = initialize_transaction)
|
||||
{
|
||||
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||
try {
|
||||
int nVersion;
|
||||
ds >> nVersion;
|
||||
ds.SetVersion(nVersion);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
return;
|
||||
}
|
||||
DataStream ds{buffer};
|
||||
bool valid_tx = true;
|
||||
const CTransaction tx = [&] {
|
||||
try {
|
||||
@@ -47,12 +39,9 @@ FUZZ_TARGET(transaction, .init = initialize_transaction)
|
||||
}
|
||||
}();
|
||||
bool valid_mutable_tx = true;
|
||||
CDataStream ds_mtx(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||
DataStream ds_mtx{buffer};
|
||||
CMutableTransaction mutable_tx;
|
||||
try {
|
||||
int nVersion;
|
||||
ds_mtx >> nVersion;
|
||||
ds_mtx.SetVersion(nVersion);
|
||||
ds_mtx >> TX_WITH_WITNESS(mutable_tx);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
valid_mutable_tx = false;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <primitives/transaction.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <primitives/transaction.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <version.h>
|
||||
|
||||
FUZZ_TARGET(tx_out)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <util/overflow.h>
|
||||
#include <util/rbf.h>
|
||||
#include <util/time.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <uint256.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -118,7 +117,7 @@ template <typename T>
|
||||
[[nodiscard]] inline std::optional<T> ConsumeDeserializable(FuzzedDataProvider& fuzzed_data_provider, const std::optional<size_t>& max_length = std::nullopt) noexcept
|
||||
{
|
||||
const std::vector<uint8_t> buffer = ConsumeRandomLengthByteVector(fuzzed_data_provider, max_length);
|
||||
CDataStream ds{buffer, SER_NETWORK, INIT_PROTO_VERSION};
|
||||
DataStream ds{buffer};
|
||||
T obj;
|
||||
try {
|
||||
ds >> obj;
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
|
||||
#include <compat/compat.h>
|
||||
#include <netaddress.h>
|
||||
#include <node/protocol_version.h>
|
||||
#include <protocol.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <test/util/net.h>
|
||||
#include <util/sock.h>
|
||||
#include <util/time.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
||||
FUZZ_TARGET(utxo_total_supply)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user