Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contrib/devtools/check-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ declare -A SUPPRESS
# https://github.com/bitcoin/bitcoin/issues/10102
SUPPRESS["common.cpp.o interface_ui.cpp.o _Z11InitWarningRK13bilingual_str"]=1
SUPPRESS["common.cpp.o interface_ui.cpp.o _Z9InitErrorRK13bilingual_str"]=1
# CBlockHeader::GetHash() applies the CPUNET hash domain separator based on
# the selected application chain.
SUPPRESS["block.cpp.o args.cpp.o _ZNK11ArgsManager18GetChainTypeStringB5cxx11Ev"]=1
SUPPRESS["block.cpp.o chaintype.cpp.o _Z17ChainTypeToStringB5cxx119ChainType"]=1

usage() {
echo "Usage: $(basename "${BASH_SOURCE[0]}") [BUILD_DIR]"
Expand Down
14 changes: 7 additions & 7 deletions src/bitcoin-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ static int Grind(const std::vector<std::string>& args, std::string& strPrint)
uint16_t n_tasks = std::max(1u, std::thread::hardware_concurrency());
if(gArgs.IsArgSet("-ntasks")) {
const auto ntasks_str = *gArgs.GetArg("-ntasks");
try {
n_tasks = std::stoi(ntasks_str);
if (n_tasks <= 0 || n_tasks > std::thread::hardware_concurrency()) {
strPrint = strprintf("Argument to -ntasks must be a positive number less than or equal to the number of cores %u, found %s\n", std::thread::hardware_concurrency(), ntasks_str);
return EXIT_FAILURE;
}
} catch (const std::exception&) {
const auto parsed_n_tasks = ToIntegral<uint16_t>(ntasks_str);
if (!parsed_n_tasks) {
strPrint = strprintf("Argument to -ntasks should be a number, found %s\n", ntasks_str);
return EXIT_FAILURE;
}
n_tasks = *parsed_n_tasks;
if (n_tasks <= 0 || n_tasks > std::thread::hardware_concurrency()) {
strPrint = strprintf("Argument to -ntasks must be a positive number less than or equal to the number of cores %u, found %s\n", std::thread::hardware_concurrency(), ntasks_str);
return EXIT_FAILURE;
}
}
threads.reserve(n_tasks);
for (int i = 0; i < n_tasks; ++i) {
Expand Down
8 changes: 4 additions & 4 deletions src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

void SetupChainParamsBaseOptions(ArgsManager& argsman)
{
argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest, cpunet", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-chain=<chain>", "Use the chain <chain>. This build supports only regtest and cpunet.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
"This is intended for regression testing tools and app development. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (segwit, bip34, dersig, cltv, csv). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-testnet", "Use the testnet3 chain. Equivalent to -chain=test. Support for testnet3 is deprecated and will be removed in an upcoming release. Consider moving to testnet4 now by using -testnet4.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-testnet4", "Use the testnet4 chain. Equivalent to -chain=testnet4.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-testnet", "Unsupported in this build.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-testnet4", "Unsupported in this build.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-cpunet", "Use the CPU-mined test chain. Equivalent to -chain=cpunet.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height]", "Use given start/end times and min_activation_height for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signet", "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signet", "Unsupported in this build.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signetchallenge", "Blocks must satisfy the given script to be considered valid (only for signet networks; defaults to the global default signet test network challenge)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signetseednode", "Specify a seed node for the signet network, in the hostname[:port] format, e.g. sig.net:1234 (may be used multiple times to specify multiple seed nodes; defaults to the global default signet test network seed node(s))", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
}
Expand Down
2 changes: 1 addition & 1 deletion src/chainparamsbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CBaseChainParams
uint16_t OnionServiceTargetPort() const { return m_onion_service_target_port; }
CBaseChainParams() = delete;
CBaseChainParams(const std::string& data_dir, uint16_t rpc_port, uint16_t onion_service_target_port)
: m_rpc_port(rpc_port), strDataDir(data_dir), m_onion_service_target_port(onion_service_target_port) {}
: m_rpc_port(rpc_port), m_onion_service_target_port(onion_service_target_port), strDataDir(data_dir) {}

private:
const uint16_t m_rpc_port;
Expand Down
1 change: 1 addition & 0 deletions src/kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ target_link_libraries(bitcoinkernel
$<TARGET_NAME_IF_EXISTS:USDT::headers>
Boost::headers
)
target_compile_definitions(bitcoinkernel PRIVATE BITCOIN_KERNEL)

target_include_directories(bitcoinkernel PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/leveldb/include>)

Expand Down
12 changes: 6 additions & 6 deletions src/kernel/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <primitives/transaction.h>
#include <script/interpreter.h>
#include <script/script.h>
#include <streams.h>
#include <uint256.h>
#include <util/chaintype.h>
#include <util/log.h>
Expand All @@ -27,6 +26,7 @@
#include <cassert>
#include <cstdint>
#include <cstring>
#include <initializer_list>
#include <iterator>
#include <map>
#include <span>
Expand Down Expand Up @@ -478,17 +478,15 @@ class CCPUNetParams : public CChainParams {
m_assumed_chain_state_size = 0;

const char* cpunet_genesis_msg = "03/May/2024 000000000000000000001ebd58c244970b3aa9d783bb001011fbe8ea8e98e00e";
const CScript cpunet_genesis_script = CScript() << ParseHex("000000000000000000000000000000000000000000000000000000000000000000") << OP_CHECKSIG;
const CScript cpunet_genesis_script = CScript() << "000000000000000000000000000000000000000000000000000000000000000000"_hex << OP_CHECKSIG;
genesis = CreateGenesisBlock(cpunet_genesis_msg,
cpunet_genesis_script,
1723652721,
961348305,
0x1d00ffff,
1,
50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
//std::cerr << "CPUNet Genesis Block header: "
// << HexStr(DataStream{} << genesis.GetBlockHeader() << "cpunet") << std::endl;
consensus.hashGenesisBlock = (HashWriter{} << static_cast<const CBlockHeader&>(genesis) << "cpunet").GetHash();
assert(consensus.hashGenesisBlock == uint256("0x00000000bbffa57733938dbc05f86239f303636de4599905ab84bccfa909f49b"));
assert(genesis.hashMerkleRoot == uint256("0x7aa0a7ae1e223414cb807e40cd57e667b718e42aaf9306db9102fe28912b7b4e"));

Expand Down Expand Up @@ -617,7 +615,7 @@ class SigNetParams : public CChainParams {

genesis = CreateGenesisBlock(1598918400, 52613770, 0x1e0377ae, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
//assert(consensus.hashGenesisBlock == uint256{"00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6"});
assert(consensus.hashGenesisBlock == uint256{"00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6"});
assert(genesis.hashMerkleRoot == uint256{"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"});

m_assumeutxo_data = {
Expand Down Expand Up @@ -844,6 +842,8 @@ std::optional<ChainType> GetNetworkForMagic(const MessageStartChars& message)
return ChainType::MAIN;
} else if (std::ranges::equal(message, testnet_msg)) {
return ChainType::TESTNET;
} else if (std::ranges::equal(message, testnet4_msg)) {
return ChainType::TESTNET4;
} else if (std::equal(message.begin(), message.end(), cpunet_msg.data())) {
return ChainType::CPUNET;
} else if (std::equal(message.begin(), message.end(), regtest_msg.data())) {
Expand Down
9 changes: 8 additions & 1 deletion src/primitives/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@

#include <primitives/block.h>

#include <common/args.h>
#include <hash.h>
#include <tinyformat.h>
#include <util/chaintype.h>

#include <memory>
#include <span>
#include <sstream>

uint256 CBlockHeader::GetHash() const
{
return (HashWriter{} << *this << "cpunet").GetHash();
#ifndef BITCOIN_KERNEL
if (gArgs.GetChainTypeString() == ChainTypeToString(ChainType::CPUNET)) {
return (HashWriter{} << *this << "cpunet").GetHash();
}
#endif
return (HashWriter{} << *this).GetHash();
}

std::string CBlock::ToString() const
Expand Down
3 changes: 3 additions & 0 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ static std::string DummyAddress(const CChainParams &params)
case ChainType::TESTNET4:
addr = "tb1p35yvjel7srp783ztf8v6jdra7dhfzk5jaun8xz2qp6ws7z80n4tqa6qnlg";
break;
case ChainType::CPUNET:
addr = "tc1p35yvjel7srp783ztf8v6jdra7dhfzk5jaun8xz2qp6ws7z80n4tqsr2427";
break;
case ChainType::REGTEST:
addr = "bcrt1p35yvjel7srp783ztf8v6jdra7dhfzk5jaun8xz2qp6ws7z80n4tqsr2427";
break;
Expand Down
2 changes: 1 addition & 1 deletion src/test/argsman_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ BOOST_FIXTURE_TEST_CASE(util_ChainMerge, ChainMergeTestingSetup)
// Results file is formatted like:
//
// <input> || <output>
BOOST_CHECK_EQUAL(out_sha_hex, "c0e33aab0c74e040ddcee9edad59e8148d8e1cacb3cccd9ea1a1f485cb6bad21");
BOOST_CHECK_EQUAL(out_sha_hex, "10e719bafb214ffd48840299719ccc651beb38609e707387e893ba38982be3d5");
}

BOOST_AUTO_TEST_CASE(util_ReadWriteSettings)
Expand Down
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
'p2p_addrfetch.py',
'rpc_net.py --v1transport',
'rpc_net.py --v2transport',
'rpc_mempool_info.py',
'wallet_keypool.py',
'wallet_descriptor.py',
'p2p_nobloomfilter_messages.py',
Expand Down
Loading