Skip to content

Commit

Permalink
Merge #2419: [Build] Add chiabls subtree
Browse files Browse the repository at this point in the history
5b289eb CI: Lint chiabls subtree (Fuzzbawls)
c775ab3 Lint: exclude chiabls subtree from whitespace linting (Fuzzbawls)
e5d5ef7 CMake: integrate chiabls subtree CMake targets (Fuzzbawls)
50318c6 Build: build chiabls library from git subtree (Fuzzbawls)
4a71f9a Squashed 'src/chiabls/' content from commit 676ea45e80 (Fuzzbawls)

Pull request description:

  This introduces a new upcoming library dependency as a git subtree with support for native autotools (and CMake) builds.

  #2405 had also introduced this library dependency, but only as part of the `depends` system, which introduced numerous issues, not least of which was essentially breaking any non-depends based builds. After some discussion, it was decided that the git subtree approach (as used with `leveldb`, `crc32`, `univalue`, and `secp256k1`) would be more ideal as it would allow for both depends and non-depends based builds.

  Achieving this requires us to maintain our own fork of https://github.com/Chia-Network/bls-signatures (ours is at https://github.com/PIVX-Project/bls-signatures) with a native autotools based build system added to it (PIVX-Project/bls-signatures#1) that has been integrated into PIVX Core here.

  Note: This PR simply introduces the new library and connects it to our autotools and CMake build systems, but does not introduce new code that actually _uses_ the new library.

  Also Note: This effectively bumps our minimum required version of CMake (for CMake builds only) to `3.14`.

ACKs for top commit:
  random-zebra:
    utACK 5b289eb and merging...

Tree-SHA512: 9a36015395f310031a59a4b0c2159704753db627802b73b26ccb0fa3b85a9f33403c53ff424aadf56da81de546bfcf8e150fb3eac99fa232c29fd98a828aedb9
  • Loading branch information
random-zebra committed Jul 28, 2021
2 parents c49c4c1 + 5b289eb commit 1e4fa87
Show file tree
Hide file tree
Showing 769 changed files with 254,801 additions and 24 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
test/lint/git-subtree-check.sh src/univalue
test/lint/git-subtree-check.sh src/leveldb
test/lint/git-subtree-check.sh src/crc32c
test/lint/git-subtree-check.sh src/chiabls
test/lint/check-doc.py
test/lint/logprint-scanner.py
test/lint/lint-all.sh
Expand Down Expand Up @@ -327,8 +328,8 @@ jobs:
functional_tests: false
no_depends: 1
goal: deploy
cc: $(brew --prefix llvm)/bin/clang
cxx: $(brew --prefix llvm)/bin/clang++
cc: clang
cxx: clang++
BITCOIN_CONFIG: "--enable-zmq --enable-gui --enable-reduce-exports --enable-werror"

steps:
Expand Down
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.14)

# Search for and use ccache if available to speed up build times
find_program(CCACHE_PROGRAM ccache)
Expand Down Expand Up @@ -148,6 +148,9 @@ set(LEVELDB_BUILD_BENCHMARKS OFF CACHE BOOL "Build LevelDB's benchmarks" FORCE)
set(LEVELDB_INSTALL OFF CACHE BOOL "Install LevelDB's header and library" FORCE)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/leveldb)

add_subdirectory(${CMAKE_SOURCE_DIR}/src/chiabls)
FetchContent_GetProperties(relic)

file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h)
file(GLOB CRYPTO_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/*.h)
file(GLOB PRIMITIVE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/primitives/*.h)
Expand Down Expand Up @@ -238,6 +241,9 @@ target_include_directories(SERVER_A PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/leveldb/include
${CMAKE_CURRENT_SOURCE_DIR}/src/leveldb/helpers/memenv
${CMAKE_CURRENT_SOURCE_DIR}/src/rust/include
${CMAKE_CURRENT_SOURCE_DIR}/src/chiabls/src
${relic_SOURCE_DIR}/include
${relic_BINARY_DIR}/include
${ZMQ_INCLUDE_DIR} ${LIBEVENT_INCLUDE_DIR} ${BerkeleyDB_INCLUDE_DIRS}
)

Expand Down Expand Up @@ -400,6 +406,9 @@ target_include_directories(COMMON_A PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/secp256k1/include
${CMAKE_CURRENT_SOURCE_DIR}/src/leveldb/include
${CMAKE_CURRENT_SOURCE_DIR}/src/univalue/include
${CMAKE_CURRENT_SOURCE_DIR}/src/chiabls/src
${relic_SOURCE_DIR}/include
${relic_BINARY_DIR}/include
${BerkeleyDB_INCLUDE_DIRS}
)

Expand Down Expand Up @@ -478,14 +487,15 @@ if($ENV{target} MATCHES "Windows")
list(APPEND pivx-cli_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/pivx-cli-res.rc)
endif()
add_executable(pivx-cli ${pivx-cli_SOURCES})
add_dependencies(pivx-cli libunivalue libzcashrust)
add_dependencies(pivx-cli libunivalue libzcashrust bls)
target_link_libraries(pivx-cli
CLI_A
univalue
UTIL_A
BITCOIN_CRYPTO_A
SAPLING_A
rustzcash
bls
${Boost_LIBRARIES} ${LIBEVENT_LIB} ${sodium_LIBRARY_RELEASE} -ldl pthread
)
if($ENV{target} MATCHES "Windows")
Expand All @@ -500,14 +510,15 @@ if($ENV{target} MATCHES "Windows")
list(APPEND pivx-tx_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/pivx-tx-res.rc)
endif()
add_executable(pivx-tx ${pivx-tx_SOURCES})
add_dependencies(pivx-tx libunivalue libsecp256k1 libzcashrust)
add_dependencies(pivx-tx libunivalue libsecp256k1 libzcashrust bls)
target_link_libraries(pivx-tx
univalue
COMMON_A
ZEROCOIN_A
UTIL_A
BITCOIN_CRYPTO_A
secp256k1
bls
SAPLING_A
rustzcash
${Boost_LIBRARIES} ${LIBEVENT_LIB} ${sodium_LIBRARY_RELEASE} ${GMP_LIBRARY} -ldl pthread
Expand All @@ -524,7 +535,7 @@ if($ENV{target} MATCHES "Windows")
list(APPEND pivxd_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/pivxd-res.rc)
endif()
add_executable(pivxd ${pivxd_SOURCES} ${BitcoinHeaders})
add_dependencies(pivxd libunivalue libsecp256k1 libzcashrust leveldb crc32c)
add_dependencies(pivxd libunivalue libsecp256k1 libzcashrust leveldb crc32c bls)
target_include_directories(pivxd PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/leveldb
${CMAKE_CURRENT_SOURCE_DIR}/src/leveldb/include
Expand All @@ -544,6 +555,7 @@ target_link_libraries(pivxd
leveldb
crc32c
secp256k1
bls
rustzcash
${BerkeleyDB_LIBRARIES} ${Boost_LIBRARIES} ${LIBEVENT_LIB} ${GMP_LIBRARY} pthread
)
Expand Down
6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,8 @@ if test x$need_bundled_univalue = xyes; then
AC_CONFIG_SUBDIRS([src/univalue])
fi

AC_CONFIG_SUBDIRS([src/chiabls])

ac_configure_args="${ac_configure_args} --disable-shared --with-pic --with-bignum=no --enable-module-recovery --disable-jni"
AC_CONFIG_SUBDIRS([src/secp256k1])

Expand All @@ -1614,6 +1616,10 @@ case ${OS} in
;;
esac

dnl Remove conflicting preprocessor defines from relic configuration header
sed -i.old '/PACKAGE/d' src/chiabls/contrib/relic/include/relic_conf.h
sed -i.old '/#define VERSION/d' src/chiabls/contrib/relic/include/relic_conf.h

echo
echo "Options used to compile and link:"
echo " with wallet = $enable_wallet"
Expand Down
4 changes: 3 additions & 1 deletion contrib/cmake/FindSodium.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ if(sodium_USE_STATIC_LIBS)
else()
set(_LIB_TYPE SHARED)
endif()
add_library(sodium ${_LIB_TYPE} IMPORTED)
if(NOT TARGET sodium)
add_library(sodium ${_LIB_TYPE} IMPORTED)
endif()

set_target_properties(sodium PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${sodium_INCLUDE_DIR}"
Expand Down
19 changes: 14 additions & 5 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

DIST_SUBDIRS = secp256k1 univalue
DIST_SUBDIRS = secp256k1 univalue chiabls

AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS)
AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS)
Expand All @@ -24,6 +24,8 @@ BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAG

BITCOIN_INCLUDES += -I$(srcdir)/rust/include
BITCOIN_INCLUDES += -I$(srcdir)/secp256k1/include
BITCOIN_INCLUDES += -I$(srcdir)/chiabls/src
BITCOIN_INCLUDES += -I$(srcdir)/chiabls/contrib/relic/include
BITCOIN_INCLUDES += $(UNIVALUE_CFLAGS)

LIBBITCOIN_SERVER=libbitcoin_server.a
Expand All @@ -35,6 +37,7 @@ LIBBITCOIN_ZEROCOIN=libzerocoin/libbitcoin_zerocoin.a
LIBBITCOINQT=qt/libbitcoinqt.a
LIBSECP256K1=secp256k1/libsecp256k1.la
LIBSAPLING=libsapling.a
LIBCHIABLS=chiabls/libchiabls.la
if ENABLE_ONLINE_RUST
LIBRUSTZCASH=$(top_builddir)/target/release/librustzcash.a
else
Expand All @@ -51,6 +54,8 @@ if ENABLE_WALLET
LIBBITCOIN_WALLET=libbitcoin_wallet.a
endif

BLS_LIBS = $(LIBCHIABLS)

RUST_ENV_VARS = RUSTC="$(RUSTC)" TERM=dumb
RUST_BUILD_OPTS = --release

Expand Down Expand Up @@ -96,6 +101,9 @@ endif
$(LIBSECP256K1): $(wildcard secp256k1/src/*.h) $(wildcard secp256k1/src/*.c) $(wildcard secp256k1/include/*)
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)

$(LIBCHIABLS):
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C chiabls

# Make is not made aware of per-object dependencies to avoid limiting building parallelization
# But to build the less dependent modules first, we manually select their order here:
EXTRA_LIBRARIES += \
Expand Down Expand Up @@ -629,7 +637,7 @@ pivxd_LDADD = \
$(LIBRUSTZCASH) \
$(LIBZCASH_LIBS)

pivxd_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS)
pivxd_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) $(BLS_LIBS)

# pivx-cli binary #
pivx_cli_SOURCES = pivx-cli.cpp
Expand All @@ -650,7 +658,7 @@ pivx_cli_LDADD = \
$(LIBRUSTZCASH) \
$(LIBZCASH_LIBS)

pivx_cli_LDADD += $(BOOST_LIBS) $(EVENT_LIBS)
pivx_cli_LDADD += $(BOOST_LIBS) $(EVENT_LIBS) $(BLS_LIBS)
#

# pivx-tx binary #
Expand All @@ -674,7 +682,7 @@ pivx_tx_LDADD = \
$(LIBRUSTZCASH) \
$(LIBZCASH_LIBS)

pivx_tx_LDADD += $(BOOST_LIBS)
pivx_tx_LDADD += $(BOOST_LIBS) $(BLS_LIBS)
#

# bitcoinconsensus library #
Expand Down Expand Up @@ -702,7 +710,7 @@ if GLIBC_BACK_COMPAT
endif

libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1)
libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1) $(BLS_LIBS)
libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
libbitcoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)

Expand Down Expand Up @@ -758,6 +766,7 @@ $(top_srcdir)/$(subdir)/config/pivx-config.h.in: $(am__configure_deps)
clean-local:
-$(MAKE) -C secp256k1 clean
-$(MAKE) -C univalue clean
-$(MAKE) -C chiabls clean
-rm -f leveldb/*/*.gcda leveldb/*/*.gcno leveldb/helpers/memenv/*.gcda leveldb/helpers/memenv/*.gcno
-rm -f config.h
-rm -rf test/__pycache__
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.bench.include
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if ENABLE_ZMQ
bench_bench_pivx_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
endif

bench_bench_pivx_LDADD += $(LIBBITCOIN_CONSENSUS) $(BOOST_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
bench_bench_pivx_LDADD += $(LIBBITCOIN_CONSENSUS) $(BOOST_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(BLS_LIBS)
bench_bench_pivx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)

CLEAN_BITCOIN_BENCH = bench/*.gcda bench/*.gcno $(GENERATED_BENCH_FILES)
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ qt_pivx_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
endif
qt_pivx_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBBITCOIN_ZEROCOIN) $(LIBSAPLING) $(LIBRUSTZCASH) $(LIBZCASH_LIBS) $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) \
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(SVG_LIBS) $(CHARTS_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(LIBSECP256K1) \
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(BLS_LIBS)
qt_pivx_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
qt_pivx_qt_LIBTOOLFLAGS = $(AM_LIBTOOLFLAGS) --tag CXX

Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.qttest.include
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ endif
qt_test_test_pivx_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBBITCOIN_ZEROCOIN) $(LIBLEVELDB) $(LIBSAPLING) $(LIBRUSTZCASH) $(LIBZCASH_LIBS) \
$(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \
$(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(LIBSECP256K1) \
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(BLS_LIBS)
qt_test_test_pivx_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
qt_test_test_pivx_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS)

Expand Down
5 changes: 3 additions & 2 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ test_test_pivx_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMM

test_test_pivx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)

test_test_pivx_LDADD += $(LIBRUSTZCASH) $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(LIBZCASH_LIBS)
test_test_pivx_LDADD += $(LIBRUSTZCASH) $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(LIBZCASH_LIBS) $(BLS_LIBS)
test_test_pivx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static

if ENABLE_ZMQ
Expand All @@ -202,7 +202,7 @@ if ENABLE_ZMQ
test_test_pivx_fuzzy_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
endif
test_test_pivx_fuzzy_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_ZEROCOIN) $(LIBBITCOIN_UTIL) $(LIBUNIVALUE) \
$(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS)
$(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) $(BLS_LIBS)
if ENABLE_WALLET
test_test_pivx_fuzzy_LDADD += $(LIBBITCOIN_WALLET)
endif
Expand Down Expand Up @@ -400,6 +400,7 @@ check-standard: $(BITCOIN_TESTS:.cpp=.cpp.test)
$(PYTHON) $(top_builddir)/test/util/bitcoin-util-test.py
@echo "Running test/util/rpcauth-test.py..."
$(PYTHON) $(top_builddir)/test/util/rpcauth-test.py
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C chiabls check
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
if EMBEDDED_UNIVALUE
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
Expand Down
17 changes: 17 additions & 0 deletions src/chiabls/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
BasedOnStyle: Google
UseTab: Never
ColumnLimit: 80
IndentWidth: 4
TabWidth: 4
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
AccessModifierOffset: -4
BinPackArguments: false
BinPackParameters: false
AlignAfterOpenBracket: AlwaysBreak
IndentCaseLabels: true
AllowAllParametersOfDeclarationOnNextLine: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
PenaltyReturnTypeOnItsOwnLine: 1000
4 changes: 4 additions & 0 deletions src/chiabls/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 120
exclude = ./typings/**/* python-impl/fields.py
ignore = E203,W503,E501
Loading

0 comments on commit 1e4fa87

Please sign in to comment.