Skip to content

Commit f55246c

Browse files
committed
Merge branch 'rm_minisketch-28+k' into rm_historical_relnotes_from_dist
2 parents 1248d0d + 18043c4 commit f55246c

File tree

13 files changed

+206
-20
lines changed

13 files changed

+206
-20
lines changed

build-aux/m4/bitcoin_subdir_to_include.m4

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,48 @@ dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
dnl BITCOIN_SUBDIR_TO_INCLUDE([CPPFLAGS-VARIABLE-NAME],[SUBDIRECTORY-NAME],[HEADER-FILE])
66
dnl SUBDIRECTORY-NAME must end with a path separator
77
AC_DEFUN([BITCOIN_SUBDIR_TO_INCLUDE],[
8-
if test "$2" = ""; then
8+
m4_pushdef([_result_var],[$1])
9+
m4_pushdef([_rel_path],[$2])
10+
m4_pushdef([_header_file],[$3.h])
11+
if test "[]_rel_path" = ""; then
912
AC_MSG_RESULT([default])
1013
else
11-
echo "#include <$2$3.h>" >conftest.cpp
12-
newinclpath=`${CXXCPP} ${CPPFLAGS} -M conftest.cpp 2>/dev/null | [ tr -d '\\n\\r\\\\' | sed -e 's/^.*[[:space:]:]\(\/[^[:space:]]*\)]$3[\.h[[:space:]].*$/\1/' -e t -e d`]
14+
echo '[#]include <'"_rel_path"'/_header_file>' >conftest.cpp
15+
newinclpath=$(
16+
${CXXCPP} ${CPPFLAGS} -M conftest.cpp 2>/dev/null |
17+
${SED} -E m4_bpatsubsts([[
18+
:build_line
19+
# If the line doesn't end with a backslash, it is complete; go on to process it
20+
/\\$/!b have_complete_line
21+
# Otherwise, read the next line, and concatenate it to the current one with a space
22+
N
23+
s/\\\n/ /
24+
# Then go back and check for a trailing backslash again.
25+
t build_line
26+
27+
# When we get here, we have the completed line, with all continuations collapsed.
28+
:have_complete_line
29+
s/^[^:]*:[[:space:]]*(([^[:space:]\]|\\.)*[[:space:]])*(([^[:space:]\]|\\.)*)(\\|\\\\|\/)?]]patsubst(]_header_file[,[\.],[\\.])[[([[:space:]].*)?$/\3/
30+
# ^^^^^^^ The Make line begins with a target (which we don't care about)
31+
# ^^^^^^^^^^^^ Ignore any spaces following it
32+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Match any number of other dependencies
33+
# ^^^^^^^^^^^^^^^^^^^^^^ Match any path components for our dependency; note this is reference 3, which we are replacing with
34+
# ^^^^^^^^^^^^^ Accept the path ending in a backslash, a double-backslash (ie escaped), or a forward slash
35+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The filename must match exactly (periods are escaped, since a normal period matches any character in regex)
36+
# ^^^^^^^^^^^^^^^^^ Filename must be followed by a space, but after that we don't care; we still need to match it all so it gets replaced, however
37+
# Delete the line, but only if we failed to find the directory (t jumps past the d if we matched)
38+
t
39+
d
40+
]],[
41+
\s*\(#.*\)?$],[],[
42+
\(.*\)],[ -e '\1'])
43+
dnl ^^^^^^^^^^^^^^^^^^^^^^^ Deletes comments and processes sed expressions into -e arguments
44+
)
45+
1346
AC_MSG_RESULT([${newinclpath}])
1447
if test "${newinclpath}" != ""; then
15-
eval "$1=\"\$$1\"' -I${newinclpath}'"
48+
eval "_result_var=\"\$_result_var\"' -I${newinclpath}'"
1649
fi
1750
fi
51+
m4_popdef([_result_var],[_rel_path],[_header_file])
1852
])

ci/test/03_test_script.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ du -sh "${PREVIOUS_RELEASES_DIR}"
143143
if [[ $HOST = *-mingw32 ]]; then
144144
# Generate all binaries, so that they can be wrapped
145145
make "$MAKEJOBS" -C src/secp256k1 VERBOSE=1
146-
make "$MAKEJOBS" -C src minisketch/test.exe VERBOSE=1
147146
"${BASE_ROOT_DIR}/ci/test/wrap-wine.sh"
148147
fi
149148

configure.ac

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,68 @@ if test "$have_any_system" != "no"; then
10751075
AC_DEFINE([HAVE_SYSTEM], [1], [Define to 1 if std::system or ::wsystem is available.])
10761076
fi
10771077

1078+
dnl Check for leveldb, only if explicitly requested
1079+
LEVELDB_CPPFLAGS=
1080+
LIBLEVELDB=
1081+
LIBMEMENV=
1082+
AC_ARG_WITH([system-leveldb],
1083+
[AS_HELP_STRING([--with-system-leveldb],
1084+
[Build with system LevelDB (default is no; DANGEROUS; NOT SUPPORTED)])],
1085+
[system_leveldb=$withval],
1086+
[system_leveldb=no]
1087+
)
1088+
if test x$system_leveldb != xno; then
1089+
LEVELDB_CPPFLAGS=
1090+
AC_CHECK_LIB([leveldb],[main],[
1091+
LIBLEVELDB=-lleveldb
1092+
],[
1093+
AC_MSG_ERROR([leveldb library not found; using --with-system-leveldb is not supported anyway])
1094+
])
1095+
AC_CHECK_HEADER([leveldb/filter_policy.h],[],[
1096+
AC_MSG_ERROR([LevelDB headers not found; using --with-system-leveldb is not supported anyway])
1097+
])
1098+
AC_CHECK_HEADER([leveldb/helpers/memenv.h],[
1099+
AC_MSG_CHECKING([for memenv.h path])
1100+
BITCOIN_SUBDIR_TO_INCLUDE([LEVELDB_CPPFLAGS],[leveldb/helpers/],[memenv])
1101+
],[
1102+
AC_CHECK_HEADER([memenv.h],[],[
1103+
AC_MSG_ERROR([LevelDB headers not found; using --with-system-leveldb is not supported anyway])
1104+
])
1105+
])
1106+
1107+
AC_MSG_CHECKING([library containing leveldb::NewMemEnv])
1108+
TEMP_LIBS="$LIBS"
1109+
TEMP_CPPFLAGS="$CPPFLAGS"
1110+
CPPFLAGS="$CPPFLAGS $LEVELDB_CPPFLAGS"
1111+
for searchlib in "" "-lmemenv" ERR; do
1112+
if test "x$searchlib" = "xERR"; then
1113+
AC_MSG_RESULT([no])
1114+
AC_MSG_ERROR([LevelDB's memenv helper not found; using --with-system-leveldb is not supported anyway])
1115+
fi
1116+
searchlib="$searchlib $LIBLEVELDB"
1117+
LIBS="$searchlib $TEMP_LIBS"
1118+
AC_LINK_IFELSE([AC_LANG_SOURCE([
1119+
#include <leveldb/env.h>
1120+
#include <memenv.h>
1121+
1122+
int main() {
1123+
leveldb::Env *myenv = leveldb::NewMemEnv(leveldb::Env::Default());
1124+
delete myenv;
1125+
}
1126+
])],[
1127+
AC_MSG_RESULT([$searchlib])
1128+
LIBMEMENV="$searchlib"
1129+
break
1130+
])
1131+
done
1132+
LIBS="$TEMP_LIBS"
1133+
CPPFLAGS="$TEMP_CPPFLAGS"
1134+
fi
1135+
AM_CONDITIONAL([EMBEDDED_LEVELDB],[test x$system_leveldb = xno])
1136+
AC_SUBST(LEVELDB_CPPFLAGS)
1137+
AC_SUBST(LIBLEVELDB)
1138+
AC_SUBST(LIBMEMENV)
1139+
10781140
dnl SUPPRESSED_CPPFLAGS=SUPPRESS_WARNINGS([$SOME_CPPFLAGS])
10791141
dnl Replace -I with -isystem in $SOME_CPPFLAGS to suppress warnings from
10801142
dnl headers from its include directories and return the result.

contrib/guix/libexec/build.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ GIT_ARCHIVE="${DIST_ARCHIVE_BASE}/${DISTNAME}.tar.gz"
196196
# Create the source tarball if not already there
197197
if [ ! -e "$GIT_ARCHIVE" ]; then
198198
mkdir -p "$(dirname "$GIT_ARCHIVE")"
199-
git archive --prefix="${DISTNAME}/" --output="$GIT_ARCHIVE" HEAD
199+
CONFIG_SITE="${BASEPREFIX}/${HOST}/share/config.site" \
200+
contrib/guix/libexec/make_release_tarball.sh "${GIT_ARCHIVE}" "${DISTNAME}"
200201
fi
201202

202203
mkdir -p "$OUTDIR"
@@ -239,8 +240,6 @@ mkdir -p "$DISTSRC"
239240
# Extract the source tarball
240241
tar --strip-components=1 -xf "${GIT_ARCHIVE}"
241242

242-
./autogen.sh
243-
244243
# Configure this DISTSRC for $HOST
245244
# shellcheck disable=SC2086
246245
env CONFIG_SITE="${BASEPREFIX}/${HOST}/share/config.site" \
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
# Copyright (c) 2020 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
#
6+
# A helper script to generate source release tarball
7+
8+
export LC_ALL=C
9+
set -ex
10+
11+
[ "$#" -ge 2 ]
12+
13+
GIT_ARCHIVE="$1"
14+
DISTNAME="$2"
15+
16+
git archive --prefix="${DISTNAME}/" HEAD | tar -xp --exclude '*minisketch*'
17+
18+
# Generate correct build info file from git, before we lose git
19+
GIT_BUILD_INFO="$(share/genbuild.sh /dev/stdout)"
20+
sed 's/\/\/ No build information available/'"${GIT_BUILD_INFO}"'/' -i "${DISTNAME}/share/genbuild.sh"
21+
22+
cd "${DISTNAME}"
23+
24+
./autogen.sh
25+
./configure --prefix=/ --disable-ccache --disable-maintainer-mode --disable-dependency-tracking
26+
make distclean
27+
28+
cd ..
29+
tar \
30+
--format=ustar \
31+
--exclude autom4te.cache \
32+
--exclude .deps \
33+
--exclude .git \
34+
--sort=name \
35+
--mode='u+rw,go+r-w,a+X' --owner=0 --group=0 \
36+
--mtime="${REFERENCE_DATETIME}" \
37+
-c "${DISTNAME}" | \
38+
gzip -9n \
39+
>"${GIT_ARCHIVE}"
40+
41+
rm -rf "${DISTNAME}"

share/genbuild.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ else
1818
exit 1
1919
fi
2020

21+
# This checks that we are actually part of the intended git repository, and not just getting info about some unrelated git repository that the code happens to be in a directory under
22+
git_check_in_repo() {
23+
! { git status --porcelain -uall --ignored "$@" 2>/dev/null || echo '??'; } | grep -q '?'
24+
}
25+
2126
GIT_TAG=""
2227
GIT_COMMIT=""
23-
if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
28+
if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo share/genbuild.sh; then
2429
# clean 'dirty' status of touched files that haven't been modified
2530
git diff >/dev/null 2>/dev/null
2631

@@ -40,7 +45,9 @@ if [ -n "$GIT_TAG" ]; then
4045
elif [ -n "$GIT_COMMIT" ]; then
4146
NEWINFO="#define BUILD_GIT_COMMIT \"$GIT_COMMIT\""
4247
else
43-
NEWINFO="// No build information available"
48+
# NOTE: The NEWINFO line below this comment gets replaced by a string-match in contrib/guix/libexec/make_release_tarball.sh
49+
# If changing it, update the script too!
50+
NEWINFO='// No build information available'
4451
fi
4552

4653
# only update build.h if necessary

src/Makefile.am

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ BITCOIN_CORE_H = \
231231
node/mempool_persist_args.h \
232232
node/miner.h \
233233
node/mini_miner.h \
234-
node/minisketchwrapper.h \
235234
node/peerman_args.h \
236235
node/protocol_version.h \
237236
node/psbt.h \
@@ -436,7 +435,6 @@ libbitcoin_node_a_SOURCES = \
436435
node/mempool_persist_args.cpp \
437436
node/miner.cpp \
438437
node/mini_miner.cpp \
439-
node/minisketchwrapper.cpp \
440438
node/peerman_args.cpp \
441439
node/psbt.cpp \
442440
node/timeoffsets.cpp \
@@ -1108,10 +1106,10 @@ endif
11081106
echo "};"; \
11091107
} > "$@.new" && mv -f "$@.new" "$@"
11101108

1111-
include Makefile.minisketch.include
1112-
1109+
if EMBEDDED_LEVELDB
11131110
include Makefile.crc32c.include
11141111
include Makefile.leveldb.include
1112+
endif
11151113

11161114
include Makefile.test_util.include
11171115
include Makefile.test_fuzz.include

src/Makefile.leveldb.include

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ LIBMEMENV_INT = leveldb/libmemenv.la
88
noinst_LTLIBRARIES += $(LIBLEVELDB_INT)
99
noinst_LTLIBRARIES += $(LIBMEMENV_INT)
1010

11-
LIBLEVELDB = $(LIBLEVELDB_INT) $(LIBCRC32C)
12-
LIBMEMENV = $(LIBMEMENV_INT)
11+
LIBLEVELDB += $(LIBLEVELDB_INT) $(LIBCRC32C)
12+
LIBMEMENV += $(LIBMEMENV_INT)
1313

14-
LEVELDB_CPPFLAGS =
1514
LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/include
15+
LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/helpers/memenv
1616

1717
LEVELDB_CPPFLAGS_INT =
1818
LEVELDB_CPPFLAGS_INT += -I$(srcdir)/leveldb

src/Makefile.test.include

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ BITCOIN_TESTS =\
114114
test/miner_tests.cpp \
115115
test/miniminer_tests.cpp \
116116
test/miniscript_tests.cpp \
117-
test/minisketch_tests.cpp \
118117
test/multisig_tests.cpp \
119118
test/net_peer_connection_tests.cpp \
120119
test/net_peer_eviction_tests.cpp \
@@ -343,7 +342,6 @@ test_fuzz_fuzz_SOURCES = \
343342
test/fuzz/merkleblock.cpp \
344343
test/fuzz/message.cpp \
345344
test/fuzz/miniscript.cpp \
346-
test/fuzz/minisketch.cpp \
347345
test/fuzz/mini_miner.cpp \
348346
test/fuzz/muhash.cpp \
349347
test/fuzz/multiplication_overflow.cpp \

src/dbwrapper.cpp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,26 @@
66

77
#include <logging.h>
88
#include <random.h>
9+
#include <node/interface_ui.h>
910
#include <serialize.h>
1011
#include <span.h>
1112
#include <streams.h>
1213
#include <util/fs.h>
1314
#include <util/fs_helpers.h>
1415
#include <util/strencodings.h>
16+
#include <util/translation.h>
1517

1618
#include <algorithm>
1719
#include <cassert>
1820
#include <cstdarg>
1921
#include <cstdint>
2022
#include <cstdio>
23+
#include <leveldb/c.h>
2124
#include <leveldb/cache.h>
2225
#include <leveldb/db.h>
2326
#include <leveldb/env.h>
2427
#include <leveldb/filter_policy.h>
25-
#include <leveldb/helpers/memenv/memenv.h>
28+
#include <memenv.h>
2629
#include <leveldb/iterator.h>
2730
#include <leveldb/options.h>
2831
#include <leveldb/slice.h>
@@ -51,6 +54,42 @@ static void HandleError(const leveldb::Status& status)
5154
throw dbwrapper_error(errmsg);
5255
}
5356

57+
bool dbwrapper_SanityCheck()
58+
{
59+
unsigned long header_version = (leveldb::kMajorVersion << 16) | leveldb::kMinorVersion;
60+
unsigned long library_version = (leveldb_major_version() << 16) | leveldb_minor_version();
61+
62+
if (header_version != library_version) {
63+
InitError(Untranslated(strprintf("Compiled with LevelDB %d.%d, but linked with LevelDB %d.%d (incompatible).",
64+
leveldb::kMajorVersion, leveldb::kMinorVersion,
65+
leveldb_major_version(), leveldb_minor_version()
66+
)));
67+
return false;
68+
}
69+
70+
return true;
71+
}
72+
73+
#ifndef WIN32
74+
namespace leveldb {
75+
class EnvPosixTestHelper {
76+
static void SetReadOnlyMMapLimit(int limit);
77+
public:
78+
static inline void SetReadOnlyMMapLimitForBitcoin(int limit) { SetReadOnlyMMapLimit(limit); }
79+
};
80+
}
81+
82+
class BitcoinLevelDBInit {
83+
public:
84+
BitcoinLevelDBInit() {
85+
if (sizeof(void*) >= 8) {
86+
leveldb::EnvPosixTestHelper::SetReadOnlyMMapLimitForBitcoin(4096);
87+
}
88+
}
89+
};
90+
static BitcoinLevelDBInit g_bitcoin_leveldb_init;
91+
#endif
92+
5493
class CBitcoinLevelDBLogger : public leveldb::Logger {
5594
public:
5695
// This code is adapted from posix_logger.h, which is why it is using vsprintf.

0 commit comments

Comments
 (0)