Skip to content

Commit 6b9abe4

Browse files
MarcoFalkeknst
authored andcommitted
Merge bitcoin#24304: [kernel 0/n] Introduce bitcoin-chainstate
BACKPORT NOTES: - UpdateUncommittedBlockStructures is segwit related; omitted from bitcoin-chainstate.cpp - call chainman.UnloadBlockIndex is removed by bitcoin#22564 - binary name is renamed from bitcoin-chainstate to dash-chainstate. Names of source files and some variables are untouched - added LIBDASHBLS to list of libraries to link - couple functions are reimplemented to avoid balooning dash-chainstate by including extra heavy depenencies - ValueFromAmount (reimplemented, core_write.cpp) - GetPrettyExceptionStr (reimplemented, stacktrackes.cpp) - g_stats_client (redefined) There are several modules that should be removed in the near future from dash-chainstate binary - protocol.cpp move NetMsgType inline helpers out of chainlock/clsig.h, governance/object.h, evo/simplifiedmns.h into their .cpp files - llmq/dkgsession.cpp, llmq/dkgsessionhandler.cpp, llmq/dkgsessionmgr.cpp, llmq/debug.cpp, batchedlogger.cpp CQuorumManager already null-guards m_qdkgsman; drop once ConnectManagers() is never called on the kernel side - llmq/signing.cpp split CSigningManager out of LLMQContext into a post-construction Connect() so the context becomes quorum-only - governance/*.cpp promote the 4 methods used by CMNPaymentsProcessor (IsValid, IsSuperblockTriggered, IsValidSuperblock, GetSuperblockPayments) to a base interface; instantiate a NullGovernanceManager in bitcoin-chainstate.cpp ORIGINAL PR Description: 2c03cec ci: Build bitcoin-chainstate (Carl Dong) 095aa6c build: Add example bitcoin-chainstate executable (Carl Dong) Pull request description: Part of: bitcoin#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
1 parent bc62f1a commit 6b9abe4

6 files changed

Lines changed: 507 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ src/dash-gui
1313
src/dash-node
1414
src/dash-tx
1515
src/dash-util
16+
src/dash-chainstate
1617
src/dash-wallet
1718
src/test/fuzz/fuzz
1819
src/test/test_dash

ci/dash/matrix.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ elif [ "$BUILD_TARGET" = "linux64_fuzz" ]; then
2727
elif [ "$BUILD_TARGET" = "linux64_multiprocess" ]; then
2828
source ./ci/test/00_setup_env_native_multiprocess.sh
2929
elif [ "$BUILD_TARGET" = "linux64_nowallet" ]; then
30-
source ./ci/test/00_setup_env_native_nowallet.sh
30+
source ./ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh
3131
elif [ "$BUILD_TARGET" = "linux64_sqlite" ]; then
3232
source ./ci/test/00_setup_env_native_sqlite.sh
3333
elif [ "$BUILD_TARGET" = "linux64_tsan" ]; then

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 HOST=x86_64-pc-linux-gnu
1111
export PACKAGES="python3-zmq"
1212
export DEP_OPTS="NO_WALLET=1 CC=gcc-14 CXX=g++-14"
1313
export GOAL="install"
14-
export BITCOIN_CONFIG="--enable-reduce-exports CC=gcc-14 CXX=g++-14"
14+
export BITCOIN_CONFIG="--enable-reduce-exports CC=gcc-14 CXX=g++-14 --enable-experimental-util-chainstate"

configure.ac

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ BITCOIN_TEST_NAME=test_dash
3535
BITCOIN_CLI_NAME=dash-cli
3636
BITCOIN_TX_NAME=dash-tx
3737
BITCOIN_UTIL_NAME=dash-util
38+
BITCOIN_CHAINSTATE_NAME=dash-chainstate
3839
BITCOIN_WALLET_TOOL_NAME=dash-wallet
3940
dnl Multi Process
4041
BITCOIN_MP_NODE_NAME=dash-node
@@ -769,6 +770,13 @@ AC_ARG_ENABLE([util-util],
769770
[build_bitcoin_util=$enableval],
770771
[build_bitcoin_util=$build_bitcoin_utils])
771772

773+
AC_ARG_ENABLE([experimental-util-chainstate],
774+
[AS_HELP_STRING([--enable-experimental-util-chainstate],
775+
[build experimental dash-chainstate executable (default=no)])],
776+
[build_bitcoin_chainstate=$enableval],
777+
[build_bitcoin_chainstate=no])
778+
779+
772780
AC_ARG_WITH([libs],
773781
[AS_HELP_STRING([--with-libs],
774782
[build libraries (default=yes)])],
@@ -1443,6 +1451,7 @@ if test "$enable_fuzz" = "yes"; then
14431451
build_bitcoin_cli=no
14441452
build_bitcoin_tx=no
14451453
build_bitcoin_util=no
1454+
build_bitcoin_chainstate=no
14461455
build_bitcoin_wallet=no
14471456
build_bitcoind=no
14481457
build_bitcoin_libs=no
@@ -1781,6 +1790,10 @@ AC_MSG_CHECKING([whether to build dash-util])
17811790
AM_CONDITIONAL([BUILD_BITCOIN_UTIL], [test $build_bitcoin_util = "yes"])
17821791
AC_MSG_RESULT($build_bitcoin_util)
17831792

1793+
AC_MSG_CHECKING([whether to build experimental dash-chainstate])
1794+
AM_CONDITIONAL([BUILD_BITCOIN_CHAINSTATE], [test $build_bitcoin_chainstate = "yes"])
1795+
AC_MSG_RESULT($build_bitcoin_chainstate)
1796+
17841797
AC_MSG_CHECKING([whether to build libraries])
17851798
AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test $build_bitcoin_libs = "yes"])
17861799
if test "$build_bitcoin_libs" = "yes"; then
@@ -1995,6 +2008,7 @@ AC_SUBST(BITCOIN_TEST_NAME)
19952008
AC_SUBST(BITCOIN_CLI_NAME)
19962009
AC_SUBST(BITCOIN_TX_NAME)
19972010
AC_SUBST(BITCOIN_UTIL_NAME)
2011+
AC_SUBST(BITCOIN_CHAINSTATE_NAME)
19982012
AC_SUBST(BITCOIN_WALLET_TOOL_NAME)
19992013
AC_SUBST(BITCOIN_MP_NODE_NAME)
20002014
AC_SUBST(BITCOIN_MP_GUI_NAME)

src/Makefile.am

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ if BUILD_BITCOIN_UTIL
148148
bin_PROGRAMS += dash-util
149149
endif
150150

151+
if BUILD_BITCOIN_CHAINSTATE
152+
bin_PROGRAMS += dash-chainstate
153+
endif
154+
151155
.PHONY: FORCE check-symbols check-security
152156
# dash core #
153157
BITCOIN_CORE_H = \
@@ -1156,6 +1160,164 @@ dash_util_LDADD = \
11561160
$(BACKTRACE_LIBS)
11571161

11581162
dash_util_LDADD += $(BOOST_LIBS)
1163+
1164+
# dash-chainstate binary #
1165+
dash_chainstate_SOURCES = \
1166+
bitcoin-chainstate.cpp \
1167+
addressindex.cpp \
1168+
arith_uint256.cpp \
1169+
base58.cpp \
1170+
batchedlogger.cpp \
1171+
bech32.cpp \
1172+
blockfilter.cpp \
1173+
bls/bls.cpp \
1174+
bls/bls_worker.cpp \
1175+
chain.cpp \
1176+
chainparamsbase.cpp \
1177+
chainparams.cpp \
1178+
clientversion.cpp \
1179+
coins.cpp \
1180+
compressor.cpp \
1181+
chainlock/clsig.cpp \
1182+
chainlock/chainlock.cpp \
1183+
consensus/merkle.cpp \
1184+
consensus/tx_check.cpp \
1185+
consensus/tx_verify.cpp \
1186+
common/bloom.cpp \
1187+
core_read.cpp \
1188+
dbwrapper.cpp \
1189+
deploymentinfo.cpp \
1190+
deploymentstatus.cpp \
1191+
evo/assetlocktx.cpp \
1192+
evo/cbtx.cpp \
1193+
evo/creditpool.cpp \
1194+
evo/chainhelper.cpp \
1195+
evo/deterministicmns.cpp \
1196+
evo/dmnstate.cpp \
1197+
evo/evodb.cpp \
1198+
evo/netinfo.cpp \
1199+
evo/mnhftx.cpp \
1200+
evo/providertx.cpp \
1201+
evo/simplifiedmns.cpp \
1202+
evo/smldiff.cpp \
1203+
evo/specialtx.cpp \
1204+
evo/specialtx_filter.cpp \
1205+
evo/specialtxman.cpp \
1206+
flatfile.cpp \
1207+
fs.cpp \
1208+
governance/classes.cpp \
1209+
governance/common.cpp \
1210+
governance/exceptions.cpp \
1211+
governance/governance.cpp \
1212+
governance/object.cpp \
1213+
governance/validators.cpp \
1214+
governance/vote.cpp \
1215+
governance/votedb.cpp \
1216+
gsl/assert.cpp \
1217+
hash.cpp \
1218+
index/base.cpp \
1219+
index/blockfilterindex.cpp \
1220+
index/coinstatsindex.cpp \
1221+
index/txindex.cpp \
1222+
instantsend/db.cpp \
1223+
instantsend/instantsend.cpp \
1224+
init/common.cpp \
1225+
key.cpp \
1226+
key_io.cpp \
1227+
llmq/blockprocessor.cpp \
1228+
llmq/commitment.cpp \
1229+
llmq/context.cpp \
1230+
llmq/debug.cpp \
1231+
llmq/dkgsession.cpp \
1232+
llmq/dkgsessionhandler.cpp \
1233+
llmq/dkgsessionmgr.cpp \
1234+
llmq/options.cpp \
1235+
llmq/quorums.cpp \
1236+
llmq/quorumsman.cpp \
1237+
llmq/signhash.cpp \
1238+
llmq/signing.cpp \
1239+
llmq/snapshot.cpp \
1240+
llmq/utils.cpp \
1241+
logging.cpp \
1242+
netaddress.cpp \
1243+
netbase.cpp \
1244+
node/blockstorage.cpp \
1245+
node/chainstate.cpp \
1246+
node/transaction.cpp \
1247+
kernel/coinstats.cpp \
1248+
masternode/meta.cpp \
1249+
masternode/payments.cpp \
1250+
masternode/sync.cpp \
1251+
messagesigner.cpp \
1252+
merkleblock.cpp \
1253+
node/interface_ui.cpp \
1254+
policy/feerate.cpp \
1255+
policy/fees.cpp \
1256+
policy/packages.cpp \
1257+
policy/policy.cpp \
1258+
policy/settings.cpp \
1259+
pow.cpp \
1260+
protocol.cpp \
1261+
primitives/block.cpp \
1262+
primitives/transaction.cpp \
1263+
pubkey.cpp \
1264+
random.cpp \
1265+
randomenv.cpp \
1266+
saltedhasher.cpp \
1267+
scheduler.cpp \
1268+
script/interpreter.cpp \
1269+
script/script.cpp \
1270+
script/script_error.cpp \
1271+
script/sigcache.cpp \
1272+
script/standard.cpp \
1273+
spork.cpp \
1274+
shutdown.cpp \
1275+
support/cleanse.cpp \
1276+
support/lockedpool.cpp \
1277+
sync.cpp \
1278+
timedata.cpp \
1279+
txdb.cpp \
1280+
txmempool.cpp \
1281+
uint256.cpp \
1282+
util/asmap.cpp \
1283+
util/bytevectorhash.cpp \
1284+
util/check.cpp \
1285+
util/getuniquepath.cpp \
1286+
util/hasher.cpp \
1287+
util/message.cpp \
1288+
util/moneystr.cpp \
1289+
util/ranges_set.cpp \
1290+
util/serfloat.cpp \
1291+
util/settings.cpp \
1292+
util/sock.cpp \
1293+
util/string.cpp \
1294+
util/strencodings.cpp \
1295+
util/syserror.cpp \
1296+
util/system.cpp \
1297+
util/thread.cpp \
1298+
util/threadinterrupt.cpp \
1299+
util/threadnames.cpp \
1300+
util/time.cpp \
1301+
util/tokenpipe.cpp \
1302+
validation.cpp \
1303+
validationinterface.cpp \
1304+
versionbits.cpp \
1305+
warnings.cpp
1306+
dash_chainstate_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
1307+
dash_chainstate_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
1308+
dash_chainstate_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS)
1309+
dash_chainstate_LDADD = \
1310+
$(LIBBITCOIN_CRYPTO) \
1311+
$(LIBUNIVALUE) \
1312+
$(LIBSECP256K1) \
1313+
$(LIBDASHBLS) \
1314+
$(LIBLEVELDB) \
1315+
$(LIBLEVELDB_SSE42) \
1316+
$(LIBMEMENV)
1317+
1318+
# Required for obj/build.h to be generated first.
1319+
# More details: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html
1320+
bitcoin_chainstate-clientversion.$(OBJEXT): obj/build.h
11591321
#
11601322

11611323
# dashconsensus library #

0 commit comments

Comments
 (0)