From 48ee339784e0ede29fa8f6b07b52f0bf72af7ae2 Mon Sep 17 00:00:00 2001 From: AlefLm Date: Thu, 23 Jan 2025 21:49:14 +0000 Subject: [PATCH] firod: add CMake compilation support. * Improved misc CMake compilation support. * Add bitcoin-config.h generation support. --- CMakeLists.txt | 49 +++++- cmake/bitcoin-build-config.h.in | 11 +- depends/packages/packages.mk | 2 + depends/toolchain.cmake.in | 2 +- src/CMakeLists.txt | 282 +++++++++++++++++++++++++++++-- src/crypto/CMakeLists.txt | 9 + src/secp256k1/CMakeLists.txt | 16 +- src/secp256k1/src/CMakeLists.txt | 24 ++- src/zmq/CMakeLists.txt | 2 + 9 files changed, 357 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3bedb72e0..3f3963ffc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ endif() set(CLIENT_NAME "Firo Core") set(CLIENT_VERSION_MAJOR 0) set(CLIENT_VERSION_MINOR 14) +set(CLIENT_VERSION_REVISION 14) set(CLIENT_VERSION_BUILD 0) set(CLIENT_VERSION_RC 0) set(CLIENT_VERSION_IS_RELEASE "false") @@ -41,7 +42,7 @@ set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ) project(FiroCore - VERSION ${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_BUILD} + VERSION ${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_REVISION} DESCRIPTION "Firo client software" HOMEPAGE_URL "https://firo.org/" LANGUAGES NONE @@ -135,9 +136,14 @@ option(REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting execu option(WERROR "Treat compiler warnings as errors." OFF) option(WITH_CCACHE "Attempt to use ccache for compiling." ON) -option(WITH_ZMQ "Enable ZMQ notifications." OFF) +option(WITH_ZMQ "Enable ZMQ notifications." ON) if(WITH_ZMQ) + message(STATUS "ZMQ notifications enabled.") + add_compile_definitions(ENABLE_ZMQ=1) find_package(ZeroMQ 4.0.0 MODULE REQUIRED) +else() + message(STATUS "ZMQ notifications disabled.") + add_compile_definitions(ENABLE_ZMQ=0) endif() option(WITH_USDT "Enable tracepoints for Userspace, Statically Defined Tracing." OFF) @@ -388,6 +394,45 @@ if(BUILD_DAEMON OR BUILD_GUI OR BUILD_CLI OR BUILD_TESTS OR BUILD_BENCH OR BUILD find_package(Libevent 2.1.8 MODULE REQUIRED) endif() +# Find bls-dash library +find_library(BLS_DASH_LIBRARY + NAMES bls-dash + REQUIRED +) + +if(${BLS_DASH_LIBRARY} STREQUAL "BLS_DASH_LIBRARY-NOTFOUND") + message(FATAL_ERROR "bls-dash library not found") +else() + message(STATUS "Found bls-dash library: ${BLS_DASH_LIBRARY}") +endif() + +# Find tor library +find_library(TOR_LIBRARY + NAMES tor + REQUIRED +) + +# Find OpenSSL library +find_package(OpenSSL 1.1.1 REQUIRED) + +# Find MiniUPNP library +find_library(MINIUPNP_LIBRARY + NAMES miniupnpc + REQUIRED +) + +# Find zlib library +find_library(ZLIB_LIBRARY + NAMES z + REQUIRED +) + +if(${TOR_LIBRARY} STREQUAL "TOR_LIBRARY-NOTFOUND") + message(FATAL_ERROR "tor library not found") +else() + message(STATUS "Found tor library: ${TOR_LIBRARY}") +endif() + include(cmake/introspection.cmake) #################### # Check functions and define diff --git a/cmake/bitcoin-build-config.h.in b/cmake/bitcoin-build-config.h.in index 56e0519fac..363f3815e7 100644 --- a/cmake/bitcoin-build-config.h.in +++ b/cmake/bitcoin-build-config.h.in @@ -17,6 +17,9 @@ /* Minor version */ #define CLIENT_VERSION_MINOR @CLIENT_VERSION_MINOR@ +/* Revision version */ +#define CLIENT_VERSION_REVISION @CLIENT_VERSION_REVISION@ + /* Copyright holder(s) before %s replacement */ #define COPYRIGHT_HOLDERS "@COPYRIGHT_HOLDERS@" @@ -121,16 +124,16 @@ #cmakedefine HAVE_VM_VM_PARAM_H 1 /* Define to the address where bug reports for this package should be sent. */ -#define CLIENT_BUGREPORT "@CLIENT_BUGREPORT@" +#define PACKAGE_BUGREPORT "@CLIENT_BUGREPORT@" /* Define to the full name of this package. */ -#define CLIENT_NAME "@CLIENT_NAME@" +#define PACKAGE_NAME "@CLIENT_NAME@" /* Define to the home page for this package. */ -#define CLIENT_URL "@PROJECT_HOMEPAGE_URL@" +#define PACKAGE_URL "@PROJECT_HOMEPAGE_URL@" /* Define to the version of this package. */ -#define CLIENT_VERSION_STRING "@CLIENT_VERSION_STRING@" +#define PACKAGE_VERSION "@CLIENT_VERSION_STRING@" /* Define to 1 if strerror_r returns char *. */ #cmakedefine STRERROR_R_CHAR_P 1 diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 574bf3b276..813afd4c16 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -11,6 +11,8 @@ qt_mingw32_packages=qt bdb_packages=bdb sqlite_packages=sqlite +zmq_packages=zeromq + upnp_packages=miniupnpc darwin_native_packages = native_ds_store native_mac_alias diff --git a/depends/toolchain.cmake.in b/depends/toolchain.cmake.in index 65e70d8179..1ae9c4ecbd 100644 --- a/depends/toolchain.cmake.in +++ b/depends/toolchain.cmake.in @@ -82,7 +82,7 @@ set(CMAKE_OBJDUMP "@OBJDUMP@") set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH OFF) set(CMAKE_FIND_ROOT_PATH "@depends_prefix@") -list(APPEND CMAKE_PREFIX_PATH "${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig") +list(APPEND CMAKE_PREFIX_PATH "${CMAKE_FIND_ROOT_PATH}/lib/;${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig") set(ENV{PKG_CONFIG_PATH} "${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e1f4d8b4b..624c2bba1b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,7 @@ include(GNUInstallDirs) include(AddWindowsResources) -configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-build-config.h.in bitcoin-build-config.h USE_SOURCE_PERMISSIONS @ONLY) +configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-build-config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config/bitcoin-config.h USE_SOURCE_PERMISSIONS @ONLY) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) add_custom_target(generate_build_info @@ -39,6 +39,30 @@ add_library(bitcoin_util STATIC EXCLUDE_FROM_ALL random.cpp sync.cpp support/lockedpool.cpp + bls/bls_batchverifier.h + bls/bls_ies.cpp + bls/bls_ies.h + bls/bls_worker.cpp + bls/bls_worker.h + support/lockedpool.cpp + chainparamsbase.cpp + clientversion.cpp + compat/glibc_sanity.cpp + compat/glibcxx_sanity.cpp + compat/strnlen.cpp + mbstring.cpp + fs.cpp + random.cpp + rpc/protocol.cpp + support/cleanse.cpp + sync.cpp + threadinterrupt.cpp + util.cpp + utilmoneystr.cpp + utilstrencodings.cpp + utiltime.cpp + crypto/scrypt.cpp + primitives/block.cpp ) target_link_libraries(bitcoin_util @@ -48,6 +72,7 @@ target_link_libraries(bitcoin_util bitcoin_crypto secp256k1 leveldb + univalue $<$:ws2_32> $<$:iphlpapi> ) @@ -64,7 +89,7 @@ endif() message("") message("Configuring secp256k1 subtree...") set(SECP256K1_DISABLE_SHARED ON CACHE BOOL "" FORCE) -set(SECP256K1_ENABLE_MODULE_ECDH OFF CACHE BOOL "" FORCE) +set(SECP256K1_ENABLE_MODULE_ECDH ON CACHE BOOL "" FORCE) set(SECP256K1_ENABLE_MODULE_RECOVERY ON CACHE BOOL "" FORCE) set(SECP256K1_ENABLE_MODULE_MUSIG OFF CACHE BOOL "" FORCE) set(SECP256K1_BUILD_BENCHMARK OFF CACHE BOOL "" FORCE) @@ -118,13 +143,49 @@ add_library(bitcoin_consensus STATIC EXCLUDE_FROM_ALL script/script.cpp script/script_error.cpp uint256.cpp + amount.h + arith_uint256.cpp + arith_uint256.h + bls/bls.cpp + bls/bls.h + consensus/merkle.cpp + consensus/merkle.h + consensus/params.h + consensus/validation.h + hash.cpp + flat-database.h + hash.h + prevector.h + crypto/scrypt.h + primitives/block.h + primitives/precomputed_hash.h + primitives/transaction.cpp + primitives/transaction.h + pubkey.cpp + pubkey.h + script/bitcoinconsensus.cpp + script/interpreter.cpp + script/interpreter.h + script/script.cpp + script/script.h + script/script_error.cpp + script/script_error.h + serialize.h + tinyformat.h + uint256.cpp + uint256.h + utilstrencodings.cpp + utilstrencodings.h + version.h ) target_link_libraries(bitcoin_consensus PRIVATE core_interface secp256k1 leveldb + ${BLS_DASH_LIBRARY} PUBLIC + OpenSSL::Crypto bitcoin_crypto ) @@ -155,6 +216,24 @@ add_library(bitcoin_common STATIC EXCLUDE_FROM_ALL rpc/rawtransaction.cpp scheduler.cpp script/sign.cpp + amount.cpp + base58.cpp + chainparams.cpp + coins.cpp + compressor.cpp + core_read.cpp + core_write.cpp + hdmint/hdmint.cpp + key.cpp + keystore.cpp + netaddress.cpp + netbase.cpp + protocol.cpp + saltedhasher.cpp + scheduler.cpp + script/sign.cpp + script/standard.cpp + warnings.cpp ) target_link_libraries(bitcoin_common PUBLIC @@ -165,35 +244,80 @@ target_link_libraries(bitcoin_common secp256k1 Boost::headers leveldb + $<$:firo_zmq> $ $<$:ws2_32> ) +add_library(bitcoin_wallet STATIC EXCLUDE_FROM_ALL + activemasternode.cpp + hdmint/hdmint.cpp + masternode-sync.cpp + hdmint/mintpool.cpp + hdmint/wallet.cpp + sigma.cpp + lelantus.cpp + spark/state.cpp + wallet/crypter.cpp + wallet/bip39.cpp + wallet/mnemoniccontainer.cpp + wallet/db.cpp + wallet/rpcdump.cpp + wallet/rpcwallet.cpp + wallet/sigmaspendbuilder.cpp + wallet/txbuilder.cpp + wallet/lelantusjoinsplitbuilder.cpp + wallet/walletexcept.cpp + wallet/wallet.cpp + spark/sparkwallet.cpp + spark/primitives.cpp + wallet/walletdb.cpp + wallet/authhelper.cpp + hdmint/tracker.cpp + policy/rbf.cpp + bip47/account.cpp + bip47/paymentchannel.cpp + bip47/bip47utils.cpp + bip47/paymentcode.cpp + bip47/secretpoint.cpp + primitives/mint_spend.cpp +) +target_link_libraries(bitcoin_wallet + PUBLIC + core_interface + bitcoin_util + univalue + secp256k1 + Boost::headers + leveldb +) + set(installable_targets) if(ENABLE_WALLET) add_subdirectory(wallet) if(BUILD_WALLET_TOOL) - add_executable(bitcoin-wallet + add_executable(firo-wallet bitcoin-wallet.cpp init/bitcoin-wallet.cpp wallet/wallettool.cpp ) - add_windows_resources(bitcoin-wallet bitcoin-wallet-res.rc) - target_link_libraries(bitcoin-wallet + add_windows_resources(firo-wallet bitcoin-wallet-res.rc) + target_link_libraries(firo-wallet core_interface firo_wallet bitcoin_common bitcoin_util + bitcoin_wallet Boost::headers ) - list(APPEND installable_targets bitcoin-wallet) + list(APPEND installable_targets firo-wallet) endif() endif() # P2P and RPC server functionality used by `bitcoind` and `bitcoin-qt` executables. -add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL +add_library(firo_node STATIC EXCLUDE_FROM_ALL addrdb.cpp addrman.cpp blockencodings.cpp @@ -224,38 +348,164 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL validation.cpp validationinterface.cpp versionbits.cpp + ui_interface.cpp + compat/glibc_sanity.cpp + compat/glibcxx_sanity.cpp + activemasternode.cpp + addrman.cpp + addrdb.cpp + batchedlogger.cpp + bloom.cpp + blockencodings.cpp + chain.cpp + checkpoints.cpp + dsnotificationinterface.cpp + evo/cbtx.cpp + evo/deterministicmns.cpp + evo/evodb.cpp + evo/mnauth.cpp + evo/providertx.cpp + evo/simplifiedmns.cpp + evo/specialtx.cpp + evo/spork.cpp + llmq/quorums.cpp + llmq/quorums_blockprocessor.cpp + llmq/quorums_commitment.cpp + llmq/quorums_chainlocks.cpp + llmq/quorums_debug.cpp + llmq/quorums_dkgsessionhandler.cpp + llmq/quorums_dkgsessionmgr.cpp + llmq/quorums_dkgsession.cpp + llmq/quorums_init.cpp + llmq/quorums_instantsend.cpp + llmq/quorums_signing.cpp + llmq/quorums_signing_shares.cpp + llmq/quorums_utils.cpp + masternode-payments.cpp + masternode-sync.cpp + masternode-utils.cpp + httprpc.cpp + httpserver.cpp + init.cpp + dbwrapper.cpp + threadinterrupt.cpp + merkleblock.cpp + miner.cpp + messagesigner.cpp + net.cpp + netfulfilledman.cpp + net_processing.cpp + noui.cpp + policy/fees.cpp + policy/policy.cpp + primitives/mint_spend.cpp + pow.cpp + rest.cpp + rpc/blockchain.cpp + rpc/masternode.cpp + rpc/mining.cpp + rpc/misc.cpp + rpc/net.cpp + rpc/rawtransaction.cpp + rpc/server.cpp + rpc/rpcevo.cpp + rpc/rpcquorums.cpp + script/sigcache.cpp + script/ismine.cpp + timedata.cpp + torcontrol.cpp + txdb.cpp + txmempool.cpp + ui_interface.cpp + batchproof_container.cpp + validation.cpp + validationinterface.cpp + versionbits.cpp + sigma.cpp + lelantus.cpp + bip47/paymentcode.cpp + spark/state.cpp + spark/primitives.cpp + coin_containers.cpp + mtpstate.cpp + sigma/coin.cpp + sigma/coinspend.cpp + sigma/spend_metadata.cpp + sigma/params.cpp + liblelantus/lelantus_primitives.cpp + liblelantus/lelantus_prover.cpp + liblelantus/lelantus_verifier.cpp + liblelantus/sigmaextended_prover.cpp + liblelantus/sigmaextended_verifier.cpp + liblelantus/schnorr_prover.cpp + liblelantus/schnorr_verifier.cpp + liblelantus/innerproduct_proof_verifier.cpp + liblelantus/innerproduct_proof_generator.cpp + liblelantus/range_prover.cpp + liblelantus/range_verifier.cpp + liblelantus/coin.cpp + liblelantus/joinsplit.cpp + liblelantus/spend_metadata.cpp + liblelantus/params.cpp + libspark/transcript.cpp + libspark/params.cpp + libspark/schnorr.cpp + libspark/chaum.cpp + libspark/coin.cpp + libspark/bpplus.cpp + libspark/grootle.cpp + libspark/keys.cpp + libspark/util.cpp + libspark/aead.cpp + libspark/kdf.cpp + libspark/hash.cpp + libspark/mint_transaction.cpp + libspark/spend_transaction.cpp + libspark/f4grumble.cpp + libspark/bech32.cpp ) -target_link_libraries(bitcoin_node + +target_link_libraries(firo_node PRIVATE core_interface bitcoin_common bitcoin_util secp256k1 - $ + $<$:firo_zmq> leveldb univalue Boost::headers Boost::thread + OpenSSL::Crypto + ${TOR_LIBRARY} + OpenSSL::SSL + ${MINIUPNP_LIBRARY} + ${ZLIB_LIBRARY} $ $ $ $ ) -# Bitcoin Core bitcoind. +# Bitcoin Core firod. if(BUILD_DAEMON) - add_executable(bitcoind + add_executable(firod bitcoind.cpp ) - add_windows_resources(bitcoind bitcoind-res.rc) - target_link_libraries(bitcoind + add_windows_resources(firod bitcoind-res.rc) + target_link_libraries(firod core_interface - bitcoin_node univalue Boost::thread + firo_node + $<$:firo_zmq> + firo_cli + secp256k1 + secp256k1pp + bitcoin_wallet $ ) - list(APPEND installable_targets bitcoind) + list(APPEND installable_targets firod) endif() if(WITH_MULTIPROCESS) add_executable(bitcoin-node @@ -264,7 +514,7 @@ if(WITH_MULTIPROCESS) ) target_link_libraries(bitcoin-node core_interface - bitcoin_node + firo_node bitcoin_ipc $ ) diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt index d81073afcd..39f3541564 100644 --- a/src/crypto/CMakeLists.txt +++ b/src/crypto/CMakeLists.txt @@ -15,6 +15,15 @@ add_library(bitcoin_crypto STATIC EXCLUDE_FROM_ALL sha256.cpp sha512.cpp scrypt.cpp + MerkleTreeProof/arith_uint256.cpp + MerkleTreeProof/blake2 + MerkleTreeProof/core.c + MerkleTreeProof/merkle-tree.cpp + MerkleTreeProof/mtp.cpp + MerkleTreeProof/ref.c + MerkleTreeProof/thread.c + MerkleTreeProof/blake2/blake2b.c + MerkleTreeProof/crypto/sha256.cpp Lyra2Z/Lyra2.c Lyra2Z/Lyra2Z.c Lyra2Z/Sponge.c diff --git a/src/secp256k1/CMakeLists.txt b/src/secp256k1/CMakeLists.txt index 6b4bc2b54e..54ef962cb4 100644 --- a/src/secp256k1/CMakeLists.txt +++ b/src/secp256k1/CMakeLists.txt @@ -75,16 +75,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) option(SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON) option(SECP256K1_ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." ON) -# Processing must be done in a topological sorting of the dependency graph -# (dependent module first). -if(SECP256K1_ENABLE_MODULE_RECOVERY) - add_compile_definitions(ENABLE_MODULE_RECOVERY=1) -endif() - -if(SECP256K1_ENABLE_MODULE_ECDH) - add_compile_definitions(ENABLE_MODULE_ECDH=1) -endif() - set(SECP256K1_ECMULT_WINDOW_SIZE 15 CACHE STRING "Window size for ecmult precomputation for verification, specified as integer in range [2..24]. The default value is a reasonable setting for desktop machines (currently 15). [default=15]") set_property(CACHE SECP256K1_ECMULT_WINDOW_SIZE PROPERTY STRINGS 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24) include(CheckStringOptionValue) @@ -162,9 +152,9 @@ if(SECP256K1_VALGRIND) endif() endif() -option(SECP256K1_BUILD_BENCHMARK "Build benchmarks." ON) -option(SECP256K1_BUILD_TESTS "Build tests." ON) -option(SECP256K1_BUILD_EXHAUSTIVE_TESTS "Build exhaustive tests." ON) +option(SECP256K1_BUILD_BENCHMARK "Build benchmarks." OFF) +option(SECP256K1_BUILD_TESTS "Build tests." OFF) +option(SECP256K1_BUILD_EXHAUSTIVE_TESTS "Build exhaustive tests." OFF) # Redefine configuration flags. # We leave assertions on, because they are only used in the examples, and we want them always on there. diff --git a/src/secp256k1/src/CMakeLists.txt b/src/secp256k1/src/CMakeLists.txt index 974bae7678..6705451b44 100644 --- a/src/secp256k1/src/CMakeLists.txt +++ b/src/secp256k1/src/CMakeLists.txt @@ -18,13 +18,29 @@ target_link_libraries(secp256k1 # secp256k1 Configuration #============================= # Define this symbol if libgmp is installed -add_compile_definitions(secp256k1 PUBLIC -DHAVE_LIBGMP=1) +add_compile_definitions(HAVE_LIBGMP=1) # Define this symbol to use the gmp implementation for num -add_compile_definitions(secp256k1 PUBLIC -DUSE_NUM_GMP=1) +add_compile_definitions(USE_NUM_GMP=1) # Define this symbol to use the num-based field inverse implementation -add_compile_definitions(secp256k1 PUBLIC -DUSE_FIELD_INV_NUM=1) +add_compile_definitions(USE_FIELD_INV_NUM=1) # Define this symbol to use the num-based scalar inverse implementation -add_compile_definitions(secp256k1 PUBLIC -DUSE_SCALAR_INV_NUM=1) +add_compile_definitions(USE_SCALAR_INV_NUM=1) + +# Processing must be done in a topological sorting of the dependency graph +# (dependent module first). +if(SECP256K1_ENABLE_MODULE_RECOVERY) + add_compile_definitions(ENABLE_MODULE_RECOVERY=1) + message(STATUS "secp256k1: Recovery module enabled") +else() + message(STATUS "secp256k1: Recovery module disabled") +endif() + +if(SECP256K1_ENABLE_MODULE_ECDH) + add_compile_definitions(ENABLE_MODULE_ECDH=1) + message(STATUS "secp256k1: ECDH module enabled") +else() + message(STATUS "secp256k1: ECDH module disabled") +endif() add_library(secp256k1pp cpp/GroupElement.cpp diff --git a/src/zmq/CMakeLists.txt b/src/zmq/CMakeLists.txt index 1afbdd1701..f3a02a7bec 100644 --- a/src/zmq/CMakeLists.txt +++ b/src/zmq/CMakeLists.txt @@ -16,4 +16,6 @@ target_link_libraries(firo_zmq core_interface univalue zeromq + secp256k1 + leveldb )