Merge 6852d1d487 into merged_master (Bitcoin PR bitcoin/bitcoin#30796)

This commit is contained in:
ivanlele 2026-03-25 09:34:43 +00:00
commit 0501efa402
No known key found for this signature in database
15 changed files with 37 additions and 65 deletions

View file

@ -3,12 +3,11 @@
# file COPYING or https://opensource.org/license/mit/.
include(GenerateHeaders)
generate_header_from_raw(data/block413567.raw)
generate_header_from_raw(data/block413567.raw benchmark::data)
add_executable(bench_bitcoin
bench_bitcoin.cpp
bench.cpp
data.cpp
nanobench.cpp
${CMAKE_CURRENT_BINARY_DIR}/data/block413567.raw.h
# Benchmarks:

View file

@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data.h>
#include <bench/data/block413567.raw.h>
#include <chainparams.h>
#include <common/args.h>
#include <consensus/validation.h>

View file

@ -1,16 +0,0 @@
// Copyright (c) 2019-2021 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/data.h>
#include <iterator>
namespace benchmark {
namespace data {
#include <bench/data/block413567.raw.h>
const std::vector<uint8_t> block413567{std::begin(block413567_raw), std::end(block413567_raw)};
} // namespace data
} // namespace benchmark

View file

@ -1,19 +0,0 @@
// Copyright (c) 2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_BENCH_DATA_H
#define BITCOIN_BENCH_DATA_H
#include <cstdint>
#include <vector>
namespace benchmark {
namespace data {
extern const std::vector<uint8_t> block413567;
} // namespace data
} // namespace benchmark
#endif // BITCOIN_BENCH_DATA_H

View file

@ -3,7 +3,7 @@
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data.h>
#include <bench/data/block413567.raw.h>
#include <chainparams.h>
#include <flatfile.h>
#include <node/blockstorage.h>

View file

@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data.h>
#include <bench/data/block413567.raw.h>
#include <flatfile.h>
#include <node/blockstorage.h>
#include <primitives/block.h>

View file

@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data.h>
#include <bench/data/block413567.raw.h>
#include <chain.h>
#include <core_io.h>
#include <primitives/block.h>

View file

@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data.h>
#include <bench/data/block413567.raw.h>
#include <span.h>
#include <util/strencodings.h>

View file

@ -12,7 +12,7 @@ generate_header_from_json(data/script_tests.json)
generate_header_from_json(data/sighash.json)
generate_header_from_json(data/tx_invalid.json)
generate_header_from_json(data/tx_valid.json)
generate_header_from_raw(data/asmap.raw)
generate_header_from_raw(data/asmap.raw test::data)
# Do not use generator expressions in test sources because the
# SOURCES property is processed to gather test suite macros.

View file

@ -47,11 +47,12 @@ static CService ResolveService(const std::string& ip, uint16_t port = 0)
}
static std::vector<bool> FromBytes(const unsigned char* source, int vector_size)
static std::vector<bool> FromBytes(std::span<const std::byte> source)
{
int vector_size(source.size() * 8);
std::vector<bool> result(vector_size);
for (int byte_i = 0; byte_i < vector_size / 8; ++byte_i) {
unsigned char cur_byte = source[byte_i];
uint8_t cur_byte{std::to_integer<uint8_t>(source[byte_i])};
for (int bit_i = 0; bit_i < 8; ++bit_i) {
result[byte_i * 8 + bit_i] = (cur_byte >> bit_i) & 1;
}
@ -576,7 +577,7 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket_legacy)
// 101.8.0.0/16 AS8
BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket)
{
std::vector<bool> asmap = FromBytes(asmap_raw, sizeof(asmap_raw) * 8);
std::vector<bool> asmap = FromBytes(test::data::asmap);
NetGroupManager ngm_asmap{asmap};
CAddress addr1 = CAddress(ResolveService("250.1.1.1", 8333), NODE_NONE);
@ -630,7 +631,7 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket)
BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket)
{
std::vector<bool> asmap = FromBytes(asmap_raw, sizeof(asmap_raw) * 8);
std::vector<bool> asmap = FromBytes(test::data::asmap);
NetGroupManager ngm_asmap{asmap};
CAddress addr1 = CAddress(ResolveService("250.1.2.1", 8333), NODE_NONE);
@ -708,7 +709,7 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket)
BOOST_AUTO_TEST_CASE(addrman_serialization)
{
std::vector<bool> asmap1 = FromBytes(asmap_raw, sizeof(asmap_raw) * 8);
std::vector<bool> asmap1 = FromBytes(test::data::asmap);
NetGroupManager netgroupman{asmap1};
const auto ratio = GetCheckRatio(m_node);

View file

@ -1,15 +1,15 @@
// Copyright (c) 2023 The Bitcoin Core developers
// Copyright (c) 2023-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <test/util/json.h>
#include <string>
#include <univalue.h>
#include <util/check.h>
#include <univalue.h>
#include <string_view>
UniValue read_json(const std::string& jsondata)
UniValue read_json(std::string_view jsondata)
{
UniValue v;
Assert(v.read(jsondata) && v.isArray());

View file

@ -1,14 +1,14 @@
// Copyright (c) 2023 The Bitcoin Core developers
// Copyright (c) 2023-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_TEST_UTIL_JSON_H
#define BITCOIN_TEST_UTIL_JSON_H
#include <string>
#include <univalue.h>
UniValue read_json(const std::string& jsondata);
#include <string_view>
UniValue read_json(std::string_view jsondata);
#endif // BITCOIN_TEST_UTIL_JSON_H