Skip to content

Commit 619f8a2

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#24304: [kernel 0/n] Introduce bitcoin-chainstate
2c03cec ci: Build bitcoin-chainstate (Carl Dong) 095aa6c build: Add example bitcoin-chainstate executable (Carl Dong) Pull request description: Part of: #24303 This PR introduces an example/demo `bitcoin-chainstate` executable using said library which can print out information about a datadir and take in new blocks on stdin. Please read the commit messages for more details. ----- #### You may ask: WTF?! Why is `index/*.cpp`, etc. being linked in? This PR is meant only to capture the state of dependencies in our consensus engine as of right now. There are many things to decouple from consensus, which will be done in subsequent PRs. Listing the files out right now in `bitcoin_chainstate_SOURCES` is purely to give us a clear picture of the task at hand, it is **not** to say that these dependencies _belongs_ there in any way. ### TODO 1. Clean up `bitcoin-chainstate.cpp` It is quite ugly, with a lot of comments I've left for myself, I should clean it up to the best of my abilities (the ugliness of our init/shutdown might be the upper bound on cleanliness here...) ACKs for top commit: ajtowns: ACK 2c03cec ryanofsky: Code review ACK 2c03cec. Just rebase, comments, formatting change since last review MarcoFalke: re-ACK 2c03cec 🏔 Tree-SHA512: 86e7fb5718caa577df8abc8288c754f4a590650d974df9d2f6476c87ed25c70f923c4db651c6963f33498fc7a3a31f6692b9a75cbc996bf4888c5dac2f34a13b
2 parents 727b0cb + 2c03cec commit 619f8a2

File tree

6 files changed

+380
-4
lines changed

6 files changed

+380
-4
lines changed

.cirrus.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ task:
258258
FILE_ENV: "./ci/test/00_setup_env_i686_multiprocess.sh"
259259

260260
task:
261-
name: '[no wallet] [bionic]'
261+
name: '[no wallet, libbitcoinkernel] [bionic]'
262262
<< : *GLOBAL_TASK_TEMPLATE
263263
container:
264264
image: ubuntu:bionic
265265
env:
266266
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
267-
FILE_ENV: "./ci/test/00_setup_env_native_nowallet.sh"
267+
FILE_ENV: "./ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh"
268268

269269
task:
270270
name: 'macOS 10.15 [gui, no tests] [focal]'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ src/bitcoin-gui
99
src/bitcoin-node
1010
src/bitcoin-tx
1111
src/bitcoin-util
12+
src/bitcoin-chainstate
1213
src/bitcoin-wallet
1314
src/test/fuzz/fuzz
1415
src/test/test_bitcoin

ci/test/00_setup_env_native_nowallet.sh renamed to ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
export LC_ALL=C.UTF-8
88

9-
export CONTAINER_NAME=ci_native_nowallet
9+
export CONTAINER_NAME=ci_native_nowallet_libbitcoinkernel
1010
export DOCKER_NAME_TAG=ubuntu:18.04 # Use bionic to have one config run the tests in python3.6, see doc/dependencies.md
1111
export PACKAGES="python3-zmq clang-7 llvm-7 libc++abi-7-dev libc++-7-dev" # Use clang-7 to test C++17 compatibility, see doc/dependencies.md
1212
export DEP_OPTS="NO_WALLET=1 CC=clang-7 CXX='clang++-7 -stdlib=libc++'"
1313
export GOAL="install"
14-
export BITCOIN_CONFIG="--enable-reduce-exports CC=clang-7 CXX='clang++-7 -stdlib=libc++'"
14+
export BITCOIN_CONFIG="--enable-reduce-exports CC=clang-7 CXX='clang++-7 -stdlib=libc++' --enable-experimental-util-chainstate"

configure.ac

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ BITCOIN_GUI_NAME=bitcoin-qt
2424
BITCOIN_CLI_NAME=bitcoin-cli
2525
BITCOIN_TX_NAME=bitcoin-tx
2626
BITCOIN_UTIL_NAME=bitcoin-util
27+
BITCOIN_CHAINSTATE_NAME=bitcoin-chainstate
2728
BITCOIN_WALLET_TOOL_NAME=bitcoin-wallet
2829
dnl Multi Process
2930
BITCOIN_MP_NODE_NAME=bitcoin-node
@@ -645,6 +646,12 @@ AC_ARG_ENABLE([util-util],
645646
[build_bitcoin_util=$enableval],
646647
[build_bitcoin_util=$build_bitcoin_utils])
647648

649+
AC_ARG_ENABLE([experimental-util-chainstate],
650+
[AS_HELP_STRING([--enable-experimental-util-chainstate],
651+
[build experimental bitcoin-chainstate executable (default=no)])],
652+
[build_bitcoin_chainstate=$enableval],
653+
[build_bitcoin_chainstate=no])
654+
648655
AC_ARG_WITH([libs],
649656
[AS_HELP_STRING([--with-libs],
650657
[build libraries (default=yes)])],
@@ -1268,6 +1275,7 @@ if test "$enable_fuzz" = "yes"; then
12681275
build_bitcoin_cli=no
12691276
build_bitcoin_tx=no
12701277
build_bitcoin_util=no
1278+
build_bitcoin_chainstate=no
12711279
build_bitcoin_wallet=no
12721280
build_bitcoind=no
12731281
build_bitcoin_libs=no
@@ -1624,6 +1632,10 @@ AC_MSG_CHECKING([whether to build bitcoin-util])
16241632
AM_CONDITIONAL([BUILD_BITCOIN_UTIL], [test $build_bitcoin_util = "yes"])
16251633
AC_MSG_RESULT($build_bitcoin_util)
16261634

1635+
AC_MSG_CHECKING([whether to build experimental bitcoin-chainstate])
1636+
AM_CONDITIONAL([BUILD_BITCOIN_CHAINSTATE], [test $build_bitcoin_chainstate = "yes"])
1637+
AC_MSG_RESULT($build_bitcoin_chainstate)
1638+
16271639
AC_MSG_CHECKING([whether to build libraries])
16281640
AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test $build_bitcoin_libs = "yes"])
16291641
if test "$build_bitcoin_libs" = "yes"; then
@@ -1843,6 +1855,7 @@ AC_SUBST(BITCOIN_GUI_NAME)
18431855
AC_SUBST(BITCOIN_CLI_NAME)
18441856
AC_SUBST(BITCOIN_TX_NAME)
18451857
AC_SUBST(BITCOIN_UTIL_NAME)
1858+
AC_SUBST(BITCOIN_CHAINSTATE_NAME)
18461859
AC_SUBST(BITCOIN_WALLET_TOOL_NAME)
18471860
AC_SUBST(BITCOIN_MP_NODE_NAME)
18481861
AC_SUBST(BITCOIN_MP_GUI_NAME)

src/Makefile.am

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ if BUILD_BITCOIN_UTIL
106106
bin_PROGRAMS += bitcoin-util
107107
endif
108108

109+
if BUILD_BITCOIN_CHAINSTATE
110+
bin_PROGRAMS += bitcoin-chainstate
111+
endif
112+
109113
.PHONY: FORCE check-symbols check-security
110114
# bitcoin core #
111115
BITCOIN_CORE_H = \
@@ -769,6 +773,102 @@ bitcoin_util_LDADD = \
769773
$(LIBSECP256K1)
770774
#
771775

776+
# bitcoin-chainstate binary #
777+
bitcoin_chainstate_SOURCES = \
778+
bitcoin-chainstate.cpp \
779+
arith_uint256.cpp \
780+
blockfilter.cpp \
781+
chain.cpp \
782+
chainparamsbase.cpp \
783+
chainparams.cpp \
784+
clientversion.cpp \
785+
coins.cpp \
786+
compat/glibcxx_sanity.cpp \
787+
compressor.cpp \
788+
consensus/merkle.cpp \
789+
consensus/tx_check.cpp \
790+
consensus/tx_verify.cpp \
791+
core_read.cpp \
792+
dbwrapper.cpp \
793+
deploymentinfo.cpp \
794+
deploymentstatus.cpp \
795+
flatfile.cpp \
796+
fs.cpp \
797+
hash.cpp \
798+
index/base.cpp \
799+
index/blockfilterindex.cpp \
800+
index/coinstatsindex.cpp \
801+
init/common.cpp \
802+
key.cpp \
803+
logging.cpp \
804+
netaddress.cpp \
805+
node/blockstorage.cpp \
806+
node/chainstate.cpp \
807+
node/coinstats.cpp \
808+
node/ui_interface.cpp \
809+
policy/feerate.cpp \
810+
policy/fees.cpp \
811+
policy/packages.cpp \
812+
policy/policy.cpp \
813+
policy/rbf.cpp \
814+
policy/settings.cpp \
815+
pow.cpp \
816+
primitives/block.cpp \
817+
primitives/transaction.cpp \
818+
pubkey.cpp \
819+
random.cpp \
820+
randomenv.cpp \
821+
scheduler.cpp \
822+
script/interpreter.cpp \
823+
script/script.cpp \
824+
script/script_error.cpp \
825+
script/sigcache.cpp \
826+
script/standard.cpp \
827+
shutdown.cpp \
828+
signet.cpp \
829+
support/cleanse.cpp \
830+
support/lockedpool.cpp \
831+
sync.cpp \
832+
threadinterrupt.cpp \
833+
timedata.cpp \
834+
txdb.cpp \
835+
txmempool.cpp \
836+
uint256.cpp \
837+
util/asmap.cpp \
838+
util/bytevectorhash.cpp \
839+
util/getuniquepath.cpp \
840+
util/hasher.cpp \
841+
util/moneystr.cpp \
842+
util/rbf.cpp \
843+
util/serfloat.cpp \
844+
util/settings.cpp \
845+
util/strencodings.cpp \
846+
util/syscall_sandbox.cpp \
847+
util/system.cpp \
848+
util/thread.cpp \
849+
util/threadnames.cpp \
850+
util/time.cpp \
851+
util/tokenpipe.cpp \
852+
validation.cpp \
853+
validationinterface.cpp \
854+
versionbits.cpp \
855+
warnings.cpp
856+
bitcoin_chainstate_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
857+
bitcoin_chainstate_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
858+
bitcoin_chainstate_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS)
859+
bitcoin_chainstate_LDADD = \
860+
$(LIBBITCOIN_CRYPTO) \
861+
$(LIBUNIVALUE) \
862+
$(LIBSECP256K1) \
863+
$(LIBLEVELDB) \
864+
$(LIBLEVELDB_SSE42) \
865+
$(LIBMEMENV)
866+
867+
# Required for obj/build.h to be generated first.
868+
# More details: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html
869+
bitcoin_chainstate-clientversion.$(OBJEXT): obj/build.h
870+
#
871+
772872
# bitcoinconsensus library #
773873
if BUILD_BITCOIN_LIBS
774874
include_HEADERS = script/bitcoinconsensus.h

0 commit comments

Comments
 (0)