mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #5974: backport: bitcoin#19522, #19809, #20993, #21075, #21126, #21138, #21221, #21354, #21542
005a6b104a
fix: format string in llmq/commitment - mismatched arguments (Konstantin Akimov)4774e1e8f6
Merge #19809: log: Prefix log messages with function name and source code location if -logsourcelocations is set (Wladimir J. van der Laan)43a94f0580
fix: adjust functional tests due to dash's support of thread name after v0.12 (Konstantin Akimov)085120d9f9
Merge #20993: test: store subversion (user agent) as string in msg_version (MarcoFalke)e866b43160
Merge #21542: ci: Bump macOS VM image to the latest version (fanquake)a3702534e5
Merge #21354: build, doc: Drop no longer required packages from macOS cross-compiling dependencies (fanquake)6bcc86ad3b
Merge #21221: [tools] Allow argument/parameter bin packing in clang-format (MarcoFalke)318c7263d0
Merge #19522: build: fix building libconsensus with reduced exports for Darwin targets (Wladimir J. van der Laan)88a45d4a9a
Merge #21138: ci: Re-run wine tests once if they fail (fanquake)4abb768456
Merge #21126: ci: Properly bump to focal for win cross build (fanquake)f254f77d75
Merge #21075: doc: Fix markdown formatting (MarcoFalke) Pull request description: ## Issue being fixed or feature implemented Regular backports from bitcoin v22 and related fixes ## What was done? Follow-up fixes for bitcoin#19809 Backports: - bitcoin/bitcoin#21075 - bitcoin/bitcoin#21126 - bitcoin/bitcoin#21138 - bitcoin/bitcoin#19522 - bitcoin/bitcoin#21221 - bitcoin/bitcoin#21354 - bitcoin/bitcoin#21542 - bitcoin/bitcoin#19809 - bitcoin/bitcoin#20993 ## How Has This Been Tested? Run unit/functional tests ## Breaking Changes N/A Notice, that function name is included now by default to logs with `-logfunctionnames` and many logs have function name twice now such as: ``` node0 2024-04-06T20:13:56.564123Z (mocktime: 2014-12-04T17:15:38Z) [httpworker.3] [masternode/sync.cpp:331] [NotifyHeaderTip] CMasternodeSync::NotifyHeaderTip -- pindexNew->nHeight: 5 fInitialDownload=0 ``` For further development need to take it in account and do not use more direct calls `__func__` from code as well as reduce usages in codebase. ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: PastaPastaPasta: utACK005a6b104a
Tree-SHA512: f98949c4605dda7d6dfe790554e1d31a8c8178b57520578fcd58178c68fe7af33c0d66a79865683c1357de9a73fa4f484eb828b28e11ca110b8e1915c1fcf9b3
This commit is contained in:
commit
54ea9260d4
@ -71,7 +71,7 @@ task:
|
||||
QEMU_USER_CMD: "" # Disable qemu and run the test natively
|
||||
|
||||
task:
|
||||
name: 'Win64 [unit tests, no gui tests, no boost::process, no functional tests] [bionic]'
|
||||
name: 'Win64 [unit tests, no gui tests, no boost::process, no functional tests] [focal]'
|
||||
<< : *GLOBAL_TASK_TEMPLATE
|
||||
container:
|
||||
image: ubuntu:focal
|
||||
@ -157,13 +157,13 @@ task:
|
||||
FILE_ENV: "./ci/test/00_setup_env_mac.sh"
|
||||
|
||||
task:
|
||||
name: 'macOS 10.15 native [gui] [no depends]'
|
||||
name: 'macOS 11 native [gui] [no depends]'
|
||||
macos_brew_addon_script:
|
||||
- brew install boost libevent berkeley-db4 qt miniupnpc ccache zeromq qrencode sqlite libtool automake pkg-config gnu-getopt
|
||||
<< : *GLOBAL_TASK_TEMPLATE
|
||||
macos_instance:
|
||||
# Use latest image, but hardcode version to avoid silent upgrades (and breaks)
|
||||
image: catalina-xcode-12.1 # https://cirrus-ci.org/guide/macOS
|
||||
image: big-sur-xcode-12.4 # https://cirrus-ci.org/guide/macOS
|
||||
env:
|
||||
DANGER_RUN_CI_ON_HOST: "true"
|
||||
CI_USE_APT_INSTALL: "no"
|
||||
|
@ -1,223 +0,0 @@
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE)
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro checks if the compiler supports one of GCC's function
|
||||
# attributes; many other compilers also provide function attributes with
|
||||
# the same syntax. Compiler warnings are used to detect supported
|
||||
# attributes as unsupported ones are ignored by default so quieting
|
||||
# warnings when using this macro will yield false positives.
|
||||
#
|
||||
# The ATTRIBUTE parameter holds the name of the attribute to be checked.
|
||||
#
|
||||
# If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_<ATTRIBUTE>.
|
||||
#
|
||||
# The macro caches its result in the ax_cv_have_func_attribute_<attribute>
|
||||
# variable.
|
||||
#
|
||||
# The macro currently supports the following function attributes:
|
||||
#
|
||||
# alias
|
||||
# aligned
|
||||
# alloc_size
|
||||
# always_inline
|
||||
# artificial
|
||||
# cold
|
||||
# const
|
||||
# constructor
|
||||
# constructor_priority for constructor attribute with priority
|
||||
# deprecated
|
||||
# destructor
|
||||
# dllexport
|
||||
# dllimport
|
||||
# error
|
||||
# externally_visible
|
||||
# flatten
|
||||
# format
|
||||
# format_arg
|
||||
# gnu_inline
|
||||
# hot
|
||||
# ifunc
|
||||
# leaf
|
||||
# malloc
|
||||
# noclone
|
||||
# noinline
|
||||
# nonnull
|
||||
# noreturn
|
||||
# nothrow
|
||||
# optimize
|
||||
# pure
|
||||
# unused
|
||||
# used
|
||||
# visibility
|
||||
# warning
|
||||
# warn_unused_result
|
||||
# weak
|
||||
# weakref
|
||||
#
|
||||
# Unsuppored function attributes will be tested with a prototype returning
|
||||
# an int and not accepting any arguments and the result of the check might
|
||||
# be wrong or meaningless so use with care.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2013 Gabriele Svelto <gabriele.svelto@gmail.com>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 3
|
||||
|
||||
AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [
|
||||
AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1])
|
||||
|
||||
AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([
|
||||
m4_case([$1],
|
||||
[alias], [
|
||||
int foo( void ) { return 0; }
|
||||
int bar( void ) __attribute__(($1("foo")));
|
||||
],
|
||||
[aligned], [
|
||||
int foo( void ) __attribute__(($1(32)));
|
||||
],
|
||||
[alloc_size], [
|
||||
void *foo(int a) __attribute__(($1(1)));
|
||||
],
|
||||
[always_inline], [
|
||||
inline __attribute__(($1)) int foo( void ) { return 0; }
|
||||
],
|
||||
[artificial], [
|
||||
inline __attribute__(($1)) int foo( void ) { return 0; }
|
||||
],
|
||||
[cold], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[const], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[constructor_priority], [
|
||||
int foo( void ) __attribute__((__constructor__(65535/2)));
|
||||
],
|
||||
[constructor], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[deprecated], [
|
||||
int foo( void ) __attribute__(($1("")));
|
||||
],
|
||||
[destructor], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[dllexport], [
|
||||
__attribute__(($1)) int foo( void ) { return 0; }
|
||||
],
|
||||
[dllimport], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[error], [
|
||||
int foo( void ) __attribute__(($1("")));
|
||||
],
|
||||
[externally_visible], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[flatten], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[format], [
|
||||
int foo(const char *p, ...) __attribute__(($1(printf, 1, 2)));
|
||||
],
|
||||
[format_arg], [
|
||||
char *foo(const char *p) __attribute__(($1(1)));
|
||||
],
|
||||
[gnu_inline], [
|
||||
inline __attribute__(($1)) int foo( void ) { return 0; }
|
||||
],
|
||||
[hot], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[ifunc], [
|
||||
int my_foo( void ) { return 0; }
|
||||
static int (*resolve_foo(void))(void) { return my_foo; }
|
||||
int foo( void ) __attribute__(($1("resolve_foo")));
|
||||
],
|
||||
[leaf], [
|
||||
__attribute__(($1)) int foo( void ) { return 0; }
|
||||
],
|
||||
[malloc], [
|
||||
void *foo( void ) __attribute__(($1));
|
||||
],
|
||||
[noclone], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[noinline], [
|
||||
__attribute__(($1)) int foo( void ) { return 0; }
|
||||
],
|
||||
[nonnull], [
|
||||
int foo(char *p) __attribute__(($1(1)));
|
||||
],
|
||||
[noreturn], [
|
||||
void foo( void ) __attribute__(($1));
|
||||
],
|
||||
[nothrow], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[optimize], [
|
||||
__attribute__(($1(3))) int foo( void ) { return 0; }
|
||||
],
|
||||
[pure], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[unused], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[used], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[visibility], [
|
||||
int foo_def( void ) __attribute__(($1("default")));
|
||||
int foo_hid( void ) __attribute__(($1("hidden")));
|
||||
int foo_int( void ) __attribute__(($1("internal")));
|
||||
int foo_pro( void ) __attribute__(($1("protected")));
|
||||
],
|
||||
[warning], [
|
||||
int foo( void ) __attribute__(($1("")));
|
||||
],
|
||||
[warn_unused_result], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[weak], [
|
||||
int foo( void ) __attribute__(($1));
|
||||
],
|
||||
[weakref], [
|
||||
static int foo( void ) { return 0; }
|
||||
static int bar( void ) __attribute__(($1("foo")));
|
||||
],
|
||||
[
|
||||
m4_warn([syntax], [Unsupported attribute $1, the test may fail])
|
||||
int foo( void ) __attribute__(($1));
|
||||
]
|
||||
)], [])
|
||||
],
|
||||
dnl GCC doesn't exit with an error if an unknown attribute is
|
||||
dnl provided but only outputs a warning, so accept the attribute
|
||||
dnl only if no warning were issued.
|
||||
[AS_IF([test -s conftest.err],
|
||||
[AS_VAR_SET([ac_var], [no])],
|
||||
[AS_VAR_SET([ac_var], [yes])])],
|
||||
[AS_VAR_SET([ac_var], [no])])
|
||||
])
|
||||
|
||||
AS_IF([test yes = AS_VAR_GET([ac_var])],
|
||||
[AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1,
|
||||
[Define to 1 if the system has the `$1' function attribute])], [])
|
||||
|
||||
AS_VAR_POPDEF([ac_var])
|
||||
])
|
@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
|
||||
|
||||
export CONTAINER_NAME=ci_macos_cross
|
||||
export HOST=x86_64-apple-darwin
|
||||
export PACKAGES="cmake libcap-dev libz-dev libbz2-dev libtinfo5 python3-setuptools"
|
||||
export PACKAGES="cmake libz-dev libtinfo5 python3-setuptools"
|
||||
export XCODE_VERSION=12.2
|
||||
export XCODE_BUILD_ID=12B45b
|
||||
export RUN_UNIT_TESTS=false
|
||||
|
@ -8,8 +8,8 @@ export LC_ALL=C.UTF-8
|
||||
|
||||
export CONTAINER_NAME=ci_win64
|
||||
export HOST=x86_64-w64-mingw32
|
||||
export PACKAGES="python3 nsis g++-mingw-w64-x86-64 wine-binfmt wine64 file"
|
||||
export DPKG_ADD_ARCH="i386"
|
||||
export PACKAGES="python3 nsis g++-mingw-w64-x86-64 wine-binfmt wine64 wine32 file"
|
||||
export RUN_FUNCTIONAL_TESTS=false
|
||||
export RUN_SECURITY_TESTS="false"
|
||||
export GOAL="deploy"
|
||||
|
@ -13,7 +13,7 @@ for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/univalue/{no_nul,
|
||||
echo "Wrap $b ..."
|
||||
mv "$b" "${b}_orig"
|
||||
echo '#!/usr/bin/env bash' > "$b"
|
||||
echo "wine64 \"${b}_orig\" \"\$@\"" >> "$b"
|
||||
echo "( wine \"${b}_orig\" \"\$@\" ) || ( sleep 1 && wine \"${b}_orig\" \"\$@\" )" >> "$b"
|
||||
chmod +x "$b"
|
||||
fi
|
||||
done
|
||||
|
37
configure.ac
37
configure.ac
@ -913,10 +913,6 @@ if test x$ac_cv_sys_large_files != x &&
|
||||
CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files"
|
||||
fi
|
||||
|
||||
AX_GCC_FUNC_ATTRIBUTE([visibility])
|
||||
AX_GCC_FUNC_ATTRIBUTE([dllexport])
|
||||
AX_GCC_FUNC_ATTRIBUTE([dllimport])
|
||||
|
||||
AC_SEARCH_LIBS([clock_gettime],[rt])
|
||||
|
||||
if test "x$enable_gprof" = xyes; then
|
||||
@ -1078,13 +1074,13 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
[ AC_MSG_RESULT(no)]
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING([for visibility attribute])
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([
|
||||
int foo_def( void ) __attribute__((visibility("default")));
|
||||
AC_MSG_CHECKING([for default visibility attribute])
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
int foo(void) __attribute__((visibility("default")));
|
||||
int main(){}
|
||||
])],
|
||||
[
|
||||
AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE,1,[Define if the visibility attribute is supported.])
|
||||
AC_DEFINE(HAVE_DEFAULT_VISIBILITY_ATTRIBUTE,1,[Define if the visibility attribute is supported.])
|
||||
AC_MSG_RESULT(yes)
|
||||
],
|
||||
[
|
||||
@ -1095,6 +1091,18 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([
|
||||
]
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING([for dllexport attribute])
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
__declspec(dllexport) int foo(void);
|
||||
int main(){}
|
||||
])],
|
||||
[
|
||||
AC_DEFINE(HAVE_DLLEXPORT_ATTRIBUTE,1,[Define if the dllexport attribute is supported.])
|
||||
AC_MSG_RESULT(yes)
|
||||
],
|
||||
[AC_MSG_RESULT(no)]
|
||||
)
|
||||
|
||||
if test "x$use_thread_local" = xyes || test "x$use_thread_local" = xauto; then
|
||||
TEMP_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="$TEMP_LDFLAGS $PTHREAD_CFLAGS"
|
||||
@ -1269,12 +1277,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
[ AC_MSG_RESULT(no); HAVE_STRONG_GETAUXVAL=0 ]
|
||||
)
|
||||
|
||||
dnl Check for reduced exports
|
||||
if test x$use_reduce_exports = xyes; then
|
||||
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"],
|
||||
[AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduce-exports.])])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for std::system])
|
||||
AC_LINK_IFELSE(
|
||||
[ AC_LANG_PROGRAM(
|
||||
@ -1486,9 +1488,11 @@ fi
|
||||
BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB"
|
||||
fi
|
||||
|
||||
dnl Check for reduced exports
|
||||
if test x$use_reduce_exports = xyes; then
|
||||
CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS"
|
||||
AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]], [RELDFLAGS="-Wl,--exclude-libs,ALL"],, [[$LDFLAG_WERROR]])
|
||||
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[CXXFLAGS="$CXXFLAGS -fvisibility=hidden"],
|
||||
[AC_MSG_ERROR([Cannot set hidden symbol visibility. Use --disable-reduce-exports.])],[[$CXXFLAG_WERROR]])
|
||||
AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]],[RELDFLAGS="-Wl,--exclude-libs,ALL"],,[[$LDFLAG_WERROR]])
|
||||
fi
|
||||
|
||||
if test x$use_tests = xyes; then
|
||||
@ -1951,6 +1955,7 @@ echo
|
||||
echo "Options used to compile and link:"
|
||||
echo " boost process = $with_boost_process"
|
||||
echo " multiprocess = $build_multiprocess"
|
||||
echo " with libs = $build_bitcoin_libs"
|
||||
echo " with wallet = $enable_wallet"
|
||||
echo " with gui / qt = $bitcoin_enable_qt"
|
||||
if test "x$enable_wallet" != "xno"; then
|
||||
|
@ -104,9 +104,7 @@ RUN apt-get update && apt-get install $APT_ARGS \
|
||||
g++-arm-linux-gnueabihf \
|
||||
g++-mingw-w64-x86-64 \
|
||||
jq \
|
||||
libcap-dev \
|
||||
libz-dev \
|
||||
libbz2-dev \
|
||||
libncurses5 \
|
||||
nsis \
|
||||
python3-zmq \
|
||||
|
@ -47,7 +47,7 @@ The paths are automatically configured and no other options are needed unless ta
|
||||
|
||||
#### For macOS cross compilation
|
||||
|
||||
sudo apt-get install curl bsdmainutils cmake libcap-dev libz-dev libbz2-dev python3-setuptools libtinfo5 xorriso
|
||||
sudo apt-get install curl bsdmainutils cmake libz-dev python3-setuptools libtinfo5 xorriso
|
||||
|
||||
Note: You must obtain the macOS SDK before proceeding with a cross-compile.
|
||||
Under the depends directory, create a subdirectory named `SDKs`.
|
||||
|
@ -9,7 +9,7 @@ Note
|
||||
Always use absolute paths to configure and compile Dash Core and the dependencies.
|
||||
For example, when specifying the path of the dependency:
|
||||
|
||||
../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX
|
||||
../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX
|
||||
|
||||
Here BDB_PREFIX must be an absolute path - it is defined using $(pwd) which ensures
|
||||
the usage of the absolute path.
|
||||
@ -227,9 +227,9 @@ Boost
|
||||
-----
|
||||
If you need to build Boost yourself:
|
||||
|
||||
sudo su
|
||||
./bootstrap.sh
|
||||
./bjam install
|
||||
sudo su
|
||||
./bootstrap.sh
|
||||
./bjam install
|
||||
|
||||
|
||||
Security
|
||||
@ -240,8 +240,8 @@ This can be disabled with:
|
||||
|
||||
Hardening Flags:
|
||||
|
||||
./configure --enable-hardening
|
||||
./configure --disable-hardening
|
||||
./configure --enable-hardening
|
||||
./configure --disable-hardening
|
||||
|
||||
|
||||
Hardening enables the following features:
|
||||
@ -256,7 +256,7 @@ Hardening enables the following features:
|
||||
|
||||
To test that you have built PIE executable, install scanelf, part of paxutils, and use:
|
||||
|
||||
scanelf -e ./dashd
|
||||
scanelf -e ./dashd
|
||||
|
||||
The output should contain:
|
||||
|
||||
@ -273,8 +273,8 @@ Hardening enables the following features:
|
||||
`scanelf -e ./dashd`
|
||||
|
||||
The output should contain:
|
||||
STK/REL/PTL
|
||||
RW- R-- RW-
|
||||
STK/REL/PTL
|
||||
RW- R-- RW-
|
||||
|
||||
The STK RW- means that the stack is readable and writeable but not executable.
|
||||
|
||||
|
18
doc/init.md
18
doc/init.md
@ -53,11 +53,11 @@ Paths
|
||||
|
||||
All three configurations assume several paths that might need to be adjusted.
|
||||
|
||||
Binary: `/usr/bin/dashd`
|
||||
Configuration file: `/etc/dashcore/dash.conf`
|
||||
Data directory: `/var/lib/dashd`
|
||||
PID file: `/var/run/dashd/dashd.pid` (OpenRC and Upstart) or `/run/dashd/dashd.pid` (systemd)
|
||||
Lock file: `/var/lock/subsys/dashd` (CentOS)
|
||||
Binary: /usr/bin/dashd
|
||||
Configuration file: /etc/dashcore/dash.conf
|
||||
Data directory: /var/lib/dashd
|
||||
PID file: /var/run/dashd/dashd.pid (OpenRC and Upstart) or /run/dashd/dashd.pid (systemd)
|
||||
Lock file: /var/lock/subsys/dashd (CentOS)
|
||||
|
||||
The PID directory (if applicable) and data directory should both be owned by the
|
||||
dashcore user and group. It is advised for security reasons to make the
|
||||
@ -83,10 +83,10 @@ OpenRC).
|
||||
|
||||
### macOS
|
||||
|
||||
Binary: `/usr/local/bin/dashd`
|
||||
Configuration file: `~/Library/Application Support/DashCore/dash.conf`
|
||||
Data directory: `~/Library/Application Support/DashCore`
|
||||
Lock file: `~/Library/Application Support/DashCore/.lock`
|
||||
Binary: /usr/local/bin/dashd
|
||||
Configuration file: ~/Library/Application Support/DashCore/dash.conf
|
||||
Data directory: ~/Library/Application Support/DashCore
|
||||
Lock file: ~/Library/Application Support/DashCore/.lock
|
||||
|
||||
Installing Service Configuration
|
||||
-----------------------------------
|
||||
|
104
doc/tor.md
104
doc/tor.md
@ -24,44 +24,44 @@ information in the debug log about your Tor configuration.
|
||||
The first step is running Dash Core behind a Tor proxy. This will already anonymize all
|
||||
outgoing connections, but more is possible.
|
||||
|
||||
-proxy=ip:port Set the proxy server. If SOCKS5 is selected (default), this proxy
|
||||
server will be used to try to reach .onion addresses as well.
|
||||
You need to use -noonion or -onion=0 to explicitly disable
|
||||
outbound access to onion services.
|
||||
-proxy=ip:port Set the proxy server. If SOCKS5 is selected (default), this proxy
|
||||
server will be used to try to reach .onion addresses as well.
|
||||
You need to use -noonion or -onion=0 to explicitly disable
|
||||
outbound access to onion services.
|
||||
|
||||
-onion=ip:port Set the proxy server to use for Tor onion services. You do not
|
||||
need to set this if it's the same as -proxy. You can use -onion=0
|
||||
to explicitly disable access to onion services.
|
||||
Note: Only the -proxy option sets the proxy for DNS requests;
|
||||
with -onion they will not route over Tor, so use -proxy if you
|
||||
have privacy concerns.
|
||||
-onion=ip:port Set the proxy server to use for Tor onion services. You do not
|
||||
need to set this if it's the same as -proxy. You can use -onion=0
|
||||
to explicitly disable access to onion services.
|
||||
Note: Only the -proxy option sets the proxy for DNS requests;
|
||||
with -onion they will not route over Tor, so use -proxy if you
|
||||
have privacy concerns.
|
||||
|
||||
-listen When using -proxy, listening is disabled by default. If you want
|
||||
to manually configure an onion service (see section 3), you'll
|
||||
need to enable it explicitly.
|
||||
-listen When using -proxy, listening is disabled by default. If you want
|
||||
to manually configure an onion service (see section 3), you'll
|
||||
need to enable it explicitly.
|
||||
|
||||
-connect=X When behind a Tor proxy, you can specify .onion addresses instead
|
||||
-addnode=X of IP addresses or hostnames in these parameters. It requires
|
||||
-seednode=X SOCKS5. In Tor mode, such addresses can also be exchanged with
|
||||
other P2P nodes.
|
||||
-connect=X When behind a Tor proxy, you can specify .onion addresses instead
|
||||
-addnode=X of IP addresses or hostnames in these parameters. It requires
|
||||
-seednode=X SOCKS5. In Tor mode, such addresses can also be exchanged with
|
||||
other P2P nodes.
|
||||
|
||||
-onlynet=onion Make outgoing connections only to .onion addresses. Incoming
|
||||
connections are not affected by this option. This option can be
|
||||
specified multiple times to allow multiple network types, e.g.
|
||||
ipv4, ipv6 or onion. If you use this option with values other
|
||||
than onion you *cannot* disable onion connections; outgoing onion
|
||||
connections will be enabled when you use -proxy or -onion. Use
|
||||
-noonion or -onion=0 if you want to be sure there are no outbound
|
||||
onion connections over the default proxy or your defined -proxy.
|
||||
-onlynet=onion Make outgoing connections only to .onion addresses. Incoming
|
||||
connections are not affected by this option. This option can be
|
||||
specified multiple times to allow multiple network types, e.g.
|
||||
ipv4, ipv6 or onion. If you use this option with values other
|
||||
than onion you *cannot* disable onion connections; outgoing onion
|
||||
connections will be enabled when you use -proxy or -onion. Use
|
||||
-noonion or -onion=0 if you want to be sure there are no outbound
|
||||
onion connections over the default proxy or your defined -proxy.
|
||||
|
||||
An example how to start the client if the Tor proxy is running on local host on
|
||||
port 9050 and only allows .onion nodes to connect:
|
||||
|
||||
./dashd -onion=127.0.0.1:9050 -onlynet=onion -listen=0 -addnode=ssapp53tmftyjmjb.onion
|
||||
./dashd -onion=127.0.0.1:9050 -onlynet=onion -listen=0 -addnode=ssapp53tmftyjmjb.onion
|
||||
|
||||
In a typical situation, this suffices to run behind a Tor proxy:
|
||||
|
||||
./dashd -proxy=127.0.0.1:9050
|
||||
./dashd -proxy=127.0.0.1:9050
|
||||
|
||||
## 2. Automatically create a Dash Core onion service
|
||||
|
||||
@ -162,57 +162,57 @@ reachable from the Tor network. Add these lines to your /etc/tor/torrc (or equiv
|
||||
config file): *Needed for Tor version 0.2.7.0 and older versions of Tor only. For newer
|
||||
versions of Tor see [Section 4](#4-automatically-listen-on-tor).*
|
||||
|
||||
HiddenServiceDir /var/lib/tor/dashcore-service/
|
||||
HiddenServicePort 9999 127.0.0.1:9996
|
||||
HiddenServiceDir /var/lib/tor/dashcore-service/
|
||||
HiddenServicePort 9999 127.0.0.1:9996
|
||||
|
||||
The directory can be different of course, but virtual port numbers should be equal to
|
||||
your dashd's P2P listen port (9999 by default), and target addresses and ports
|
||||
should be equal to binding address and port for inbound Tor connections (127.0.0.1:9996 by default).
|
||||
|
||||
-externalip=X You can tell Dash Core about its publicly reachable addresses using
|
||||
this option, and this can be an onion address. Given the above
|
||||
configuration, you can find your onion address in
|
||||
/var/lib/tor/dashcore-service/hostname. For connections
|
||||
coming from unroutable addresses (such as 127.0.0.1, where the
|
||||
Tor proxy typically runs), onion addresses are given
|
||||
preference for your node to advertise itself with.
|
||||
-externalip=X You can tell Dash Core about its publicly reachable addresses using
|
||||
this option, and this can be an onion address. Given the above
|
||||
configuration, you can find your onion address in
|
||||
/var/lib/tor/dashcore-service/hostname. For connections
|
||||
coming from unroutable addresses (such as 127.0.0.1, where the
|
||||
Tor proxy typically runs), onion addresses are given
|
||||
preference for your node to advertise itself with.
|
||||
|
||||
You can set multiple local addresses with -externalip. The
|
||||
one that will be rumoured to a particular peer is the most
|
||||
compatible one and also using heuristics, e.g. the address
|
||||
with the most incoming connections, etc.
|
||||
You can set multiple local addresses with -externalip. The
|
||||
one that will be rumoured to a particular peer is the most
|
||||
compatible one and also using heuristics, e.g. the address
|
||||
with the most incoming connections, etc.
|
||||
|
||||
-listen You'll need to enable listening for incoming connections, as this
|
||||
is off by default behind a proxy.
|
||||
-listen You'll need to enable listening for incoming connections, as this
|
||||
is off by default behind a proxy.
|
||||
|
||||
-discover When -externalip is specified, no attempt is made to discover local
|
||||
IPv4 or IPv6 addresses. If you want to run a dual stack, reachable
|
||||
from both Tor and IPv4 (or IPv6), you'll need to either pass your
|
||||
other addresses using -externalip, or explicitly enable -discover.
|
||||
Note that both addresses of a dual-stack system may be easily
|
||||
linkable using traffic analysis.
|
||||
-discover When -externalip is specified, no attempt is made to discover local
|
||||
IPv4 or IPv6 addresses. If you want to run a dual stack, reachable
|
||||
from both Tor and IPv4 (or IPv6), you'll need to either pass your
|
||||
other addresses using -externalip, or explicitly enable -discover.
|
||||
Note that both addresses of a dual-stack system may be easily
|
||||
linkable using traffic analysis.
|
||||
|
||||
In a typical situation, where you're only reachable via Tor, this should suffice:
|
||||
|
||||
./dashd -proxy=127.0.0.1:9050 -externalip=7zvj7a2imdgkdbg4f2dryd5rgtrn7upivr5eeij4cicjh65pooxeshid.onion -listen
|
||||
./dashd -proxy=127.0.0.1:9050 -externalip=7zvj7a2imdgkdbg4f2dryd5rgtrn7upivr5eeij4cicjh65pooxeshid.onion -listen
|
||||
|
||||
(obviously, replace the .onion address with your own). It should be noted that you still
|
||||
listen on all devices and another node could establish a clearnet connection, when knowing
|
||||
your address. To mitigate this, additionally bind the address of your Tor proxy:
|
||||
|
||||
./dashd ... -bind=127.0.0.1
|
||||
./dashd ... -bind=127.0.0.1
|
||||
|
||||
If you don't care too much about hiding your node, and want to be reachable on IPv4
|
||||
as well, use `discover` instead:
|
||||
|
||||
./dashd ... -discover
|
||||
./dashd ... -discover
|
||||
|
||||
and open port 9999 on your firewall (or use port mapping, i.e., `-upnp` or `-natpmp`).
|
||||
|
||||
If you only want to use Tor to reach .onion addresses, but not use it as a proxy
|
||||
for normal IPv4/IPv6 communication, use:
|
||||
|
||||
./dashd -onion=127.0.0.1:9050 -externalip=7zvj7a2imdgkdbg4f2dryd5rgtrn7upivr5eeij4cicjh65pooxeshid.onion -discover
|
||||
./dashd -onion=127.0.0.1:9050 -externalip=7zvj7a2imdgkdbg4f2dryd5rgtrn7upivr5eeij4cicjh65pooxeshid.onion -discover
|
||||
|
||||
|
||||
## 3.1. List of known Dash Core Tor relays
|
||||
|
@ -14,7 +14,7 @@ AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
BinPackArguments: true
|
||||
BinPackParameters: false
|
||||
BinPackParameters: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
|
@ -4,8 +4,11 @@
|
||||
|
||||
#include <batchedlogger.h>
|
||||
|
||||
CBatchedLogger::CBatchedLogger(BCLog::LogFlags _category, const std::string& _header) :
|
||||
accept(LogAcceptCategory(_category)), header(_header)
|
||||
CBatchedLogger::CBatchedLogger(BCLog::LogFlags _category, const std::string& logging_function, const std::string& source_file, int source_line) :
|
||||
accept(LogAcceptCategory(_category)),
|
||||
m_logging_function(logging_function),
|
||||
m_source_file(source_file),
|
||||
m_source_line(source_line)
|
||||
{
|
||||
}
|
||||
|
||||
@ -19,6 +22,6 @@ void CBatchedLogger::Flush()
|
||||
if (!accept || msg.empty()) {
|
||||
return;
|
||||
}
|
||||
LogInstance().LogPrintStr(strprintf("%s:\n%s", header, msg));
|
||||
LogInstance().LogPrintStr(msg, m_logging_function, m_source_file, m_source_line);
|
||||
msg.clear();
|
||||
}
|
||||
|
@ -11,10 +11,12 @@ class CBatchedLogger
|
||||
{
|
||||
private:
|
||||
bool accept;
|
||||
std::string header;
|
||||
std::string m_logging_function;;
|
||||
std::string m_source_file;
|
||||
const int m_source_line;
|
||||
std::string msg;
|
||||
public:
|
||||
CBatchedLogger(BCLog::LogFlags _category, const std::string& _header);
|
||||
CBatchedLogger(BCLog::LogFlags _category, const std::string& logging_function, const std::string& m_source_file, int m_source_line);
|
||||
virtual ~CBatchedLogger();
|
||||
|
||||
template<typename... Args>
|
||||
|
@ -719,6 +719,7 @@ void SetupServerArgs(NodeContext& node)
|
||||
argsman.AddArg("-debugexclude=<category>", strprintf("Exclude debugging information for a category. Can be used in conjunction with -debug=1 to output debug logs for all categories except the specified category. This option can be specified multiple times to exclude multiple categories."), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
|
||||
argsman.AddArg("-disablegovernance", strprintf("Disable governance validation (0-1, default: %u)", 0), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
|
||||
argsman.AddArg("-logips", strprintf("Include IP addresses in debug output (default: %u)", DEFAULT_LOGIPS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
|
||||
argsman.AddArg("-logsourcelocations", strprintf("Prepend debug output with name of the originating source location (source file, line number and function name) (default: %u)", DEFAULT_LOGSOURCELOCATIONS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
|
||||
argsman.AddArg("-logtimemicros", strprintf("Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||
#ifdef HAVE_THREAD_LOCAL
|
||||
argsman.AddArg("-logtimestamps", strprintf("Prepend debug output with timestamp (default: %u)", DEFAULT_LOGTIMESTAMPS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
|
||||
@ -1084,6 +1085,8 @@ void InitLogging(const ArgsManager& args)
|
||||
#ifdef HAVE_THREAD_LOCAL
|
||||
LogInstance().m_log_threadnames = args.GetBoolArg("-logthreadnames", DEFAULT_LOGTHREADNAMES);
|
||||
#endif
|
||||
LogInstance().m_log_sourcelocations = args.GetBoolArg("-logsourcelocations", DEFAULT_LOGSOURCELOCATIONS);
|
||||
|
||||
fLogIPs = args.GetBoolArg("-logips", DEFAULT_LOGIPS);
|
||||
|
||||
std::string version_string = FormatFullVersion();
|
||||
|
@ -27,18 +27,11 @@ CFinalCommitment::CFinalCommitment(const Consensus::LLMQParams& params, const ui
|
||||
{
|
||||
}
|
||||
|
||||
template<typename... Types>
|
||||
void LogPrintfFinalCommitment(Types... out) {
|
||||
if (LogAcceptCategory(BCLog::LLMQ)) {
|
||||
LogInstance().LogPrintStr(strprintf("CFinalCommitment::%s -- %s", __func__, tinyformat::format(out...)));
|
||||
}
|
||||
}
|
||||
|
||||
bool CFinalCommitment::Verify(CDeterministicMNManager& dmnman, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, bool checkSigs) const
|
||||
{
|
||||
const auto& llmq_params_opt = Params().GetLLMQ(llmqType);
|
||||
if (!llmq_params_opt.has_value()) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid llmqType=%d\n", quorumHash.ToString(), ToUnderlying(llmqType));
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid llmqType=%d\n", quorumHash.ToString(), ToUnderlying(llmqType));
|
||||
return false;
|
||||
}
|
||||
const auto& llmq_params = llmq_params_opt.value();
|
||||
@ -46,17 +39,17 @@ bool CFinalCommitment::Verify(CDeterministicMNManager& dmnman, gsl::not_null<con
|
||||
const uint16_t expected_nversion{CFinalCommitment::GetVersion(IsQuorumRotationEnabled(llmq_params, pQuorumBaseBlockIndex),
|
||||
DeploymentActiveAfter(pQuorumBaseBlockIndex, Params().GetConsensus(), Consensus::DEPLOYMENT_V19))};
|
||||
if (nVersion == 0 || nVersion != expected_nversion) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid nVersion=%d expectednVersion\n", quorumHash.ToString(), nVersion, expected_nversion);
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid nVersion=%d expected=%d\n", quorumHash.ToString(), nVersion, expected_nversion);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pQuorumBaseBlockIndex->GetBlockHash() != quorumHash) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid quorumHash\n", quorumHash.ToString());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid quorumHash\n", quorumHash.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((pQuorumBaseBlockIndex->nHeight % llmq_params.dkgInterval) != quorumIndex) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid quorumIndex=%d\n", quorumHash.ToString(), quorumIndex);
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid quorumIndex=%d\n", quorumHash.ToString(), quorumIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -65,27 +58,27 @@ bool CFinalCommitment::Verify(CDeterministicMNManager& dmnman, gsl::not_null<con
|
||||
}
|
||||
|
||||
if (CountValidMembers() < llmq_params.minSize) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid validMembers count. validMembersCount=%d\n", quorumHash.ToString(), CountValidMembers());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid validMembers count. validMembersCount=%d\n", quorumHash.ToString(), CountValidMembers());
|
||||
return false;
|
||||
}
|
||||
if (CountSigners() < llmq_params.minSize) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid signers count. signersCount=%d\n", quorumHash.ToString(), CountSigners());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid signers count. signersCount=%d\n", quorumHash.ToString(), CountSigners());
|
||||
return false;
|
||||
}
|
||||
if (!quorumPublicKey.IsValid()) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid quorumPublicKey\n", quorumHash.ToString());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid quorumPublicKey\n", quorumHash.ToString());
|
||||
return false;
|
||||
}
|
||||
if (quorumVvecHash.IsNull()) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid quorumVvecHash\n", quorumHash.ToString());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid quorumVvecHash\n", quorumHash.ToString());
|
||||
return false;
|
||||
}
|
||||
if (!membersSig.IsValid()) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid membersSig\n", quorumHash.ToString());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid membersSig\n", quorumHash.ToString());
|
||||
return false;
|
||||
}
|
||||
if (!quorumSig.IsValid()) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid vvecSig\n");
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid vvecSig\n", quorumHash.ToString());
|
||||
return false;
|
||||
}
|
||||
auto members = utils::GetAllQuorumMembers(llmqType, dmnman, pQuorumBaseBlockIndex);
|
||||
@ -96,16 +89,16 @@ bool CFinalCommitment::Verify(CDeterministicMNManager& dmnman, gsl::not_null<con
|
||||
ss << "v[" << i << "]=" << validMembers[i];
|
||||
ss2 << "s[" << i << "]=" << signers[i];
|
||||
}
|
||||
LogPrintfFinalCommitment("CFinalCommitment::%s mns[%d] validMembers[%s] signers[%s]\n", __func__, members.size(), ss.str(), ss2.str());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment::%s mns[%d] validMembers[%s] signers[%s]\n", __func__, members.size(), ss.str(), ss2.str());
|
||||
}
|
||||
|
||||
for (const auto i : irange::range(members.size(), size_t(llmq_params.size))) {
|
||||
if (validMembers[i]) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid validMembers bitset. bit %d should not be set\n", quorumHash.ToString(), i);
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid validMembers bitset. bit %d should not be set\n", quorumHash.ToString(), i);
|
||||
return false;
|
||||
}
|
||||
if (signers[i]) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid signers bitset. bit %d should not be set\n", quorumHash.ToString(), i);
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid signers bitset. bit %d should not be set\n", quorumHash.ToString(), i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -118,7 +111,7 @@ bool CFinalCommitment::Verify(CDeterministicMNManager& dmnman, gsl::not_null<con
|
||||
for (const auto &mn: members) {
|
||||
ss3 << mn->proTxHash.ToString().substr(0, 4) << " | ";
|
||||
}
|
||||
LogPrintfFinalCommitment("CFinalCommitment::%s members[%s] quorumPublicKey[%s] commitmentHash[%s]\n",
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment::%s members[%s] quorumPublicKey[%s] commitmentHash[%s]\n",
|
||||
__func__, ss3.str(), quorumPublicKey.ToString(), commitmentHash.ToString());
|
||||
}
|
||||
std::vector<CBLSPublicKey> memberPubKeys;
|
||||
@ -130,17 +123,17 @@ bool CFinalCommitment::Verify(CDeterministicMNManager& dmnman, gsl::not_null<con
|
||||
}
|
||||
|
||||
if (!membersSig.VerifySecureAggregated(memberPubKeys, commitmentHash)) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid aggregated members signature\n", quorumHash.ToString());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid aggregated members signature\n", quorumHash.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!quorumSig.VerifyInsecure(quorumPublicKey, commitmentHash)) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid quorum signature\n", quorumHash.ToString());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid quorum signature\n", quorumHash.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
LogPrintfFinalCommitment("q[%s] VALID\n", quorumHash.ToString());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] VALID QUORUM\n", quorumHash.ToString());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -149,7 +142,7 @@ bool CFinalCommitment::VerifyNull() const
|
||||
{
|
||||
const auto& llmq_params_opt = Params().GetLLMQ(llmqType);
|
||||
if (!llmq_params_opt.has_value()) {
|
||||
LogPrintfFinalCommitment("q[%s]invalid llmqType=%d\n", quorumHash.ToString(), ToUnderlying(llmqType));
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s]invalid llmqType=%d\n", quorumHash.ToString(), ToUnderlying(llmqType));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -163,11 +156,11 @@ bool CFinalCommitment::VerifyNull() const
|
||||
bool CFinalCommitment::VerifySizes(const Consensus::LLMQParams& params) const
|
||||
{
|
||||
if (signers.size() != size_t(params.size)) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid signers.size=%d\n", quorumHash.ToString(), signers.size());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid signers.size=%d\n", quorumHash.ToString(), signers.size());
|
||||
return false;
|
||||
}
|
||||
if (validMembers.size() != size_t(params.size)) {
|
||||
LogPrintfFinalCommitment("q[%s] invalid signers.size=%d\n", quorumHash.ToString(), signers.size());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid signers.size=%d\n", quorumHash.ToString(), signers.size());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -177,14 +170,14 @@ bool CheckLLMQCommitment(CDeterministicMNManager& dmnman, const CTransaction& tx
|
||||
{
|
||||
const auto opt_qcTx = GetTxPayload<CFinalCommitmentTxPayload>(tx);
|
||||
if (!opt_qcTx) {
|
||||
LogPrintfFinalCommitment("h[%d] GetTxPayload failed\n", pindexPrev->nHeight);
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] GetTxPayload LLMQCommitment failed\n", pindexPrev->nHeight);
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-payload");
|
||||
}
|
||||
auto& qcTx = *opt_qcTx;
|
||||
|
||||
const auto& llmq_params_opt = Params().GetLLMQ(qcTx.commitment.llmqType);
|
||||
if (!llmq_params_opt.has_value()) {
|
||||
LogPrintfFinalCommitment("h[%d] GetLLMQ failed for llmqType[%d]\n", pindexPrev->nHeight, ToUnderlying(qcTx.commitment.llmqType));
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] GetLLMQ failed for llmqType[%d]\n", pindexPrev->nHeight, ToUnderlying(qcTx.commitment.llmqType));
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-commitment-type");
|
||||
}
|
||||
|
||||
@ -193,17 +186,17 @@ bool CheckLLMQCommitment(CDeterministicMNManager& dmnman, const CTransaction& tx
|
||||
for (const auto i: irange::range(llmq_params_opt->size)) {
|
||||
ss << "v[" << i << "]=" << qcTx.commitment.validMembers[i];
|
||||
}
|
||||
LogPrintfFinalCommitment("%s llmqType[%d] validMembers[%s] signers[]\n", __func__,
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- %s llmqType[%d] validMembers[%s] signers[]\n", __func__,
|
||||
int(qcTx.commitment.llmqType), ss.str());
|
||||
}
|
||||
|
||||
if (qcTx.nVersion == 0 || qcTx.nVersion > CFinalCommitmentTxPayload::CURRENT_VERSION) {
|
||||
LogPrintfFinalCommitment("h[%d] invalid qcTx.nVersion[%d]\n", pindexPrev->nHeight, qcTx.nVersion);
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.nVersion[%d]\n", pindexPrev->nHeight, qcTx.nVersion);
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-version");
|
||||
}
|
||||
|
||||
if (qcTx.nHeight != uint32_t(pindexPrev->nHeight + 1)) {
|
||||
LogPrintfFinalCommitment("h[%d] invalid qcTx.nHeight[%d]\n", pindexPrev->nHeight, qcTx.nHeight);
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.nHeight[%d]\n", pindexPrev->nHeight, qcTx.nHeight);
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-height");
|
||||
}
|
||||
|
||||
@ -220,18 +213,18 @@ bool CheckLLMQCommitment(CDeterministicMNManager& dmnman, const CTransaction& tx
|
||||
|
||||
if (qcTx.commitment.IsNull()) {
|
||||
if (!qcTx.commitment.VerifyNull()) {
|
||||
LogPrintfFinalCommitment("h[%d] invalid qcTx.commitment[%s] VerifyNull failed\n", pindexPrev->nHeight, qcTx.commitment.quorumHash.ToString());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.commitment[%s] VerifyNull failed\n", pindexPrev->nHeight, qcTx.commitment.quorumHash.ToString());
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-invalid-null");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!qcTx.commitment.Verify(dmnman, pQuorumBaseBlockIndex, false)) {
|
||||
LogPrintfFinalCommitment("h[%d] invalid qcTx.commitment[%s] Verify failed\n", pindexPrev->nHeight, qcTx.commitment.quorumHash.ToString());
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.commitment[%s] Verify failed\n", pindexPrev->nHeight, qcTx.commitment.quorumHash.ToString());
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-invalid");
|
||||
}
|
||||
|
||||
LogPrintfFinalCommitment("h[%d] CheckLLMQCommitment VALID\n", pindexPrev->nHeight);
|
||||
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] CheckLLMQCommitment VALID\n", pindexPrev->nHeight);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -35,10 +35,10 @@ namespace llmq
|
||||
class CDKGLogger : public CBatchedLogger
|
||||
{
|
||||
public:
|
||||
CDKGLogger(const CDKGSession& _quorumDkg, std::string_view _func) :
|
||||
CDKGLogger(_quorumDkg.params.name, _quorumDkg.quorumIndex, _quorumDkg.m_quorum_base_block_index->GetBlockHash(), _quorumDkg.m_quorum_base_block_index->nHeight, _quorumDkg.AreWeMember(), _func){};
|
||||
CDKGLogger(std::string_view _llmqTypeName, int _quorumIndex, const uint256& _quorumHash, int _height, bool _areWeMember, std::string_view _func) :
|
||||
CBatchedLogger(BCLog::LLMQ_DKG, strprintf("QuorumDKG(type=%s, quorumIndex=%d, height=%d, member=%d, func=%s)", _llmqTypeName, _quorumIndex, _height, _areWeMember, _func)){};
|
||||
CDKGLogger(const CDKGSession& _quorumDkg, std::string_view _func, int source_line) :
|
||||
CDKGLogger(_quorumDkg.params.name, _quorumDkg.quorumIndex, _quorumDkg.m_quorum_base_block_index->GetBlockHash(), _quorumDkg.m_quorum_base_block_index->nHeight, _quorumDkg.AreWeMember(), _func, source_line){};
|
||||
CDKGLogger(std::string_view _llmqTypeName, int _quorumIndex, const uint256& _quorumHash, int _height, bool _areWeMember, std::string_view _func, int source_line) :
|
||||
CBatchedLogger(BCLog::LLMQ_DKG, strprintf("QuorumDKG(type=%s, qIndex=%d, h=%d, member=%d)", _llmqTypeName, _quorumIndex, _height, _areWeMember), __FILE__, source_line){};
|
||||
};
|
||||
|
||||
static std::array<std::atomic<double>, ToUnderlying(DKGError::type::_COUNT)> simDkgErrorMap{};
|
||||
@ -100,7 +100,7 @@ bool CDKGSession::Init(gsl::not_null<const CBlockIndex*> _pQuorumBaseBlockIndex,
|
||||
}
|
||||
}
|
||||
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
if (LogAcceptCategory(BCLog::LLMQ) && IsQuorumRotationEnabled(params, m_quorum_base_block_index)) {
|
||||
int cycleQuorumBaseHeight = m_quorum_base_block_index->nHeight - quorumIndex;
|
||||
@ -140,7 +140,7 @@ bool CDKGSession::Init(gsl::not_null<const CBlockIndex*> _pQuorumBaseBlockIndex,
|
||||
|
||||
void CDKGSession::Contribute(CDKGPendingMessages& pendingMessages)
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
if (!AreWeMember()) {
|
||||
return;
|
||||
@ -161,7 +161,7 @@ void CDKGSession::Contribute(CDKGPendingMessages& pendingMessages)
|
||||
|
||||
void CDKGSession::SendContributions(CDKGPendingMessages& pendingMessages)
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
assert(AreWeMember());
|
||||
|
||||
@ -214,7 +214,7 @@ void CDKGSession::SendContributions(CDKGPendingMessages& pendingMessages)
|
||||
// only performs cheap verifications, but not the signature of the message. this is checked with batched verification
|
||||
bool CDKGSession::PreVerifyMessage(const CDKGContribution& qc, bool& retBan) const
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
retBan = false;
|
||||
|
||||
@ -262,7 +262,7 @@ void CDKGSession::ReceiveMessage(const CDKGContribution& qc, bool& retBan)
|
||||
{
|
||||
LOCK(cs_pending);
|
||||
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
retBan = false;
|
||||
|
||||
@ -357,7 +357,7 @@ void CDKGSession::VerifyPendingContributions()
|
||||
{
|
||||
AssertLockHeld(cs_pending);
|
||||
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
cxxtimer::Timer t1(true);
|
||||
|
||||
@ -418,7 +418,7 @@ void CDKGSession::VerifyAndComplain(CDKGPendingMessages& pendingMessages)
|
||||
VerifyPendingContributions();
|
||||
}
|
||||
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
// we check all members if they sent us their contributions
|
||||
// we consider members as bad if they missed to send anything or if they sent multiple
|
||||
@ -456,7 +456,7 @@ void CDKGSession::VerifyConnectionAndMinProtoVersions() const
|
||||
return;
|
||||
}
|
||||
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
std::unordered_map<uint256, int, StaticSaltedHasher> protoMap;
|
||||
connman.ForEachNode([&](const CNode* pnode) {
|
||||
@ -491,7 +491,7 @@ void CDKGSession::VerifyConnectionAndMinProtoVersions() const
|
||||
|
||||
void CDKGSession::SendComplaint(CDKGPendingMessages& pendingMessages)
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
assert(AreWeMember());
|
||||
|
||||
@ -534,7 +534,7 @@ void CDKGSession::SendComplaint(CDKGPendingMessages& pendingMessages)
|
||||
// only performs cheap verifications, but not the signature of the message. this is checked with batched verification
|
||||
bool CDKGSession::PreVerifyMessage(const CDKGComplaint& qc, bool& retBan) const
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
retBan = false;
|
||||
|
||||
@ -576,7 +576,7 @@ bool CDKGSession::PreVerifyMessage(const CDKGComplaint& qc, bool& retBan) const
|
||||
|
||||
void CDKGSession::ReceiveMessage(const CDKGComplaint& qc, bool& retBan)
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
retBan = false;
|
||||
|
||||
@ -643,7 +643,7 @@ void CDKGSession::VerifyAndJustify(CDKGPendingMessages& pendingMessages)
|
||||
return;
|
||||
}
|
||||
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
std::set<uint256> justifyFor;
|
||||
|
||||
@ -680,7 +680,7 @@ void CDKGSession::VerifyAndJustify(CDKGPendingMessages& pendingMessages)
|
||||
|
||||
void CDKGSession::SendJustification(CDKGPendingMessages& pendingMessages, const std::set<uint256>& forMembers)
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
assert(AreWeMember());
|
||||
|
||||
@ -729,7 +729,7 @@ void CDKGSession::SendJustification(CDKGPendingMessages& pendingMessages, const
|
||||
// only performs cheap verifications, but not the signature of the message. this is checked with batched verification
|
||||
bool CDKGSession::PreVerifyMessage(const CDKGJustification& qj, bool& retBan) const
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
retBan = false;
|
||||
|
||||
@ -787,7 +787,7 @@ bool CDKGSession::PreVerifyMessage(const CDKGJustification& qj, bool& retBan) co
|
||||
|
||||
void CDKGSession::ReceiveMessage(const CDKGJustification& qj, bool& retBan)
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
retBan = false;
|
||||
|
||||
@ -885,7 +885,7 @@ void CDKGSession::VerifyAndCommit(CDKGPendingMessages& pendingMessages)
|
||||
return;
|
||||
}
|
||||
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
std::vector<size_t> badMembers;
|
||||
badMembers.reserve(members.size());
|
||||
@ -926,7 +926,7 @@ void CDKGSession::VerifyAndCommit(CDKGPendingMessages& pendingMessages)
|
||||
|
||||
void CDKGSession::SendCommitment(CDKGPendingMessages& pendingMessages)
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
assert(AreWeMember());
|
||||
|
||||
@ -1041,7 +1041,7 @@ void CDKGSession::SendCommitment(CDKGPendingMessages& pendingMessages)
|
||||
// only performs cheap verifications, but not the signature of the message. this is checked with batched verification
|
||||
bool CDKGSession::PreVerifyMessage(const CDKGPrematureCommitment& qc, bool& retBan) const
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
retBan = false;
|
||||
|
||||
@ -1102,7 +1102,7 @@ bool CDKGSession::PreVerifyMessage(const CDKGPrematureCommitment& qc, bool& retB
|
||||
|
||||
void CDKGSession::ReceiveMessage(const CDKGPrematureCommitment& qc, bool& retBan)
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
retBan = false;
|
||||
|
||||
@ -1185,7 +1185,7 @@ std::vector<CFinalCommitment> CDKGSession::FinalizeCommitments()
|
||||
return {};
|
||||
}
|
||||
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
|
||||
using Key = std::vector<bool>;
|
||||
std::map<Key, std::vector<CDKGPrematureCommitment>> commitmentsMap;
|
||||
@ -1311,7 +1311,7 @@ void CDKGSession::MarkBadMember(size_t idx)
|
||||
|
||||
void CDKGSession::RelayInvToParticipants(const CInv& inv) const
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
CDKGLogger logger(*this, __func__, __LINE__);
|
||||
std::stringstream ss;
|
||||
for (const auto& r : relayMembers) {
|
||||
ss << r.ToString().substr(0, 4) << " | ";
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <logging.h>
|
||||
#include <util/system.h>
|
||||
#include <util/threadnames.h>
|
||||
#include <util/string.h>
|
||||
#include <util/time.h>
|
||||
|
||||
#include <algorithm>
|
||||
@ -269,11 +270,15 @@ namespace BCLog {
|
||||
}
|
||||
} // namespace BCLog
|
||||
|
||||
void BCLog::Logger::LogPrintStr(const std::string& str)
|
||||
void BCLog::Logger::LogPrintStr(const std::string& str, const std::string& logging_function, const std::string& source_file, const int source_line)
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
std::string str_prefixed = LogEscapeMessage(str);
|
||||
|
||||
if (m_log_sourcelocations && m_started_new_line) {
|
||||
str_prefixed.insert(0, "[" + RemovePrefix(source_file, "./") + ":" + ToString(source_line) + "] [" + logging_function + "] ");
|
||||
}
|
||||
|
||||
if (m_log_threadnames && m_started_new_line) {
|
||||
// 16 chars total, "dash-" is 5 of them and another 1 is a NUL terminator
|
||||
str_prefixed.insert(0, "[" + strprintf("%10s", util::ThreadGetInternalName()) + "] ");
|
||||
|
@ -22,6 +22,7 @@ static const bool DEFAULT_LOGTIMEMICROS = false;
|
||||
static const bool DEFAULT_LOGIPS = false;
|
||||
static const bool DEFAULT_LOGTIMESTAMPS = true;
|
||||
static const bool DEFAULT_LOGTHREADNAMES = false;
|
||||
static const bool DEFAULT_LOGSOURCELOCATIONS = false;
|
||||
extern const char * const DEFAULT_DEBUGLOGFILE;
|
||||
|
||||
extern bool fLogThreadNames;
|
||||
@ -117,12 +118,13 @@ namespace BCLog {
|
||||
bool m_log_timestamps = DEFAULT_LOGTIMESTAMPS;
|
||||
bool m_log_time_micros = DEFAULT_LOGTIMEMICROS;
|
||||
bool m_log_threadnames = DEFAULT_LOGTHREADNAMES;
|
||||
bool m_log_sourcelocations = DEFAULT_LOGSOURCELOCATIONS;
|
||||
|
||||
fs::path m_file_path;
|
||||
std::atomic<bool> m_reopen_file{false};
|
||||
|
||||
/** Send a string to the log output */
|
||||
void LogPrintStr(const std::string& str);
|
||||
void LogPrintStr(const std::string& str, const std::string& logging_function, const std::string& source_file, const int source_line);
|
||||
|
||||
/** Returns whether logs will be written to any output */
|
||||
bool Enabled() const
|
||||
@ -203,7 +205,7 @@ std::string SafeStringFormat(const std::string& fmt, const Args&... args)
|
||||
// peer can fill up a user's disk with debug.log entries.
|
||||
|
||||
template <typename... Args>
|
||||
static inline void LogPrintf(const char* fmt, const Args&... args)
|
||||
static inline void LogPrintf_(const std::string& logging_function, const std::string& source_file, const int source_line, const char* fmt, const Args&... args)
|
||||
{
|
||||
if (LogInstance().Enabled()) {
|
||||
std::string log_msg;
|
||||
@ -213,10 +215,12 @@ static inline void LogPrintf(const char* fmt, const Args&... args)
|
||||
/* Original format string will have newline so don't add one here */
|
||||
log_msg = "Error \"" + std::string(fmterr.what()) + "\" while formatting log message: " + fmt;
|
||||
}
|
||||
LogInstance().LogPrintStr(log_msg);
|
||||
LogInstance().LogPrintStr(log_msg, logging_function, source_file, source_line);
|
||||
}
|
||||
}
|
||||
|
||||
#define LogPrintf(...) LogPrintf_(__func__, __FILE__, __LINE__, __VA_ARGS__)
|
||||
|
||||
// Use a macro instead of a function for conditional logging to prevent
|
||||
// evaluating arguments when logging for the category is not enabled.
|
||||
#define LogPrint(category, ...) \
|
||||
|
@ -11,14 +11,12 @@
|
||||
#if defined(BUILD_BITCOIN_INTERNAL) && defined(HAVE_CONFIG_H)
|
||||
#include <config/bitcoin-config.h>
|
||||
#if defined(_WIN32)
|
||||
#if defined(DLL_EXPORT)
|
||||
#if defined(HAVE_FUNC_ATTRIBUTE_DLLEXPORT)
|
||||
#define EXPORT_SYMBOL __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_SYMBOL
|
||||
#endif
|
||||
#if defined(HAVE_DLLEXPORT_ATTRIBUTE)
|
||||
#define EXPORT_SYMBOL __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_SYMBOL
|
||||
#endif
|
||||
#elif defined(HAVE_FUNC_ATTRIBUTE_VISIBILITY)
|
||||
#elif defined(HAVE_DEFAULT_VISIBILITY_ATTRIBUTE)
|
||||
#define EXPORT_SYMBOL __attribute__ ((visibility ("default")))
|
||||
#endif
|
||||
#elif defined(MSC_VER) && !defined(STATIC_LIBBITCOINCONSENSUS)
|
||||
|
@ -161,6 +161,7 @@ FUZZ_TARGET(string)
|
||||
(void)ParseNonRFCJSONValue(random_string_1);
|
||||
} catch (const std::runtime_error&) {
|
||||
}
|
||||
(void)RemovePrefix(random_string_1, random_string_2);
|
||||
(void)ResolveErrMsg(random_string_1, random_string_2);
|
||||
try {
|
||||
(void)RPCConvertNamedValues(random_string_1, random_string_vector);
|
||||
|
@ -142,6 +142,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
|
||||
{
|
||||
"dummy",
|
||||
"-printtoconsole=0",
|
||||
"-logsourcelocations",
|
||||
"-logtimemicros",
|
||||
"-logthreadnames",
|
||||
"-debug",
|
||||
|
@ -2635,4 +2635,17 @@ BOOST_AUTO_TEST_CASE(message_hash)
|
||||
BOOST_CHECK_NE(message_hash1, signature_hash);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(remove_prefix)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(RemovePrefix("./util/system.h", "./"), "util/system.h");
|
||||
BOOST_CHECK_EQUAL(RemovePrefix("foo", "foo"), "");
|
||||
BOOST_CHECK_EQUAL(RemovePrefix("foo", "fo"), "o");
|
||||
BOOST_CHECK_EQUAL(RemovePrefix("foo", "f"), "oo");
|
||||
BOOST_CHECK_EQUAL(RemovePrefix("foo", ""), "foo");
|
||||
BOOST_CHECK_EQUAL(RemovePrefix("fo", "foo"), "fo");
|
||||
BOOST_CHECK_EQUAL(RemovePrefix("f", "foo"), "f");
|
||||
BOOST_CHECK_EQUAL(RemovePrefix("", "foo"), "");
|
||||
BOOST_CHECK_EQUAL(RemovePrefix("", ""), "");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
@ -39,6 +39,14 @@ void ReplaceAll(std::string& in_out, const std::string& search, const std::strin
|
||||
return str.substr(front, end - front + 1);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline std::string RemovePrefix(const std::string& str, const std::string& prefix)
|
||||
{
|
||||
if (str.substr(0, prefix.size()) == prefix) {
|
||||
return str.substr(prefix.size());
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Join a list of items
|
||||
*
|
||||
|
@ -78,7 +78,7 @@ def get_p2p_id(node, uacomment=None):
|
||||
for p2p in node.p2ps:
|
||||
if uacomment is not None and p2p.uacomment != uacomment:
|
||||
continue
|
||||
if p["subver"] == p2p.strSubVer.decode():
|
||||
if p["subver"] == p2p.strSubVer:
|
||||
return p["id"]
|
||||
return None
|
||||
wait_until_helper(lambda: get_id() is not None, timeout=10)
|
||||
|
@ -33,7 +33,7 @@ import dash_hash
|
||||
|
||||
MIN_VERSION_SUPPORTED = 60001
|
||||
MY_VERSION = 70231 # NO_LEGACY_ISLOCK_PROTO_VERSION
|
||||
MY_SUBVERSION = b"/python-p2p-tester:0.0.3%s/"
|
||||
MY_SUBVERSION = "/python-p2p-tester:0.0.3%s/"
|
||||
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)
|
||||
|
||||
MAX_LOCATOR_SZ = 101
|
||||
@ -1521,7 +1521,7 @@ class msg_version:
|
||||
self.addrTo = CAddress()
|
||||
self.addrFrom = CAddress()
|
||||
self.nNonce = random.getrandbits(64)
|
||||
self.strSubVer = MY_SUBVERSION % b""
|
||||
self.strSubVer = MY_SUBVERSION % ""
|
||||
self.nStartingHeight = -1
|
||||
self.nRelay = MY_RELAY
|
||||
|
||||
@ -1535,7 +1535,7 @@ class msg_version:
|
||||
self.addrFrom = CAddress()
|
||||
self.addrFrom.deserialize(f, with_time=False)
|
||||
self.nNonce = struct.unpack("<Q", f.read(8))[0]
|
||||
self.strSubVer = deser_string(f)
|
||||
self.strSubVer = deser_string(f).decode('utf-8')
|
||||
|
||||
self.nStartingHeight = struct.unpack("<i", f.read(4))[0]
|
||||
|
||||
@ -1554,7 +1554,7 @@ class msg_version:
|
||||
r += self.addrTo.serialize(with_time=False)
|
||||
r += self.addrFrom.serialize(with_time=False)
|
||||
r += struct.pack("<Q", self.nNonce)
|
||||
r += ser_string(self.strSubVer)
|
||||
r += ser_string(self.strSubVer.encode('utf-8'))
|
||||
r += struct.pack("<i", self.nStartingHeight)
|
||||
r += struct.pack("<b", self.nRelay)
|
||||
return r
|
||||
|
@ -186,13 +186,13 @@ class P2PConnection(asyncio.Protocol):
|
||||
if net == "devnet":
|
||||
devnet_name = "devnet1" # see initialize_datadir()
|
||||
if self.uacomment is None:
|
||||
self.strSubVer = MY_SUBVERSION % ("(devnet.devnet-%s)" % devnet_name).encode()
|
||||
self.strSubVer = MY_SUBVERSION % ("(devnet.devnet-%s)" % devnet_name)
|
||||
else:
|
||||
self.strSubVer = MY_SUBVERSION % ("(devnet.devnet-%s,%s)" % (devnet_name, self.uacomment)).encode()
|
||||
self.strSubVer = MY_SUBVERSION % ("(devnet.devnet-%s,%s)" % (devnet_name, self.uacomment))
|
||||
elif self.uacomment is not None:
|
||||
self.strSubVer = MY_SUBVERSION % ("(%s)" % self.uacomment).encode()
|
||||
self.strSubVer = MY_SUBVERSION % ("(%s)" % self.uacomment)
|
||||
else:
|
||||
self.strSubVer = MY_SUBVERSION % b""
|
||||
self.strSubVer = MY_SUBVERSION % ""
|
||||
|
||||
def peer_connect(self, dstaddr, dstport, *, net, timeout_factor, uacomment=None):
|
||||
self.peer_connect_helper(dstaddr, dstport, net, timeout_factor, uacomment)
|
||||
|
@ -116,8 +116,10 @@ class TestNode():
|
||||
"--gen-suppressions=all", "--exit-on-first-error=yes",
|
||||
"--error-exitcode=1", "--quiet"] + self.args
|
||||
|
||||
if self.version_is_at_least(190000):
|
||||
if self.version_is_at_least(120100):
|
||||
self.args.append("-logthreadnames")
|
||||
if self.version_is_at_least(21000000):
|
||||
self.args.append("-logsourcelocations")
|
||||
|
||||
self.cli = TestNodeCLI(bitcoin_cli, self.datadir)
|
||||
self.use_cli = use_cli
|
||||
@ -592,7 +594,7 @@ class TestNode():
|
||||
|
||||
def num_test_p2p_connections(self):
|
||||
"""Return number of test framework p2p connections to the node."""
|
||||
return len([peer for peer in self.getpeerinfo() if peer['subver'] == MY_SUBVERSION.decode("utf-8")])
|
||||
return len([peer for peer in self.getpeerinfo() if peer['subver'] == MY_SUBVERSION])
|
||||
|
||||
def disconnect_p2ps(self):
|
||||
"""Close all p2p connections to the node."""
|
||||
@ -603,7 +605,7 @@ class TestNode():
|
||||
def check_peers():
|
||||
for p in self.getpeerinfo():
|
||||
for p2p in self.p2ps:
|
||||
if p['subver'] == p2p.strSubVer.decode():
|
||||
if p['subver'] == p2p.strSubVer:
|
||||
return False
|
||||
return True
|
||||
wait_until_helper(check_peers, timeout=5)
|
||||
|
Loading…
Reference in New Issue
Block a user