Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ not checks at all: return an error, `AbortNode()`, or `InitError()`.

Vendored or subtree-style code should normally be left alone:

- `src/{crc32c,dashbls,gsl,immer,leveldb,minisketch,secp256k1,univalue}`
- `src/{blst,crc32c,dashbls,gsl,immer,leveldb,minisketch,secp256k1,univalue}`
- `src/crypto/{ctaes,x11}`

`test/util/data/non-backported.txt` lists Dash-specific files used by Dash
Expand Down
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ LCOV_FILTER_PATTERN = \
-p "/usr/include/" \
-p "/usr/lib/" \
-p "/usr/lib64/" \
-p "src/blst/" \
-p "src/dashbls/" \
-p "src/immer/" \
-p "src/leveldb/" \
Expand Down
8 changes: 3 additions & 5 deletions ci/test/00_setup_env_native_msan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ LIBCXX_FLAGS="-nostdinc++ -nostdlib++ -isystem ${LIBCXX_DIR}include/c++/v1 -L${L
export MSAN_AND_LIBCXX_FLAGS="${MSAN_FLAGS} ${LIBCXX_FLAGS}"

# BDB generates false-positives and will be removed in future
# __BLST_NO_ASM__ makes blst use its C implementation instead of hand-written
# assembly, which MSan cannot see through.
export DEP_OPTS="DEBUG=1 NO_BDB=1 NO_QT=1 NO_UPNP=1 NO_NATPMP=1 CC=clang-19 CXX=clang++-19 CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}' CPPFLAGS='-D__BLST_NO_ASM__'"
export DEP_OPTS="DEBUG=1 NO_BDB=1 NO_QT=1 NO_UPNP=1 NO_NATPMP=1 CC=clang-19 CXX=clang++-19 CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
export GOAL="install"
# CC/CXX/CFLAGS/CXXFLAGS are repeated here rather than left to depends'
# config.site. Upstream dropped them in bitcoin#29800 because its
Expand All @@ -28,8 +26,8 @@ export GOAL="install"
# target whose compiler differs from the system default, so nothing else in
# Dash's CI exercises that hand-off.
# _FORTIFY_SOURCE is not compatible with MSAN.
# --with-asm=no keeps secp256k1 off hand-written assembly, which MSan cannot
# see through.
# --with-asm=no keeps secp256k1 and blst off hand-written assembly, which MSan
# cannot see through.
# --disable-mimalloc selects the plain malloc secure allocator; mimalloc seeds
# itself with a raw getrandom syscall before main(), which MSan cannot track.
export BITCOIN_CONFIG="--with-sanitizers=memory --with-gui=no --without-bdb --with-sqlite \
Expand Down
40 changes: 32 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ LT_PREREQ([2.4.2])
dnl Libtool init checks.
LT_INIT([pic-only win32-dll])

dnl Assembler for src/blst/build/assembly.S
AM_PROG_AS

dnl Check/return PATH for base programs.
AC_PATH_TOOL([AR], [ar])
AC_PATH_TOOL([GCOV], [gcov])
Expand Down Expand Up @@ -179,6 +182,13 @@ AC_ARG_ENABLE([mimalloc],
[use_mimalloc=$enableval],
[use_mimalloc=yes])

dnl Also passed on to secp256k1's configure, which accepts more values.
AC_ARG_WITH([asm],
[AS_HELP_STRING([--with-asm=no],
[build secp256k1 and blst without hand-written assembly (default is auto)])],
[use_asm=$withval],
[use_asm=auto])

AC_ARG_ENABLE(tests,
AS_HELP_STRING([--disable-tests],[do not compile tests (default is to compile)]),
[use_tests=$enableval],
Expand Down Expand Up @@ -1578,12 +1588,26 @@ if test "$use_natpmp" != "no"; then
CPPFLAGS="$TEMP_CPPFLAGS"
fi

dnl Check for blst (required by src/dashbls)
TEMP_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BLST_CPPFLAGS"
AC_CHECK_HEADERS([blst.h], [], [AC_MSG_ERROR([blst headers missing])])
AC_CHECK_LIB([blst], [blst_p1_compress], [BLST_LIBS="$BLST_LIBS -lblst"], [AC_MSG_ERROR([libblst missing])], [$BLST_LIBS])
CPPFLAGS="$TEMP_CPPFLAGS"
dnl src/blst ships assembly for x86_64 and aarch64 only. Like its build.sh,
dnl select the C implementation on every other target, or with --with-asm=no.
dnl The assembly is then left out entirely, as it would define the same symbols
dnl as the C implementation.
AC_LANG_PUSH([C])
AC_MSG_CHECKING([whether to use blst assembly])
use_blst_asm=no
if test "$use_asm" != "no"; then
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
#if (!defined(__x86_64__) && !defined(__aarch64__)) || defined(__BLST_NO_ASM__)
#error "blst assembly not used"
#endif
]])],
[use_blst_asm=yes])
fi
AC_MSG_RESULT([$use_blst_asm])
if test "$use_blst_asm" = "no"; then
BLST_CPPFLAGS_INT="-D__BLST_NO_ASM__"
fi
AC_LANG_POP([C])

if test "$build_bitcoin_wallet$build_bitcoin_cli$build_bitcoin_tx$build_bitcoin_util$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench$enable_fuzz_binary" = "nonononononononono"; then
use_boost=no
Expand Down Expand Up @@ -2018,6 +2042,7 @@ AM_CONDITIONAL([ENABLE_ARM_CRC], [test "$enable_arm_crc" = "yes"])
AM_CONDITIONAL([ENABLE_ARM_NEON], [test "$enable_arm_neon" = "yes"])
AM_CONDITIONAL([ENABLE_ARM_SHANI], [test "$enable_arm_shani" = "yes"])
AM_CONDITIONAL([WORDS_BIGENDIAN], [test "$ac_cv_c_bigendian" = "yes"])
AM_CONDITIONAL([USE_BLST_ASM], [test "$use_blst_asm" = "yes"])
AM_CONDITIONAL([USE_MIMALLOC], [test "$use_mimalloc" = "yes"])
AM_CONDITIONAL([USE_NATPMP], [test "$use_natpmp" = "yes"])
AM_CONDITIONAL([USE_UPNP], [test "$use_upnp" = "yes"])
Expand Down Expand Up @@ -2094,8 +2119,7 @@ AC_SUBST(MINIUPNPC_LIBS)
AC_SUBST(BACKTRACE_FLAGS)
AC_SUBST(BACKTRACE_LDFLAGS)
AC_SUBST(BACKTRACE_LIBS)
AC_SUBST(BLST_CPPFLAGS)
AC_SUBST(BLST_LIBS)
AC_SUBST(BLST_CPPFLAGS_INT)
AC_SUBST(NATPMP_CPPFLAGS)
AC_SUBST(NATPMP_LIBS)
AC_SUBST(DSYMUTIL_FLAT)
Expand Down
15 changes: 0 additions & 15 deletions contrib/containers/ci/ci.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@ RUN set -ex; \
zip \
&& rm -rf /var/lib/apt/lists/*

# No distribution packages blst, so builds that take their libraries from the
# system instead of depends (NO_DEPENDS=1) find it here.
# Keep the version in sync with depends/packages/blst.mk.
ARG BLST_VERSION=0.3.17
ARG BLST_SHA256=c3fef37b566b67419703b2bbb648e15176276af9a880c22aa8f5f2e8cecc2e4d
RUN set -ex; \
curl -fL "https://github.com/supranational/blst/archive/refs/tags/v${BLST_VERSION}.tar.gz" -o /tmp/blst.tar.gz; \
echo "${BLST_SHA256} /tmp/blst.tar.gz" | sha256sum -c -; \
mkdir /tmp/blst && tar -xzf /tmp/blst.tar.gz -C /tmp/blst --strip-components=1; \
cd /tmp/blst; \
CFLAGS="-O2 -fno-builtin -fPIC -D__BLST_PORTABLE__" ./build.sh; \
install -m 644 bindings/blst.h bindings/blst_aux.h /usr/local/include; \
install -m 644 libblst.a /usr/local/lib; \
cd / && rm -rf /tmp/blst /tmp/blst.tar.gz

# Native g++-11 already provides aarch64-linux-gnu-g++-11 on arm64, where noble
# has no g++-11-aarch64-linux-gnu cross package
RUN set -ex; \
Expand Down
1 change: 1 addition & 0 deletions contrib/devtools/copyright_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

EXCLUDE_DIRS = [
# git subtrees
"src/blst/",
"src/crc32c/",
"src/crypto/ctaes/",
"src/dashbls/",
Expand Down
29 changes: 0 additions & 29 deletions depends/packages/blst.mk

This file was deleted.

2 changes: 1 addition & 1 deletion depends/packages/packages.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
packages:=backtrace blst
packages:=backtrace

boost_packages = boost

Expand Down
7 changes: 0 additions & 7 deletions depends/patches/blst/no_asm_limbs.patch

This file was deleted.

1 change: 0 additions & 1 deletion doc/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ You can find installation instructions in the `build-*.md` file for your platfor
| --- | --- | --- | --- | --- |
| [Boost](../depends/packages/boost.mk) | [link](https://www.boost.org/users/download/) | 1.81.0 | [1.73.0](https://github.com/bitcoin/bitcoin/pull/29066) | No |
| [libevent](../depends/packages/libevent.mk) | [link](https://github.com/libevent/libevent/releases) | [2.1.12-stable](https://github.com/bitcoin/bitcoin/pull/21991) | [2.1.8](https://github.com/bitcoin/bitcoin/pull/24681) | No |
| [blst](../depends/packages/blst.mk) | [link](https://github.com/supranational/blst/releases) | 0.3.17 | | No |
| glibc | [link](https://www.gnu.org/software/libc/) | N/A | [2.31](https://github.com/bitcoin/bitcoin/pull/29987) | Yes |
| Linux Kernel | [link](https://www.kernel.org/) | N/A | [3.17.0](https://github.com/bitcoin/bitcoin/pull/27699) | Yes |

Expand Down
6 changes: 6 additions & 0 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,12 @@ Current subtrees include:
- src/dashbls
- Upstream at https://github.com/dashpay/bls-signatures ; maintained by Dash Core contributors.

- src/blst
- Upstream at https://github.com/supranational/blst ; maintained by Supranational. The BLS12-381
backend of src/dashbls, pulled from release tags with `git subtree pull --squash`.
- **Note**: Dash carries one local change, in `src/blst/src/vect.h`, so that its C implementation (selected by
`--with-asm=no`, as in the MSan build) also works on x86_64 and aarch64. Check that it survives each update.

- src/immer
- Upstream at https://github.com/arximboldi/immer ; provides the immutable containers used by the deterministic masternode list.

Expand Down
1 change: 1 addition & 0 deletions src/.bear-tidy-config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"include_only_existing_source": true,
"paths_to_include": [],
"paths_to_exclude": [
"src/blst",
"src/crc32c",
"src/crypto/ctaes",
"src/crypto/x11",
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1459,12 +1459,15 @@ CLEANFILES += wallet/*.gcda wallet/*.gcno
CLEANFILES += wallet/test/*.gcda wallet/test/*.gcno
CLEANFILES += zmq/*.gcda zmq/*.gcno
CLEANFILES += dashbls/src/*.gcda dashbls/src/*.gcno dashbls/depends/mimalloc/src/*.gcda dashbls/depends/mimalloc/src/*.gcno
CLEANFILES += blst/src/*.gcda blst/src/*.gcno blst/build/*.gcda blst/build/*.gcno
CLEANFILES += obj/build.h

IMMER_DIST = immer/immer
LIBDASHBLS_DIST = dashbls
BLST_DIST = blst/LICENSE blst/README.md blst/build blst/src

EXTRA_DIST = \
$(BLST_DIST) \
$(CTAES_DIST) \
$(IMMER_DIST) \
$(LIBDASHBLS_DIST)
Expand Down
39 changes: 36 additions & 3 deletions src/Makefile.dashbls.include
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

LIBDASHBLS_INT = dashbls/libdashbls.la
LIBBLST_INT = blst/libblst.la

noinst_LTLIBRARIES += $(LIBDASHBLS_INT)
noinst_LTLIBRARIES += $(LIBDASHBLS_INT) $(LIBBLST_INT)
if USE_MIMALLOC
LIBMIMALLOC_INT = dashbls/libmimalloc-secure.la
noinst_LTLIBRARIES += $(LIBMIMALLOC_INT)
endif

# What consumers link, dependents first: dashbls -> mimalloc -> blst (from depends)
LIBDASHBLS = $(LIBDASHBLS_INT) $(LIBMIMALLOC_INT) $(BLST_LIBS)
# What consumers link, dependents first: dashbls -> mimalloc -> blst
LIBDASHBLS = $(LIBDASHBLS_INT) $(LIBMIMALLOC_INT) $(LIBBLST_INT)

BLST_CPPFLAGS = -isystem$(srcdir)/blst/bindings

# Flags for consumers of the library
DASHBLS_CPPFLAGS = -isystem$(srcdir)/dashbls/include $(BLST_CPPFLAGS)
Expand Down Expand Up @@ -96,6 +99,22 @@ dashbls_libmimalloc_secure_la_CPPFLAGS = $(AM_CPPFLAGS) $(MIMALLOC_CPPFLAGS_INT)
dashbls_libmimalloc_secure_la_CFLAGS = $(AM_CFLAGS) $(PIE_FLAGS) -static
dashbls_libmimalloc_secure_la_LDFLAGS = $(AM_LDFLAGS) -static

# server.c #includes the rest of blst's C sources; assembly.S selects the
# assembly for the host. __BLST_PORTABLE__ picks the ADX code paths at runtime
# instead of from the builder's CPU, which keeps the build reproducible.
blst_libblst_la_SOURCES = \
blst/bindings/blst.h \
blst/bindings/blst_aux.h \
blst/src/server.c
if USE_BLST_ASM
blst_libblst_la_SOURCES += blst/build/assembly.S
endif

blst_libblst_la_CPPFLAGS = $(AM_CPPFLAGS) -D__BLST_PORTABLE__ $(BLST_CPPFLAGS_INT)
blst_libblst_la_CFLAGS = $(AM_CFLAGS) $(PIE_FLAGS) -fno-builtin -static
blst_libblst_la_CCASFLAGS = $(AM_CCASFLAGS) -static
blst_libblst_la_LDFLAGS = $(AM_LDFLAGS) -static

if ENABLE_TESTS
if !ENABLE_FUZZ
DASHBLS_RUNTEST = dashbls/runtest
Expand All @@ -113,3 +132,17 @@ dashbls_runtest_LDADD = $(LIBDASHBLS)
dashbls_runtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) -static
endif
endif

if ENABLE_BENCH
if !ENABLE_FUZZ
noinst_PROGRAMS += dashbls/runbench

dashbls_runbench_SOURCES = \
dashbls/src/test-bench.cpp \
dashbls/include/dashbls/test-utils.hpp
dashbls_runbench_CPPFLAGS = $(AM_CPPFLAGS) $(DASHBLS_CPPFLAGS_INT)
dashbls_runbench_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
dashbls_runbench_LDADD = $(LIBDASHBLS)
dashbls_runbench_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) -static
endif
endif
3 changes: 3 additions & 0 deletions src/blst/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pl linguist-language=assembly
*.h linguist-language=c
*.tgo linguist-language=go
Loading
Loading