diff --git a/.gitignore b/.gitignore index 8c13e82b2289..efa7ab526448 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ src/dash-gui src/dash-node src/dash-tx src/dash-util +src/dash-chainstate src/dash-wallet src/test/fuzz/fuzz src/test/test_dash diff --git a/ci/dash/matrix.sh b/ci/dash/matrix.sh index 6e249fc476d1..de01eaf6d6c7 100755 --- a/ci/dash/matrix.sh +++ b/ci/dash/matrix.sh @@ -27,7 +27,7 @@ elif [ "$BUILD_TARGET" = "linux64_fuzz" ]; then elif [ "$BUILD_TARGET" = "linux64_multiprocess" ]; then source ./ci/test/00_setup_env_native_multiprocess.sh elif [ "$BUILD_TARGET" = "linux64_nowallet" ]; then - source ./ci/test/00_setup_env_native_nowallet.sh + source ./ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh elif [ "$BUILD_TARGET" = "linux64_sqlite" ]; then source ./ci/test/00_setup_env_native_sqlite.sh elif [ "$BUILD_TARGET" = "linux64_tsan" ]; then diff --git a/ci/test/00_setup_env_native_nowallet.sh b/ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh similarity index 81% rename from ci/test/00_setup_env_native_nowallet.sh rename to ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh index 3e083c3d4d62..ef228c677fef 100755 --- a/ci/test/00_setup_env_native_nowallet.sh +++ b/ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh @@ -6,9 +6,9 @@ export LC_ALL=C.UTF-8 -export CONTAINER_NAME=ci_native_nowallet +export CONTAINER_NAME=ci_native_nowallet_libbitcoinkernel export HOST=x86_64-pc-linux-gnu export PACKAGES="python3-zmq" export DEP_OPTS="NO_WALLET=1 CC=gcc-14 CXX=g++-14" export GOAL="install" -export BITCOIN_CONFIG="--enable-reduce-exports CC=gcc-14 CXX=g++-14" +export BITCOIN_CONFIG="--enable-reduce-exports CC=gcc-14 CXX=g++-14 --enable-experimental-util-chainstate" diff --git a/configure.ac b/configure.ac index 31951e1f7c47..371000a95312 100644 --- a/configure.ac +++ b/configure.ac @@ -35,6 +35,7 @@ BITCOIN_TEST_NAME=test_dash BITCOIN_CLI_NAME=dash-cli BITCOIN_TX_NAME=dash-tx BITCOIN_UTIL_NAME=dash-util +BITCOIN_CHAINSTATE_NAME=dash-chainstate BITCOIN_WALLET_TOOL_NAME=dash-wallet dnl Multi Process BITCOIN_MP_NODE_NAME=dash-node @@ -769,6 +770,13 @@ AC_ARG_ENABLE([util-util], [build_bitcoin_util=$enableval], [build_bitcoin_util=$build_bitcoin_utils]) +AC_ARG_ENABLE([experimental-util-chainstate], + [AS_HELP_STRING([--enable-experimental-util-chainstate], + [build experimental dash-chainstate executable (default=no)])], + [build_bitcoin_chainstate=$enableval], + [build_bitcoin_chainstate=no]) + + AC_ARG_WITH([libs], [AS_HELP_STRING([--with-libs], [build libraries (default=yes)])], @@ -1443,6 +1451,7 @@ if test "$enable_fuzz" = "yes"; then build_bitcoin_cli=no build_bitcoin_tx=no build_bitcoin_util=no + build_bitcoin_chainstate=no build_bitcoin_wallet=no build_bitcoind=no build_bitcoin_libs=no @@ -1781,6 +1790,10 @@ AC_MSG_CHECKING([whether to build dash-util]) AM_CONDITIONAL([BUILD_BITCOIN_UTIL], [test $build_bitcoin_util = "yes"]) AC_MSG_RESULT($build_bitcoin_util) +AC_MSG_CHECKING([whether to build experimental dash-chainstate]) +AM_CONDITIONAL([BUILD_BITCOIN_CHAINSTATE], [test $build_bitcoin_chainstate = "yes"]) +AC_MSG_RESULT($build_bitcoin_chainstate) + AC_MSG_CHECKING([whether to build libraries]) AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test $build_bitcoin_libs = "yes"]) if test "$build_bitcoin_libs" = "yes"; then @@ -1995,6 +2008,7 @@ AC_SUBST(BITCOIN_TEST_NAME) AC_SUBST(BITCOIN_CLI_NAME) AC_SUBST(BITCOIN_TX_NAME) AC_SUBST(BITCOIN_UTIL_NAME) +AC_SUBST(BITCOIN_CHAINSTATE_NAME) AC_SUBST(BITCOIN_WALLET_TOOL_NAME) AC_SUBST(BITCOIN_MP_NODE_NAME) AC_SUBST(BITCOIN_MP_GUI_NAME) diff --git a/src/Makefile.am b/src/Makefile.am index a36f08be79c5..e11917845b35 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -148,6 +148,10 @@ if BUILD_BITCOIN_UTIL bin_PROGRAMS += dash-util endif +if BUILD_BITCOIN_CHAINSTATE + bin_PROGRAMS += dash-chainstate +endif + .PHONY: FORCE check-symbols check-security # dash core # BITCOIN_CORE_H = \ @@ -1157,6 +1161,163 @@ dash_util_LDADD = \ $(BACKTRACE_LIBS) dash_util_LDADD += $(BOOST_LIBS) + +# dash-chainstate binary # +dash_chainstate_SOURCES = \ + bitcoin-chainstate.cpp \ + addressindex.cpp \ + arith_uint256.cpp \ + base58.cpp \ + batchedlogger.cpp \ + blockfilter.cpp \ + bls/bls.cpp \ + bls/bls_worker.cpp \ + chain.cpp \ + chainparamsbase.cpp \ + chainparams.cpp \ + clientversion.cpp \ + coins.cpp \ + compressor.cpp \ + chainlock/clsig.cpp \ + chainlock/chainlock.cpp \ + consensus/merkle.cpp \ + consensus/tx_check.cpp \ + consensus/tx_verify.cpp \ + common/bloom.cpp \ + core_read.cpp \ + dbwrapper.cpp \ + deploymentinfo.cpp \ + deploymentstatus.cpp \ + evo/assetlocktx.cpp \ + evo/cbtx.cpp \ + evo/creditpool.cpp \ + evo/chainhelper.cpp \ + evo/deterministicmns.cpp \ + evo/dmnstate.cpp \ + evo/evodb.cpp \ + evo/netinfo.cpp \ + evo/mnhftx.cpp \ + evo/providertx.cpp \ + evo/simplifiedmns.cpp \ + evo/smldiff.cpp \ + evo/specialtx.cpp \ + evo/specialtx_filter.cpp \ + evo/specialtxman.cpp \ + flatfile.cpp \ + fs.cpp \ + governance/classes.cpp \ + governance/common.cpp \ + governance/exceptions.cpp \ + governance/governance.cpp \ + governance/object.cpp \ + governance/validators.cpp \ + governance/vote.cpp \ + governance/votedb.cpp \ + gsl/assert.cpp \ + hash.cpp \ + index/base.cpp \ + index/blockfilterindex.cpp \ + index/coinstatsindex.cpp \ + index/txindex.cpp \ + instantsend/db.cpp \ + instantsend/instantsend.cpp \ + init/common.cpp \ + key.cpp \ + key_io.cpp \ + llmq/blockprocessor.cpp \ + llmq/commitment.cpp \ + llmq/context.cpp \ + llmq/debug.cpp \ + llmq/dkgsession.cpp \ + llmq/dkgsessionhandler.cpp \ + llmq/dkgsessionmgr.cpp \ + llmq/options.cpp \ + llmq/quorums.cpp \ + llmq/quorumsman.cpp \ + llmq/signhash.cpp \ + llmq/signing.cpp \ + llmq/snapshot.cpp \ + llmq/utils.cpp \ + logging.cpp \ + netaddress.cpp \ + netbase.cpp \ + node/blockstorage.cpp \ + node/chainstate.cpp \ + node/transaction.cpp \ + kernel/coinstats.cpp \ + masternode/meta.cpp \ + masternode/payments.cpp \ + masternode/sync.cpp \ + messagesigner.cpp \ + merkleblock.cpp \ + node/interface_ui.cpp \ + policy/feerate.cpp \ + policy/fees.cpp \ + policy/packages.cpp \ + policy/policy.cpp \ + policy/settings.cpp \ + pow.cpp \ + protocol.cpp \ + primitives/block.cpp \ + primitives/transaction.cpp \ + pubkey.cpp \ + random.cpp \ + randomenv.cpp \ + saltedhasher.cpp \ + scheduler.cpp \ + script/interpreter.cpp \ + script/script.cpp \ + script/script_error.cpp \ + script/sigcache.cpp \ + script/standard.cpp \ + spork.cpp \ + shutdown.cpp \ + support/cleanse.cpp \ + support/lockedpool.cpp \ + sync.cpp \ + timedata.cpp \ + txdb.cpp \ + txmempool.cpp \ + uint256.cpp \ + util/asmap.cpp \ + util/bytevectorhash.cpp \ + util/check.cpp \ + util/getuniquepath.cpp \ + util/hasher.cpp \ + util/message.cpp \ + util/moneystr.cpp \ + util/ranges_set.cpp \ + util/serfloat.cpp \ + util/settings.cpp \ + util/sock.cpp \ + util/string.cpp \ + util/strencodings.cpp \ + util/syserror.cpp \ + util/system.cpp \ + util/thread.cpp \ + util/threadinterrupt.cpp \ + util/threadnames.cpp \ + util/time.cpp \ + util/tokenpipe.cpp \ + validation.cpp \ + validationinterface.cpp \ + versionbits.cpp \ + warnings.cpp +dash_chainstate_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) +dash_chainstate_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +dash_chainstate_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) +dash_chainstate_LDADD = \ + $(LIBBITCOIN_CRYPTO) \ + $(LIBUNIVALUE) \ + $(LIBSECP256K1) \ + $(LIBDASHBLS) \ + $(LIBLEVELDB) \ + $(LIBLEVELDB_SSE42) \ + $(LIBMEMENV) + +# Required for obj/build.h to be generated first. +# More details: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html +bitcoin_chainstate-clientversion.$(OBJEXT): obj/build.h # # dashconsensus library # diff --git a/src/active/context.cpp b/src/active/context.cpp index 831a1b4ccc67..bca4df5a8316 100644 --- a/src/active/context.cpp +++ b/src/active/context.cpp @@ -32,7 +32,6 @@ ActiveContext::ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman const CMasternodeSync& mn_sync, const CBLSSecretKey& operator_sk, const llmq::QvvecSyncModeMap& sync_map, const util::DbWrapperParams& db_params, bool quorums_recovery, bool quorums_watch) : - m_isman{isman}, m_qman{qman}, nodeman{std::make_unique(connman, dmnman, operator_sk)}, dkgdbgman{std::make_unique(dmnman, qsnapman, chainman)}, @@ -53,14 +52,12 @@ ActiveContext::ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman qblockman, qsnapman, *nodeman, chainman, sporkman, llmq_params, quorums_watch, quorum_idx); }); - m_isman.ConnectSigner(is_signer.get()); m_qman.ConnectManagers(qman_handler.get(), qdkgsman.get()); } ActiveContext::~ActiveContext() { m_qman.DisconnectManagers(); - m_isman.DisconnectSigner(); } void ActiveContext::Start(CConnman& connman, PeerManager& peerman, int16_t worker_count) diff --git a/src/active/context.h b/src/active/context.h index c93690c4bc4a..e0d774f6e923 100644 --- a/src/active/context.h +++ b/src/active/context.h @@ -54,7 +54,6 @@ struct DbWrapperParams; struct ActiveContext final : public CValidationInterface { private: - llmq::CInstantSendManager& m_isman; llmq::CQuorumManager& m_qman; public: @@ -97,8 +96,11 @@ struct ActiveContext final : public CValidationInterface { const std::unique_ptr ehf_sighandler; const std::unique_ptr qman_handler; const std::unique_ptr cl_signer; + +public: const std::unique_ptr is_signer; +public: /** Owned by PeerManager, use GetCJServer() */ CCoinJoinServer* m_cj_server{nullptr}; }; diff --git a/src/active/quorums.cpp b/src/active/quorums.cpp index 0472ebe70f9d..b47efd9db6fc 100644 --- a/src/active/quorums.cpp +++ b/src/active/quorums.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp new file mode 100644 index 000000000000..c5a0e0f1d59e --- /dev/null +++ b/src/bitcoin-chainstate.cpp @@ -0,0 +1,366 @@ +// Copyright (c) 2022 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// +// The bitcoin-chainstate executable serves to surface the dependencies required +// by a program wishing to use Bitcoin Core's consensus engine as it is right +// now. +// +// DEVELOPER NOTE: Since this is a "demo-only", experimental, etc. executable, +// it may diverge from Bitcoin Core's coding style. +// +// It is part of the libbitcoinkernel project. + +#include +#include +#include +#include +#include +#include +#include +#include +#include