Skip to content

Commit

Permalink
Merge pull request #5816 from PastaPastaPasta/develop-trivial-2024-01-10
Browse files Browse the repository at this point in the history
backport: trivial 2024 01 10
  • Loading branch information
PastaPastaPasta authored Jan 14, 2024
2 parents d6ac2b9 + 1b1badf commit dfc978a
Show file tree
Hide file tree
Showing 30 changed files with 297 additions and 127 deletions.
23 changes: 22 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ AC_CONFIG_HEADERS([src/config/bitcoin-config.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux/m4])

m4_ifndef([PKG_PROG_PKG_CONFIG], [AC_MSG_ERROR([PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh])])
m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal([PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh])])
PKG_PROG_PKG_CONFIG
if test "x$PKG_CONFIG" = x; then
AC_MSG_ERROR([pkg-config not found])
Expand Down Expand Up @@ -1478,6 +1478,26 @@ if test x$build_bitcoin_cli$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench
fi
fi

if test x$use_libevent = xyes; then
TEMP_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $EVENT_CFLAGS"
AC_MSG_CHECKING([if evhttp_connection_get_peer expects const char**])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <cstdint>
#include <event2/http.h>
]], [[
evhttp_connection *conn = (evhttp_connection *)1;
const char *host;
uint16_t port;
evhttp_connection_get_peer(conn, &host, &port);
]])],
[ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR], [1], [Define this symbol if evhttp_connection_get_peer expects const char**]) ],
[ AC_MSG_RESULT([no]) ]
)
CXXFLAGS="$TEMP_CXXFLAGS"
fi

dnl QR Code encoding library check

if test "x$use_qr" != xno; then
Expand Down Expand Up @@ -1787,6 +1807,7 @@ AC_SUBST(HAVE_MM_PREFETCH)
AC_SUBST(HAVE_STRONG_GETAUXVAL)
AC_SUBST(HAVE_GMTIME_R)
AC_SUBST(ANDROID_ARCH)
AC_SUBST(HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR)
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini])
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])
Expand Down
11 changes: 7 additions & 4 deletions depends/packages/zeromq.mk
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package=zeromq
$(package)_version=4.3.1
$(package)_version=4.3.4
$(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version)/
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=bcbabe1e2c7d0eec4ed612e10b94b112dd5f06fcefa994a0c79a45d835cd21eb
$(package)_patches=remove_libstd_link.patch
$(package)_sha256_hash=c593001a89f5a85dd2ddf564805deb860e02471171b3f204944857336295c3e5
$(package)_patches=remove_libstd_link.patch netbsd_kevent_void.patch

define $(package)_set_vars
$(package)_config_opts=--without-docs --disable-shared --disable-curve --disable-curve-keygen --disable-perf
$(package)_config_opts = --without-docs --disable-shared --disable-valgrind
$(package)_config_opts += --disable-perf --disable-curve-keygen --disable-curve --disable-libbsd
$(package)_config_opts += --without-libsodium --without-libgssapi_krb5 --without-pgm --without-norm --without-vmci
$(package)_config_opts += --disable-libunwind --disable-radix-tree --without-gcov --disable-dependency-tracking
$(package)_config_opts += --disable-Werror --disable-drafts --enable-option-checking
Expand All @@ -20,10 +21,12 @@ endef

define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/remove_libstd_link.patch && \
patch -p1 < $($(package)_patch_dir)/netbsd_kevent_void.patch && \
cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub config
endef

define $(package)_config_cmds
./autogen.sh && \
$($(package)_autoconf)
endef

Expand Down
57 changes: 57 additions & 0 deletions depends/patches/zeromq/netbsd_kevent_void.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
commit 129137d5182967dbfcfec66bad843df2a992a78f
Author: fanquake <[email protected]>
Date: Mon Jan 3 20:13:33 2022 +0800

problem: kevent udata is now void* on NetBSD Current (10)

solution: check for the intptr_t variant in configure.

diff --git a/configure.ac b/configure.ac
index 1a571291..402f8b86 100644
--- a/configure.ac
+++ b/configure.ac
@@ -307,6 +307,27 @@ case "${host_os}" in
if test "x$libzmq_netbsd_has_atomic" = "xno"; then
AC_DEFINE(ZMQ_FORCE_MUTEXES, 1, [Force to use mutexes])
fi
+ # NetBSD Current (to become 10) has changed the type of udata in it's
+ # kevent struct from intptr_t to void * to align with darwin and other
+ # BSDs, see upstream commit:
+ # https://github.com/NetBSD/src/commit/e5ead823eb916b56589d2c6c560dbcfe4a2d0afc
+ AC_MSG_CHECKING([whether kevent udata type is intptr_t])
+ AC_LANG_PUSH([C++])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(
+ [[#include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>]],
+ [[struct kevent ev;
+ intptr_t udata;
+ EV_SET(&ev, 0, 0, EV_ADD, 0, 0, udata);
+ return 0;]])],
+ [libzmq_netbsd_kevent_udata_intptr_t=yes],
+ [libzmq_netbsd_kevent_udata_intptr_t=no])
+ AC_LANG_POP([C++])
+ AC_MSG_RESULT([$libzmq_netbsd_kevent_udata_intptr_t])
+ if test "x$libzmq_netbsd_kevent_udata_intptr_t" = "xyes"; then
+ AC_DEFINE(ZMQ_NETBSD_KEVENT_UDATA_INTPTR_T, 1, [kevent udata type is intptr_t])
+ fi
;;
*openbsd*|*bitrig*)
# Define on OpenBSD to enable all library features
diff --git a/src/kqueue.cpp b/src/kqueue.cpp
index 53d82ac4..a6a7a7f2 100644
--- a/src/kqueue.cpp
+++ b/src/kqueue.cpp
@@ -46,9 +46,9 @@
#include "i_poll_events.hpp"
#include "likely.hpp"

-// NetBSD defines (struct kevent).udata as intptr_t, everyone else
-// as void *.
-#if defined ZMQ_HAVE_NETBSD
+// NetBSD up to version 9 defines (struct kevent).udata as intptr_t,
+// everyone else as void *.
+#if defined ZMQ_HAVE_NETBSD && defined(ZMQ_NETBSD_KEVENT_UDATA_INTPTR_T)
#define kevent_udata_t intptr_t
#else
#define kevent_udata_t void *
1 change: 1 addition & 0 deletions doc/REST-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Only supports JSON as output format.

Returns transactions in the TX mempool.
Only supports JSON as output format.
Refer to the `getrawmempool` RPC help for details.

Risks
-------------
Expand Down
7 changes: 1 addition & 6 deletions src/arith_uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,19 @@ template<unsigned int BITS>
class base_uint
{
protected:
static_assert(BITS / 32 > 0 && BITS % 32 == 0, "Template parameter BITS must be a positive multiple of 32.");
static constexpr int WIDTH = BITS / 32;
uint32_t pn[WIDTH];
public:

base_uint()
{
static_assert(BITS/32 > 0 && BITS%32 == 0, "Template parameter BITS must be a positive multiple of 32.");

for (int i = 0; i < WIDTH; i++)
pn[i] = 0;
}

base_uint(const base_uint& b)
{
static_assert(BITS/32 > 0 && BITS%32 == 0, "Template parameter BITS must be a positive multiple of 32.");

for (int i = 0; i < WIDTH; i++)
pn[i] = b.pn[i];
}
Expand All @@ -53,8 +50,6 @@ class base_uint

base_uint(uint64_t b)
{
static_assert(BITS/32 > 0 && BITS%32 == 0, "Template parameter BITS must be a positive multiple of 32.");

pn[0] = (unsigned int)b;
pn[1] = (unsigned int)(b >> 32);
for (int i = 2; i < WIDTH; i++)
Expand Down
20 changes: 13 additions & 7 deletions src/banman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <netaddress.h>
#include <node/ui_interface.h>
#include <sync.h>
#include <util/system.h>
#include <util/time.h>
#include <util/translation.h>
Expand Down Expand Up @@ -39,18 +40,23 @@ BanMan::~BanMan()

void BanMan::DumpBanlist()
{
SweepBanned(); // clean unused entries (if bantime has expired)

if (!BannedSetIsDirty()) return;

int64_t n_start = GetTimeMillis();
static Mutex dump_mutex;
LOCK(dump_mutex);

banmap_t banmap;
GetBanned(banmap);
if (m_ban_db.Write(banmap)) {
{
LOCK(m_cs_banned);
SweepBanned();
if (!BannedSetIsDirty()) return;
banmap = m_banned;
SetBannedSetDirty(false);
}

int64_t n_start = GetTimeMillis();
if (!m_ban_db.Write(banmap)) {
SetBannedSetDirty(true);
}

LogPrint(BCLog::NET, "Flushed %d banned node addresses/subnets to disk %dms\n", banmap.size(),
GetTimeMillis() - n_start);
}
Expand Down
5 changes: 4 additions & 1 deletion src/bench/checkqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
{
return true;
}
void swap(PrevectorJob& x){p.swap(x.p);};
void swap(PrevectorJob& x) noexcept
{
p.swap(x.p);
};
};
CCheckQueue<PrevectorJob> queue {QUEUE_BATCH_SIZE};

Expand Down
2 changes: 1 addition & 1 deletion src/hdchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CHDChain
);
}

void swap(CHDChain& first, CHDChain& second) // nothrow
void swap(CHDChain& first, CHDChain& second) noexcept
{
// enable ADL (not necessary in our case, but good practice)
using std::swap;
Expand Down
10 changes: 10 additions & 0 deletions src/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <httpserver.h>

#include <chainparamsbase.h>
Expand Down Expand Up @@ -597,7 +601,13 @@ CService HTTPRequest::GetPeer() const
// evhttp retains ownership over returned address string
const char* address = "";
uint16_t port = 0;

#ifdef HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR
evhttp_connection_get_peer(con, &address, &port);
#else
evhttp_connection_get_peer(con, (char**)&address, &port);
#endif // HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR

peer = LookupNumeric(address, port);
}
return peer;
Expand Down
2 changes: 1 addition & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,7 @@ void CConnman::SetTryNewOutboundPeer(bool flag)

// Return the number of peers we have over our outbound connection limit
// Exclude peers that are marked for disconnect, or are going to be
// disconnected soon (eg one-shots and feelers)
// disconnected soon (eg ADDR_FETCH and FEELER)
// Also exclude peers that haven't finished initial connection handshake yet
// (so that we don't decide we're over our desired connection limit, and then
// evict some peer that has finished the handshake)
Expand Down
17 changes: 13 additions & 4 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,19 @@ enum class ConnectionType {
MANUAL,

/**
* Feeler connections are short lived connections used to increase the
* number of connectable addresses in our AddrMan. Approximately every
* FEELER_INTERVAL, we attempt to connect to a random address from the new
* table. If successful, we add it to the tried table.
* Feeler connections are short-lived connections made to check that a node
* is alive. They can be useful for:
* - test-before-evict: if one of the peers is considered for eviction from
* our AddrMan because another peer is mapped to the same slot in the tried table,
* evict only if this longer-known peer is offline.
* - move node addresses from New to Tried table, so that we have more
* connectable addresses in our AddrMan.
* Note that in the literature ("Eclipse Attacks on Bitcoin’s Peer-to-Peer Network")
* only the latter feature is referred to as "feeler connections",
* although in our codebase feeler connections encompass test-before-evict as well.
* We make these connections approximately every FEELER_INTERVAL:
* first we resolve previously found collisions if they exist (test-before-evict),
* otherwise connect to a node from the new table.
*/
FEELER,

Expand Down
3 changes: 2 additions & 1 deletion src/prevector.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ class prevector {
return *item_ptr(size() - 1);
}

void swap(prevector<N, T, Size, Diff>& other) {
void swap(prevector<N, T, Size, Diff>& other) noexcept
{
std::swap(_union, other._union);
std::swap(_size, other._size);
}
Expand Down
6 changes: 5 additions & 1 deletion src/qt/bitcoinunits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include <cassert>

static constexpr auto MAX_DIGITS_BTC = 16;

BitcoinUnits::BitcoinUnits(QObject *parent):
QAbstractListModel(parent),
unitlist(availableUnits())
Expand Down Expand Up @@ -129,7 +131,9 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
qint64 n_abs = (n > 0 ? n : -n);
qint64 quotient = n_abs / coin;
QString quotient_str = QString::number(quotient);
if (justify) quotient_str = quotient_str.rightJustified(16 - num_decimals, ' ');
if (justify) {
quotient_str = quotient_str.rightJustified(MAX_DIGITS_BTC - num_decimals, ' ');
}

// Use SI-style thin space separators as these are locale independent and can't be
// confused with the decimal marker.
Expand Down
12 changes: 3 additions & 9 deletions src/qt/notificator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
#include <QTemporaryFile>
#include <QVariant>
#ifdef USE_DBUS
#include <stdint.h>
#include <QDBusMetaType>
#include <QtDBus>
#include <stdint.h>
#endif
#ifdef Q_OS_MAC
#include <qt/macnotificationhandler.h>
Expand Down Expand Up @@ -73,8 +74,6 @@ class FreedesktopImage
FreedesktopImage() {}
explicit FreedesktopImage(const QImage &img);

static int metaType();

// Image to variant that can be marshalled over DBus
static QVariant toVariant(const QImage &img);

Expand Down Expand Up @@ -136,15 +135,10 @@ const QDBusArgument &operator>>(const QDBusArgument &a, FreedesktopImage &i)
return a;
}

int FreedesktopImage::metaType()
{
return qDBusRegisterMetaType<FreedesktopImage>();
}

QVariant FreedesktopImage::toVariant(const QImage &img)
{
FreedesktopImage fimg(img);
return QVariant(FreedesktopImage::metaType(), &fimg);
return QVariant(qDBusRegisterMetaType<FreedesktopImage>(), &fimg);
}

void Notificator::notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout)
Expand Down
11 changes: 5 additions & 6 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,17 +557,16 @@ bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
case Qt::Key_Down: if(obj == ui->lineEdit) { browseHistory(1); return true; } break;
case Qt::Key_PageUp: /* pass paging keys to messages widget */
case Qt::Key_PageDown:
if(obj == ui->lineEdit)
{
QApplication::postEvent(ui->messagesWidget, new QKeyEvent(*keyevt));
if (obj == ui->lineEdit) {
QApplication::sendEvent(ui->messagesWidget, keyevt);
return true;
}
break;
case Qt::Key_Return:
case Qt::Key_Enter:
// forward these events to lineEdit
if(obj == autoCompleter->popup()) {
QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
if (obj == autoCompleter->popup()) {
QApplication::sendEvent(ui->lineEdit, keyevt);
autoCompleter->popup()->hide();
return true;
}
Expand All @@ -581,7 +580,7 @@ bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
((mod & Qt::ShiftModifier) && key == Qt::Key_Insert)))
{
ui->lineEdit->setFocus();
QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
QApplication::sendEvent(ui->lineEdit, keyevt);
return true;
}
}
Expand Down
Loading

0 comments on commit dfc978a

Please sign in to comment.