Skip to content

Commit

Permalink
Kernel: Implement PoC FFI
Browse files Browse the repository at this point in the history
Also add a C binary and a Python script to exercise it.
  • Loading branch information
TheCharlatan committed May 18, 2024
1 parent 058af75 commit c9779f3
Show file tree
Hide file tree
Showing 10 changed files with 2,804 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ src/bitcoin-node
src/bitcoin-tx
src/bitcoin-util
src/bitcoin-chainstate
src/bitcoin-chainstate_c
src/bitcoin-wallet
src/test/fuzz/fuzz
src/test/test_bitcoin
Expand Down Expand Up @@ -136,6 +137,7 @@ test/lint/test_runner/target/

/doc/doxygen/

libbitcoinkernel.pc
contrib/devtools/split-debug.sh

# Output from running db4 installation
Expand Down
5 changes: 5 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ endif
.PHONY: deploy FORCE
.INTERMEDIATE: $(COVERAGE_INFO)

if BUILD_BITCOIN_KERNEL_LIB
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libbitcoinkernel.pc
endif

BITCOIND_BIN=$(top_builddir)/src/$(BITCOIN_DAEMON_NAME)$(EXEEXT)
BITCOIN_QT_BIN=$(top_builddir)/src/qt/$(BITCOIN_GUI_NAME)$(EXEEXT)
BITCOIN_TEST_BIN=$(top_builddir)/src/test/$(BITCOIN_TEST_NAME)$(EXEEXT)
Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,10 @@ AC_MSG_RESULT($build_bitcoin_chainstate)

AM_CONDITIONAL([BUILD_BITCOIN_KERNEL_LIB], [test "$build_experimental_kernel_lib" != "no" && ( test "$build_experimental_kernel_lib" = "yes" || test "$build_bitcoin_chainstate" = "yes" )])

if test "$build_bitcoin_kernel_lib" = "yes"; then
AC_CONFIG_FILES([libbitcoinkernel.pc:libbitcoinkernel.pc.in])
fi

AC_LANG_POP

if test "$use_ccache" != "no"; then
Expand Down
10 changes: 10 additions & 0 deletions libbitcoinkernel.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

Name: @PACKAGE_NAME@ kernel library
Description: Library for the Bitcoin chain validation.
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lbitcoinkernel
Cflags: -I${includedir}
12 changes: 12 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ AM_LIBTOOLFLAGS = --preserve-dup-deps
PTHREAD_FLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)
EXTRA_LIBRARIES =

include_HEADERS =
lib_LTLIBRARIES =
noinst_LTLIBRARIES =

Expand Down Expand Up @@ -110,6 +111,7 @@ endif

if BUILD_BITCOIN_CHAINSTATE
bin_PROGRAMS += bitcoin-chainstate
bin_PROGRAMS += bitcoin-chainstate_c
endif

.PHONY: FORCE check-symbols check-security
Expand All @@ -124,6 +126,7 @@ BITCOIN_CORE_H = \
base58.h \
bech32.h \
bip324.h \
bitcoinkernel.h \
blockencodings.h \
blockfilter.h \
chain.h \
Expand Down Expand Up @@ -888,6 +891,13 @@ bitcoin_util_LDADD = \
$(LIBSECP256K1)
#

# bitcoin-chainstate C binary #
bitcoin_chainstate_c_SOURCES = bitcoin-chainstate.c
bitcoin_chainstate_c_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
bitcoin_chainstate_c_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
bitcoin_chainstate_c_LDFLAGS = $(RELDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(AM_LDFLAGS) $(PTHREAD_FLAGS)
bitcoin_chainstate_c_LDADD = $(LIBBITCOINKERNEL)

# bitcoin-chainstate binary #
bitcoin_chainstate_SOURCES = bitcoin-chainstate.cpp
bitcoin_chainstate_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
Expand All @@ -904,6 +914,7 @@ bitcoin_chainstate_LDADD += $(LIBSECP256K1)
# bitcoinkernel library #
if BUILD_BITCOIN_KERNEL_LIB
lib_LTLIBRARIES += $(LIBBITCOINKERNEL)
include_HEADERS += bitcoinkernel.h

libbitcoinkernel_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) $(PTHREAD_FLAGS)
libbitcoinkernel_la_LIBADD = $(LIBBITCOIN_CRYPTO) $(LIBLEVELDB) $(LIBMEMENV) $(LIBSECP256K1)
Expand Down Expand Up @@ -945,6 +956,7 @@ libbitcoinkernel_la_SOURCES = \
kernel/disconnected_transactions.cpp \
kernel/mempool_persist.cpp \
kernel/mempool_removal_reason.cpp \
bitcoin-chainstate-wrapper.cpp \
logging.cpp \
node/blockstorage.cpp \
node/chainstate.cpp \
Expand Down
Loading

0 comments on commit c9779f3

Please sign in to comment.