Skip to content

Commit

Permalink
Auto merge of #4739 - str4d:update-leveldb, r=str4d
Browse files Browse the repository at this point in the history
Update LevelDB to upstream commit f545dfabf

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7911
- bitcoin/bitcoin#7982
- bitcoin/bitcoin#8133
- bitcoin/bitcoin#8784
  - Only the missing changes.
- bitcoin/bitcoin#8826
- bitcoin/bitcoin#8613
- bitcoin/bitcoin#10544
- bitcoin/bitcoin#10633
  - Only the changes to files and code we have.
- bitcoin/bitcoin#10806
- bitcoin/bitcoin#10958
- bitcoin/bitcoin#12451
- bitcoin/bitcoin#13925
- bitcoin/bitcoin#15270

This upgrades LevelDB in the exact same commit progression as upstream, up to January 2019.
  • Loading branch information
zkbot committed Sep 25, 2020
2 parents e886263 + f4c78c4 commit 514d868
Show file tree
Hide file tree
Showing 90 changed files with 3,678 additions and 1,622 deletions.
10 changes: 0 additions & 10 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,8 @@ COVERAGE_INFO = baseline_filtered_combined.info baseline.info \
zcash-gtest.info zcash-gtest_filtered.info zcash-gtest_coverage.info

dist-hook:
-$(MAKE) -C $(top_distdir)/src/leveldb clean
-$(MAKE) -C $(top_distdir)/src/secp256k1 distclean
-$(GIT) archive --format=tar HEAD -- src/clientversion.cpp | $(AMTAR) -C $(top_distdir) -xf -

distcheck-hook:
$(MKDIR_P) $(top_distdir)/_build/src/leveldb
cp -rf $(top_srcdir)/src/leveldb/* $(top_distdir)/_build/src/leveldb/
-$(MAKE) -C $(top_distdir)/_build/src/leveldb clean

distcleancheck:
@:

$(if $(findstring src/,$(MAKECMDGOALS)),$(MAKECMDGOALS), none): FORCE
$(MAKE) -C src $(patsubst src/%,%,$@)

Expand Down
39 changes: 36 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,36 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
AX_CHECK_COMPILE_FLAG([-Wself-assign],[CXXFLAGS="$CXXFLAGS -Wno-self-assign"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wdeprecated-register],[CXXFLAGS="$CXXFLAGS -Wno-deprecated-register"],,[[$CXXFLAG_WERROR]])

# Check for optional instruction set support. Enabling these does _not_ imply that all code will
# be compiled with them, rather that specific objects/libs may use them after checking for runtime
# compatibility.
AX_CHECK_COMPILE_FLAG([-msse4.2],[[SSE42_CXXFLAGS="-msse4.2"]],,[[$CXXFLAG_WERROR]])

fi

TEMP_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $SSE42_CXXFLAGS"
AC_MSG_CHECKING(for assembler crc32 support)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdint.h>
#if defined(_MSC_VER)
#include <intrin.h>
#elif defined(__GNUC__) && defined(__SSE4_2__)
#include <nmmintrin.h>
#endif
]],[[
uint64_t l = 0;
l = _mm_crc32_u8(l, 0);
l = _mm_crc32_u32(l, 0);
l = _mm_crc32_u64(l, 0);
return l;
]])],
[ AC_MSG_RESULT(yes); enable_hwcrc32=yes],
[ AC_MSG_RESULT(no)]
)
CXXFLAGS="$TEMP_CXXFLAGS"

CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"

AC_ARG_WITH([utils],
Expand Down Expand Up @@ -356,7 +385,7 @@ case $host in
fi

CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB"
LEVELDB_TARGET_FLAGS="TARGET_OS=OS_WINDOWS_CROSSCOMPILE"
LEVELDB_TARGET_FLAGS="-DOS_WINDOWS"
if test "x$CXXFLAGS_overridden" = "xno"; then
CXXFLAGS="$CXXFLAGS -w"
fi
Expand All @@ -378,7 +407,7 @@ case $host in
;;
*darwin*)
TARGET_OS=darwin
LEVELDB_TARGET_FLAGS="TARGET_OS=Darwin"
LEVELDB_TARGET_FLAGS="-DOS_MACOSX"
if test x$cross_compiling != xyes; then
BUILD_OS=darwin
AC_CHECK_PROG([PORT],port, port)
Expand Down Expand Up @@ -435,9 +464,11 @@ case $host in
OBJCXXFLAGS="$CXXFLAGS"
;;
*linux*)
TARGET_OS=linux
LEVELDB_TARGET_FLAGS="-DOS_LINUX"
;;
*)
OTHER_OS=`echo ${host_os} | awk '{print toupper($0)}'`
LEVELDB_TARGET_FLAGS="-DOS_${OTHER_OS}"
;;
esac

Expand Down Expand Up @@ -893,6 +924,7 @@ AM_CONDITIONAL([ENABLE_BENCH],[test x$use_bench = xyes])
AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes])
AM_CONDITIONAL([ENABLE_HWCRC32],[test x$enable_hwcrc32 = xyes])

AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
Expand Down Expand Up @@ -925,6 +957,7 @@ AC_SUBST(PIC_FLAGS)
AC_SUBST(PIE_FLAGS)
AC_SUBST(SANITIZER_CXXFLAGS)
AC_SUBST(SANITIZER_LDFLAGS)
AC_SUBST(SSE42_CXXFLAGS)
AC_SUBST(LIBTOOL_APP_LDFLAGS)
AC_SUBST(BOOST_LIBS)
AC_SUBST(TESTDEFS)
Expand Down
22 changes: 11 additions & 11 deletions qa/rpc-tests/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def run_test(self):
n = vout['n']


######################################
# GETUTXOS: query a unspent outpoint #
######################################
#######################################
# GETUTXOS: query an unspent outpoint #
#######################################
json_request = '/checkmempool/'+txid+'-'+str(n)
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
Expand All @@ -109,9 +109,9 @@ def run_test(self):
assert_equal(json_obj['utxos'][0]['value'], 0.1)


################################################
# GETUTXOS: now query a already spent outpoint #
################################################
#################################################
# GETUTXOS: now query an already spent outpoint #
#################################################
json_request = '/checkmempool/'+vintx+'-0'
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
Expand Down Expand Up @@ -173,24 +173,24 @@ def run_test(self):
json_request = '/'+txid+'-'+str(n)
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
assert_equal(len(json_obj['utxos']), 0) # there should be a outpoint because it has just added to the mempool
assert_equal(len(json_obj['utxos']), 0) # there should be an outpoint because it has just added to the mempool

json_request = '/checkmempool/'+txid+'-'+str(n)
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
assert_equal(len(json_obj['utxos']), 1) # there should be a outpoint because it has just added to the mempool
assert_equal(len(json_obj['utxos']), 1) # there should be an outpoint because it has just added to the mempool

# do some invalid requests
json_request = '{"checkmempool'
response = http_post_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request, True)
assert_equal(response.status, 500) # must be a 500 because we send a invalid json request
assert_equal(response.status, 500) # must be a 500 because we send an invalid json request

json_request = '{"checkmempool'
response = http_post_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'bin', json_request, True)
assert_equal(response.status, 500) # must be a 500 because we send a invalid bin request
assert_equal(response.status, 500) # must be a 500 because we send an invalid bin request

response = http_post_call(url.hostname, url.port, '/rest/getutxos/checkmempool'+self.FORMAT_SEPARATOR+'bin', '', True)
assert_equal(response.status, 500) # must be a 500 because we send a invalid bin request
assert_equal(response.status, 500) # must be a 500 because we send an invalid bin request

# test limits
json_request = '/checkmempool/'
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/smartfees.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from decimal import Decimal, ROUND_DOWN

# Construct 2 trivial P2SH's and the ScriptSigs that spend them
# So we can create many many transactions without needing to spend
# So we can create many transactions without needing to spend
# time signing.
P2SH_1 = "2MySexEGVzZpRgNQ1JdjdP5bRETznm3roQ2" # P2SH of "OP_1 OP_DROP"
P2SH_2 = "2NBdpwq8Aoo1EEKEXPNrKvr5xQr3M9UfcZA" # P2SH of "OP_2 OP_DROP"
Expand Down
25 changes: 7 additions & 18 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,6 @@ AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_C
AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS)
EXTRA_LIBRARIES =

if EMBEDDED_LEVELDB
LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/include
LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/helpers/memenv
LIBLEVELDB += $(builddir)/leveldb/libleveldb.a
LIBMEMENV += $(builddir)/leveldb/libmemenv.a

# NOTE: This dependency is not strictly necessary, but without it make may try to build both in parallel, which breaks the LevelDB build system in a race
$(LIBLEVELDB): $(LIBMEMENV)

$(LIBLEVELDB) $(LIBMEMENV):
@echo "Building LevelDB ..." && $(MAKE) -C $(@D) $(@F) CXX="$(CXX)" \
CC="$(CC)" PLATFORM=$(TARGET_OS) AR="$(AR)" $(LEVELDB_TARGET_FLAGS) \
OPT="$(AM_CXXFLAGS) $(PIE_FLAGS) $(CXXFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -D__STDC_LIMIT_MACROS"
endif

BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config
BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS)

Expand Down Expand Up @@ -476,6 +461,7 @@ zcashd_LDADD = \
$(LIBZCASH) \
$(LIBRUSTZCASH) \
$(LIBLEVELDB) \
$(LIBLEVELDB_SSE42) \
$(LIBMEMENV) \
$(LIBSECP256K1)

Expand Down Expand Up @@ -593,15 +579,14 @@ CTAES_DIST += crypto/ctaes/ctaes.h
CTAES_DIST += crypto/ctaes/README.md
CTAES_DIST += crypto/ctaes/test.c

CLEANFILES = leveldb/libleveldb.a leveldb/libmemenv.a *.gcda *.gcno */*.gcno wallet/*/*.gcno
CLEANFILES = *.gcda *.gcno */*.gcno wallet/*/*.gcno

DISTCLEANFILES = obj/build.h

EXTRA_DIST = leveldb $(CTAES_DIST) rust
EXTRA_DIST = $(CTAES_DIST) rust

clean-local:
rm -f $(top_srcdir)/.cargo/config $(top_srcdir)/.cargo/.configured-for-*
-$(MAKE) -C leveldb clean
-$(MAKE) -C secp256k1 clean
-$(MAKE) -C univalue clean
rm -f leveldb/*/*.gcno leveldb/helpers/memenv/*.gcno
Expand Down Expand Up @@ -633,6 +618,10 @@ endif
@test -f $(PROTOC)
$(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(abspath $(<D) $<)

if EMBEDDED_LEVELDB
include Makefile.leveldb.include
endif

if ENABLE_TESTS
include Makefile.test.include
include Makefile.gtest.include
Expand Down
6 changes: 6 additions & 0 deletions src/Makefile.bench.include
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) 2020 The Zcash developers
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php .

bin_PROGRAMS += bench/bench_bitcoin
BENCH_SRCDIR = bench
BENCH_BINARY = bench/bench_bitcoin$(EXEEXT)
Expand Down Expand Up @@ -26,6 +31,7 @@ bench_bench_bitcoin_LDADD = \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CRYPTO) \
$(LIBLEVELDB) \
$(LIBLEVELDB_SSE42) \
$(LIBMEMENV) \
$(LIBSECP256K1) \
$(LIBZCASH) \
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.gtest.include
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ zcash_gtest_LDADD = \
$(LIBBITCOIN_CRYPTO) \
$(LIBUNIVALUE) \
$(LIBLEVELDB) \
$(LIBLEVELDB_SSE42) \
$(LIBMEMENV) \
$(LIBSECP256K1)

Expand Down
Loading

0 comments on commit 514d868

Please sign in to comment.