Skip to content

Commit

Permalink
build: Introduce libbitcoin_kernel as an internal compilation unit
Browse files Browse the repository at this point in the history
See doc/design/libraries.md for an overview of the internal libraries.

Some of the internal libraries and bitcoin binaries do not link with the
libbitcoin kernel (e.g. libbitcoin_wallet, bitcoin-wallet,
libbitcoin_cli, libbitcoinqt). However they still rely on some of the
files that are also required by the kernel library. Move this class of
files into the util library, which all libraries and binaries can link
with. Files moved for this reason from the common to the util library
are:

coins.cpp
core_read.cpp
kernel/chainparams.cpp
key.cpp
policy/feerate.cpp
policy/policy.cpp
scheduler.cpp
script/solver.cpp
  • Loading branch information
TheCharlatan committed Nov 29, 2023
1 parent 248afa0 commit 8d45d9e
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 35 deletions.
3 changes: 2 additions & 1 deletion build_msvc/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ libbitcoin_cli/libbitcoin_cli.vcxproj
libbitcoin_common/libbitcoin_common.vcxproj
libbitcoin_crypto/libbitcoin_crypto.vcxproj
libbitcoin_node/libbitcoin_node.vcxproj
libbitcoin_kernel/libbitcoin_kernel.vcxproj
libbitcoin_util/libbitcoin_util.vcxproj
libbitcoin_wallet_tool/libbitcoin_wallet_tool.vcxproj
libbitcoin_wallet/libbitcoin_wallet.vcxproj
Expand All @@ -27,4 +28,4 @@ libtest_util/libtest_util.vcxproj
*/Win32
libbitcoin_qt/QtGeneratedFiles/*
test_bitcoin-qt/QtGeneratedFiles/*
vcpkg_installed
vcpkg_installed
5 changes: 4 additions & 1 deletion build_msvc/bench_bitcoin/bench_bitcoin.vcxproj.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<ProjectReference Include="..\libbitcoin_node\libbitcoin_node.vcxproj">
<Project>{460fee33-1fe1-483f-b3bf-931ff8e969a5}</Project>
</ProjectReference>
<ProjectReference Include="..\libbitcoin_kernel\libbitcoin_kernel.vcxproj">
<Project>{a938586f-1016-4c60-9b82-56123264ee14}</Project>
</ProjectReference>
<ProjectReference Include="..\libbitcoin_util\libbitcoin_util.vcxproj">
<Project>{b53a5535-ee9d-4c6f-9a26-f79ee3bc3754}</Project>
</ProjectReference>
Expand Down Expand Up @@ -59,4 +62,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="..\common.vcxproj" />
</Project>
</Project>
3 changes: 3 additions & 0 deletions build_msvc/bitcoin-qt/bitcoin-qt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<ProjectReference Include="..\libbitcoin_node\libbitcoin_node.vcxproj">
<Project>{460fee33-1fe1-483f-b3bf-931ff8e969a5}</Project>
</ProjectReference>
<ProjectReference Include="..\libbitcoin_kernel\libbitcoin_kernel.vcxproj">
<Project>{a938586f-1016-4c60-9b82-56123264ee14}</Project>
</ProjectReference>
<ProjectReference Include="..\libbitcoin_util\libbitcoin_util.vcxproj">
<Project>{b53a5535-ee9d-4c6f-9a26-f79ee3bc3754}</Project>
</ProjectReference>
Expand Down
6 changes: 6 additions & 0 deletions build_msvc/bitcoin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbitcoin_crypto", "libbit
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbitcoin_node", "libbitcoin_node\libbitcoin_node.vcxproj", "{460FEE33-1FE1-483F-B3BF-931FF8E969A5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbitcoin_kernel", "libbitcoin_kernel\libbitcoin_kernel.vcxproj", "{A938586F-1016-4C60-9B82-56123264EE14}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libunivalue", "libunivalue\libunivalue.vcxproj", "{5724BA7D-A09A-4BA8-800B-C4C1561B3D69}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbitcoin_wallet", "libbitcoin_wallet\libbitcoin_wallet.vcxproj", "{93B86837-B543-48A5-A89B-7C87ABB77DF2}"
Expand Down Expand Up @@ -80,6 +82,10 @@ Global
{460FEE33-1FE1-483F-B3BF-931FF8E969A5}.Debug|x64.Build.0 = Debug|x64
{460FEE33-1FE1-483F-B3BF-931FF8E969A5}.Release|x64.ActiveCfg = Release|x64
{460FEE33-1FE1-483F-B3BF-931FF8E969A5}.Release|x64.Build.0 = Release|x64
{A938586F-1016-4C60-9B82-56123264EE14}.Debug|x64.ActiveCfg = Debug|x64
{A938586F-1016-4C60-9B82-56123264EE14}.Debug|x64.Build.0 = Debug|x64
{A938586F-1016-4C60-9B82-56123264EE14}.Release|x64.ActiveCfg = Release|x64
{A938586F-1016-4C60-9B82-56123264EE14}.Release|x64.Build.0 = Release|x64
{5724BA7D-A09A-4BA8-800B-C4C1561B3D69}.Debug|x64.ActiveCfg = Debug|x64
{5724BA7D-A09A-4BA8-800B-C4C1561B3D69}.Debug|x64.Build.0 = Debug|x64
{5724BA7D-A09A-4BA8-800B-C4C1561B3D69}.Release|x64.ActiveCfg = Release|x64
Expand Down
3 changes: 3 additions & 0 deletions build_msvc/bitcoind/bitcoind.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<ProjectReference Include="..\libbitcoin_node\libbitcoin_node.vcxproj">
<Project>{460fee33-1fe1-483f-b3bf-931ff8e969a5}</Project>
</ProjectReference>
<ProjectReference Include="..\libbitcoin_kernel\libbitcoin_kernel.vcxproj">
<Project>{a938586f-1016-4c60-9b82-56123264ee14}</Project>
</ProjectReference>
<ProjectReference Include="..\libbitcoin_util\libbitcoin_util.vcxproj">
<Project>{b53a5535-ee9d-4c6f-9a26-f79ee3bc3754}</Project>
</ProjectReference>
Expand Down
16 changes: 16 additions & 0 deletions build_msvc/libbitcoin_kernel/libbitcoin_kernel.vcxproj.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\common.init.vcxproj" />
<PropertyGroup Label="Globals">
<ProjectGuid>{A938586F-1016-4C60-9B82-56123264EE14}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<ItemGroup>
@SOURCE_FILES@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="..\common.vcxproj" />
</Project>
1 change: 1 addition & 0 deletions build_msvc/msvc-autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'libbitcoin_common',
'libbitcoin_crypto',
'libbitcoin_node',
'libbitcoin_kernel',
'libbitcoin_util',
'libbitcoin_wallet_tool',
'libbitcoin_wallet',
Expand Down
3 changes: 3 additions & 0 deletions build_msvc/test_bitcoin-qt/test_bitcoin-qt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<ProjectReference Include="..\libbitcoin_node\libbitcoin_node.vcxproj">
<Project>{460fee33-1fe1-483f-b3bf-931ff8e969a5}</Project>
</ProjectReference>
<ProjectReference Include="..\libbitcoin_kernel\libbitcoin_kernel.vcxproj">
<Project>{a938586f-1016-4c60-9b82-56123264ee14}</Project>
</ProjectReference>
<ProjectReference Include="..\libbitcoin_util\libbitcoin_util.vcxproj">
<Project>{b53a5535-ee9d-4c6f-9a26-f79ee3bc3754}</Project>
</ProjectReference>
Expand Down
3 changes: 3 additions & 0 deletions build_msvc/test_bitcoin/test_bitcoin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<ProjectReference Include="..\libbitcoin_node\libbitcoin_node.vcxproj">
<Project>{460fee33-1fe1-483f-b3bf-931ff8e969a5}</Project>
</ProjectReference>
<ProjectReference Include="..\libbitcoin_kernel\libbitcoin_kernel.vcxproj">
<Project>{a938586f-1016-4c60-9b82-56123264ee14}</Project>
</ProjectReference>
<ProjectReference Include="..\libbitcoin_util\libbitcoin_util.vcxproj">
<Project>{b53a5535-ee9d-4c6f-9a26-f79ee3bc3754}</Project>
</ProjectReference>
Expand Down
79 changes: 49 additions & 30 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ LIBBITCOIN_CONSENSUS=libbitcoin_consensus.a
LIBBITCOIN_CLI=libbitcoin_cli.a
LIBBITCOIN_UTIL=libbitcoin_util.a
LIBBITCOIN_CRYPTO_BASE=crypto/libbitcoin_crypto_base.la
LIBBITCOIN_KERNEL=libbitcoin_kernel.a
LIBBITCOINQT=qt/libbitcoinqt.a
LIBSECP256K1=secp256k1/libsecp256k1.la

Expand Down Expand Up @@ -77,6 +78,7 @@ EXTRA_LIBRARIES += \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_CONSENSUS) \
$(LIBBITCOIN_KERNEL) \
$(LIBBITCOIN_NODE) \
$(LIBBITCOIN_CLI) \
$(LIBBITCOIN_IPC) \
Expand Down Expand Up @@ -385,11 +387,6 @@ libbitcoin_node_a_SOURCES = \
bip324.cpp \
blockencodings.cpp \
blockfilter.cpp \
chain.cpp \
consensus/tx_verify.cpp \
dbwrapper.cpp \
deploymentstatus.cpp \
flatfile.cpp \
headerssync.cpp \
httprpc.cpp \
httpserver.cpp \
Expand All @@ -413,9 +410,7 @@ libbitcoin_node_a_SOURCES = \
netgroup.cpp \
node/abort.cpp \
node/blockmanager_args.cpp \
node/blockstorage.cpp \
node/caches.cpp \
node/chainstate.cpp \
node/chainstatemanager_args.cpp \
node/coin.cpp \
node/coins_view_args.cpp \
Expand All @@ -435,15 +430,9 @@ libbitcoin_node_a_SOURCES = \
node/psbt.cpp \
node/transaction.cpp \
node/txreconciliation.cpp \
node/utxo_snapshot.cpp \
node/validation_cache_args.cpp \
noui.cpp \
policy/fees.cpp \
policy/fees_args.cpp \
policy/packages.cpp \
policy/rbf.cpp \
policy/settings.cpp \
pow.cpp \
rest.cpp \
rpc/blockchain.cpp \
rpc/fees.cpp \
Expand All @@ -457,18 +446,11 @@ libbitcoin_node_a_SOURCES = \
rpc/server_util.cpp \
rpc/signmessage.cpp \
rpc/txoutproof.cpp \
script/sigcache.cpp \
shutdown.cpp \
signet.cpp \
timedata.cpp \
torcontrol.cpp \
txdb.cpp \
txmempool.cpp \
txorphanage.cpp \
txrequest.cpp \
validation.cpp \
validationinterface.cpp \
versionbits.cpp \
$(BITCOIN_CORE_H)

if ENABLE_WALLET
Expand Down Expand Up @@ -673,7 +655,6 @@ libbitcoin_common_a_SOURCES = \
bech32.cpp \
chainparams.cpp \
chainparamsbase.cpp \
coins.cpp \
common/args.cpp \
common/asmap.cpp \
common/bip32.cpp \
Expand All @@ -689,36 +670,27 @@ libbitcoin_common_a_SOURCES = \
common/sock.cpp \
common/spanparsing.cpp \
common/system.cpp \
compressor.cpp \
core_read.cpp \
core_write.cpp \
deploymentinfo.cpp \
external_signer.cpp \
init/common.cpp \
kernel/chainparams.cpp \
key.cpp \
key_io.cpp \
merkleblock.cpp \
net_types.cpp \
netaddress.cpp \
netbase.cpp \
net_permissions.cpp \
outputtype.cpp \
policy/feerate.cpp \
policy/policy.cpp \
protocol.cpp \
psbt.cpp \
rpc/external_signer.cpp \
rpc/rawtransaction_util.cpp \
rpc/request.cpp \
rpc/util.cpp \
scheduler.cpp \
script/descriptor.cpp \
script/miniscript.cpp \
script/sign.cpp \
script/signingprovider.cpp \
script/solver.cpp \
warnings.cpp \
$(BITCOIN_CORE_H)

if USE_LIBEVENT
Expand All @@ -727,14 +699,60 @@ libbitcoin_common_a_SOURCES += common/url.cpp
endif
#

# kernel #
libbitcoin_kernel_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS)
libbitcoin_kernel_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_kernel_a_SOURCES = \
chain.cpp \
compressor.cpp \
consensus/tx_verify.cpp \
dbwrapper.cpp \
deploymentinfo.cpp \
deploymentstatus.cpp \
flatfile.cpp \
kernel/chain.cpp \
kernel/checks.cpp \
kernel/coinstats.cpp \
kernel/context.cpp \
kernel/cs_main.cpp \
kernel/disconnected_transactions.cpp \
kernel/mempool_persist.cpp \
kernel/mempool_removal_reason.cpp \
node/blockstorage.cpp \
node/chainstate.cpp \
node/utxo_snapshot.cpp \
policy/fees.cpp \
policy/packages.cpp \
policy/rbf.cpp \
policy/settings.cpp \
pow.cpp \
script/sigcache.cpp \
signet.cpp \
txdb.cpp \
txmempool.cpp \
validation.cpp \
validationinterface.cpp \
versionbits.cpp \
warnings.cpp \
$(BITCOIN_CORE_H)
#

# util #
libbitcoin_util_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libbitcoin_util_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_util_a_SOURCES = \
clientversion.cpp \
coins.cpp \
core_read.cpp \
kernel/chainparams.cpp \
key.cpp \
logging.cpp \
policy/feerate.cpp \
policy/policy.cpp \
random.cpp \
randomenv.cpp \
scheduler.cpp \
script/solver.cpp \
streams.cpp \
support/lockedpool.cpp \
sync.cpp \
Expand Down Expand Up @@ -788,6 +806,7 @@ endif
bitcoin_bin_ldadd = \
$(LIBBITCOIN_WALLET) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_KERNEL) \
$(LIBBITCOIN_UTIL) \
$(LIBUNIVALUE) \
$(LIBBITCOIN_ZMQ) \
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.bench.include
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ bench_bench_bitcoin_LDADD = \
$(LIBBITCOIN_NODE) \
$(LIBBITCOIN_WALLET) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_KERNEL) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CONSENSUS) \
$(LIBBITCOIN_CRYPTO) \
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ bitcoin_qt_sources = qt/main.cpp
if TARGET_WINDOWS
bitcoin_qt_sources += $(BITCOIN_QT_RC)
endif
bitcoin_qt_ldadd = qt/libbitcoinqt.a $(LIBBITCOIN_NODE)
bitcoin_qt_ldadd = qt/libbitcoinqt.a $(LIBBITCOIN_NODE) $(LIBBITCOIN_KERNEL)
if ENABLE_WALLET
bitcoin_qt_ldadd += $(LIBBITCOIN_UTIL) $(LIBBITCOIN_WALLET)
endif
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.qttest.include
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ endif # ENABLE_WALLET

nodist_qt_test_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP)

qt_test_test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_NODE) $(LIBTEST_UTIL)
qt_test_test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_NODE) $(LIBBITCOIN_KERNEL) $(LIBTEST_UTIL)
if ENABLE_WALLET
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_UTIL) $(LIBBITCOIN_WALLET)
endif
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ FUZZ_SUITE_LD_COMMON = \
$(LIBBITCOIN_NODE) \
$(LIBBITCOIN_WALLET) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_KERNEL) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CONSENSUS) \
$(LIBBITCOIN_CRYPTO) \
Expand Down Expand Up @@ -224,7 +225,7 @@ test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET)
test_test_bitcoin_CPPFLAGS += $(BDB_CPPFLAGS)
endif

test_test_bitcoin_LDADD += $(LIBBITCOIN_NODE) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) \
test_test_bitcoin_LDADD += $(LIBBITCOIN_NODE) $(LIBBITCOIN_KERNEL) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) \
$(LIBLEVELDB) $(LIBMEMENV) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) $(MINISKETCH_LIBS)
test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)

Expand Down

0 comments on commit 8d45d9e

Please sign in to comment.