Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: bitcoin#11909, #20586, #21090, #21500, #21562, #22232, #22378, #22688, bitcoin-core/gui#381, #390 #6360

Merged
merged 9 commits into from
Oct 25, 2024
Merged
2 changes: 1 addition & 1 deletion ci/lint/06_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test/lint/lint-all.sh

if [ "$CIRRUS_REPO_FULL_NAME" = "dashpay/dash" ] && [ -n "$CIRRUS_CRON" ]; then
git log --merges --before="2 days ago" -1 --format='%H' > ./contrib/verify-commits/trusted-sha512-root-commit
${CI_RETRY_EXE} gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys $(<contrib/verify-commits/trusted-keys) &&
${CI_RETRY_EXE} gpg --keyserver hkps://keys.openpgp.org --recv-keys $(<contrib/verify-commits/trusted-keys) &&
./contrib/verify-commits/verify-commits.py --clean-merge=2;
fi

Expand Down
4 changes: 0 additions & 4 deletions ci/test/00_setup_env_win64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ export RUN_SECURITY_TESTS="false"
export GOAL="deploy"
export BITCOIN_CONFIG="--enable-gui --enable-reduce-exports --disable-miner --without-boost-process"
export DIRECT_WINE_EXEC_TESTS=true

# Compiler for MinGW-w64 causes false -Wreturn-type warning.
# See https://sourceforge.net/p/mingw-w64/bugs/306/
export NO_WERROR=1
8 changes: 7 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,13 @@ if test "x$enable_werror" = "xyes"; then
AX_CHECK_COMPILE_FLAG([-Werror=range-loop-analysis],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=range-loop-analysis"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=unused-variable],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-variable"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=return-type],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"],,[[$CXXFLAG_WERROR]])

dnl -Wreturn-type is broken in GCC for MinGW-w64.
dnl https://sourceforge.net/p/mingw-w64/bugs/306/
AX_CHECK_COMPILE_FLAG([-Werror=return-type], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"], [], [$CXXFLAG_WERROR],
[AC_LANG_SOURCE([[#include <cassert>
int f(){ assert(false); }]])])

AX_CHECK_COMPILE_FLAG([-Werror=conditional-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=conditional-uninitialized"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Werror=sign-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=sign-compare"],,[[$CXXFLAG_WERROR]])
dnl -Wsuggest-override is broken with GCC before 9.2
Expand Down
25 changes: 18 additions & 7 deletions contrib/builder-keys/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
PGP keys
========
## PGP keys of builders and Developers

This folder contains the public keys of developers and active contributors.
The file `keys.txt` contains fingerprints of the public keys of builders and
active developers.

The keys are mainly used to sign git commits or the build results of builds.

You can import the keys into gpg as follows. Also, make sure to fetch the
latest version from the key server to see if any key was revoked in the
meantime.
The most recent version of each pgp key can be found on most pgp key servers.

Fetch the latest version from the key server to see if any key was revoked in
the meantime.
To fetch the latest version of all pgp keys in your gpg homedir,

```sh
gpg --import ./*.pgp
gpg --refresh-keys
```

To fetch keys of builders and active developers, feed the list of fingerprints
of the primary keys into gpg:

```sh
while read fingerprint keyholder_name; do gpg --keyserver hkps://keys.openpgp.org --recv-keys ${fingerprint}; done < ./keys.txt
```

Add your key to the list if you provided Guix attestations for two major or
minor releases of Dash Core.
2 changes: 1 addition & 1 deletion contrib/verify-commits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Import trusted keys
In order to check the commit signatures, you must add the trusted PGP keys to your machine. [GnuPG](https://gnupg.org/) may be used to import the trusted keys by running the following command:

```sh
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys $(<contrib/verify-commits/trusted-keys)
gpg --keyserver hkps://keys.openpgp.org --recv-keys $(<contrib/verify-commits/trusted-keys)
```

Key expiry/revocation
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ QT_MOC_CPP = \
qt/moc_editaddressdialog.cpp \
qt/moc_governancelist.cpp \
qt/moc_guiutil.cpp \
qt/moc_initexecutor.cpp \
qt/moc_intro.cpp \
qt/moc_macdockiconhandler.cpp \
qt/moc_macnotificationhandler.cpp \
Expand Down Expand Up @@ -133,6 +134,7 @@ BITCOIN_QT_H = \
qt/governancelist.h \
qt/guiconstants.h \
qt/guiutil.h \
qt/initexecutor.h \
qt/intro.h \
qt/macdockiconhandler.h \
qt/macnotificationhandler.h \
Expand Down Expand Up @@ -222,6 +224,7 @@ BITCOIN_QT_BASE_CPP = \
qt/clientmodel.cpp \
qt/csvmodelwriter.cpp \
qt/guiutil.cpp \
qt/initexecutor.cpp \
qt/intro.cpp \
qt/modaloverlay.cpp \
qt/networkstyle.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/tx_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& ma
* Count total signature operations for a transaction.
* @param[in] tx Transaction for which we are counting sigops
* @param[in] inputs Map of previous transactions that have outputs we're spending
* @param[out] flags Script verification flags
* @param[in] flags Script verification flags
* @return Total signature operation count for a tx
*/
unsigned int GetTransactionSigOpCount(const CTransaction& tx, const CCoinsViewCache& inputs, uint32_t flags);
Expand Down
3 changes: 2 additions & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ class PeerManagerImpl final : public PeerManager
* million to make it highly unlikely for users to have issues with this
* filter.
*
* Memory used: 1.3MB
* Memory used: 1.3 MB
*/
CRollingBloomFilter m_recent_rejects GUARDED_BY(::cs_main){120'000, 0.000'001};
uint256 hashRecentRejectsChainTip GUARDED_BY(cs_main);
Expand Down Expand Up @@ -1620,6 +1620,7 @@ void PeerManagerImpl::FinalizeNode(const CNode& node) {
assert(m_num_preferred_download_peers == 0);
assert(m_peers_downloading_from == 0);
assert(m_outbound_peers_with_protect_from_disconnect == 0);
assert(m_orphanage.Size() == 0);
}
} // cs_main

Expand Down
124 changes: 24 additions & 100 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@
#endif

#include <qt/bitcoin.h>
#include <qt/bitcoingui.h>

#include <chainparams.h>
#include <fs.h>
#include <init.h>
#include <interfaces/handler.h>
#include <interfaces/node.h>
#include <net.h>
#include <node/context.h>
#include <node/ui_interface.h>
#include <noui.h>
#include <qt/bitcoingui.h>
#include <qt/clientmodel.h>
#include <qt/guiconstants.h>
#include <qt/guiutil.h>
#include <qt/initexecutor.h>
#include <qt/intro.h>
#include <net.h>
#include <qt/networkstyle.h>
#include <qt/optionsmodel.h>
#include <qt/splashscreen.h>
#include <qt/utilitydialog.h>
#include <qt/winshutdownmonitor.h>
#include <stacktraces.h>
#include <uint256.h>
#include <util/string.h>
#include <util/system.h>
#include <util/threadnames.h>
#include <util/translation.h>
#include <validation.h>

#ifdef ENABLE_WALLET
#include <qt/paymentserver.h>
#include <qt/walletcontroller.h>
#include <qt/walletmodel.h>
#endif // ENABLE_WALLET

#include <init.h>
#include <interfaces/handler.h>
#include <interfaces/node.h>
#include <node/context.h>
#include <node/ui_interface.h>
#include <noui.h>
#include <stacktraces.h>
#include <uint256.h>
#include <util/system.h>
#include <util/threadnames.h>
#include <util/translation.h>
#include <validation.h>

#include <boost/signals2/connection.hpp>
#include <memory>

Expand All @@ -52,7 +52,6 @@
#include <QLibraryInfo>
#include <QLocale>
#include <QMessageBox>
#include <QProcess>
#include <QSettings>
#include <QThread>
#include <QTimer>
Expand Down Expand Up @@ -208,72 +207,11 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons
}
}

BitcoinCore::BitcoinCore(interfaces::Node& node) :
QObject(), m_node(node)
{
}

void BitcoinCore::handleRunawayException(const std::exception_ptr e)
{
PrintExceptionContinue(e, "Runaway exception");
Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings().translated));
}

void BitcoinCore::initialize()
{
try
{
util::ThreadRename("qt-init");
qDebug() << __func__ << ": Running initialization in thread";
interfaces::BlockAndHeaderTipInfo tip_info;
bool rv = m_node.appInitMain(&tip_info);
Q_EMIT initializeResult(rv, tip_info);
} catch (...) {
handleRunawayException(std::current_exception());
}
}

void BitcoinCore::restart(QStringList args)
{
static bool executing_restart{false};

if(!executing_restart) { // Only restart 1x, no matter how often a user clicks on a restart-button
executing_restart = true;
try
{
qDebug() << __func__ << ": Running Restart in thread";
m_node.appPrepareShutdown();
qDebug() << __func__ << ": Shutdown finished";
Q_EMIT shutdownResult();
CExplicitNetCleanup::callCleanup();
QProcess::startDetached(QApplication::applicationFilePath(), args);
qDebug() << __func__ << ": Restart initiated...";
QApplication::quit();
} catch (...) {
handleRunawayException(std::current_exception());
}
}
}

void BitcoinCore::shutdown()
{
try
{
qDebug() << __func__ << ": Running Shutdown in thread";
m_node.appShutdown();
qDebug() << __func__ << ": Shutdown finished";
Q_EMIT shutdownResult();
} catch (...) {
handleRunawayException(std::current_exception());
}
}

static int qt_argc = 1;
static const char* qt_argv = "dash-qt";

BitcoinApplication::BitcoinApplication():
QApplication(qt_argc, const_cast<char **>(&qt_argv)),
coreThread(nullptr),
optionsModel(nullptr),
clientModel(nullptr),
window(nullptr),
Expand All @@ -287,13 +225,7 @@ BitcoinApplication::BitcoinApplication():

BitcoinApplication::~BitcoinApplication()
{
if(coreThread)
{
qDebug() << __func__ << ": Stopping thread";
coreThread->quit();
coreThread->wait();
qDebug() << __func__ << ": Stopped thread";
}
m_executor.reset();

delete window;
window = nullptr;
Expand Down Expand Up @@ -350,23 +282,16 @@ bool BitcoinApplication::baseInitialize()

void BitcoinApplication::startThread()
{
if(coreThread)
return;
coreThread = new QThread(this);
BitcoinCore *executor = new BitcoinCore(node());
executor->moveToThread(coreThread);
assert(!m_executor);
m_executor.emplace(node());

/* communication to and from thread */
connect(executor, &BitcoinCore::initializeResult, this, &BitcoinApplication::initializeResult);
connect(executor, &BitcoinCore::shutdownResult, this, &BitcoinApplication::shutdownResult);
connect(executor, &BitcoinCore::runawayException, this, &BitcoinApplication::handleRunawayException);
connect(this, &BitcoinApplication::requestedInitialize, executor, &BitcoinCore::initialize);
connect(this, &BitcoinApplication::requestedShutdown, executor, &BitcoinCore::shutdown);
connect(window, &BitcoinGUI::requestedRestart, executor, &BitcoinCore::restart);
/* make sure executor object is deleted in its own thread */
connect(coreThread, &QThread::finished, executor, &QObject::deleteLater);

coreThread->start();
connect(&m_executor.value(), &InitExecutor::initializeResult, this, &BitcoinApplication::initializeResult);
connect(&m_executor.value(), &InitExecutor::shutdownResult, this, &BitcoinApplication::shutdownResult);
connect(&m_executor.value(), &InitExecutor::runawayException, this, &BitcoinApplication::handleRunawayException);
connect(this, &BitcoinApplication::requestedInitialize, &m_executor.value(), &InitExecutor::initialize);
connect(this, &BitcoinApplication::requestedShutdown, &m_executor.value(), &InitExecutor::shutdown);
connect(window, &BitcoinGUI::requestedRestart, &m_executor.value(), &InitExecutor::restart);
}

void BitcoinApplication::parameterSetup()
Expand Down Expand Up @@ -399,7 +324,6 @@ void BitcoinApplication::requestShutdown()
shutdownWindow.reset(ShutdownWindow::showShutdownWindow(window));

qDebug() << __func__ << ": Requesting shutdown";
startThread();
window->hide();
// Must disconnect node signals otherwise current thread can deadlock since
// no event loop is running.
Expand Down
35 changes: 6 additions & 29 deletions src/qt/bitcoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
#include <config/bitcoin-config.h>
#endif

#include <QApplication>
#include <interfaces/node.h>
#include <qt/initexecutor.h>

#include <assert.h>
#include <memory>
#include <optional>

#include <interfaces/node.h>
#include <QApplication>

class BitcoinGUI;
class ClientModel;
Expand All @@ -25,32 +28,6 @@ class WalletController;
class WalletModel;


/** Class encapsulating Bitcoin Core startup and shutdown.
* Allows running startup and shutdown in a different thread from the UI thread.
*/
class BitcoinCore: public QObject
{
Q_OBJECT
public:
explicit BitcoinCore(interfaces::Node& node);

public Q_SLOTS:
void initialize();
void shutdown();
void restart(QStringList args);

Q_SIGNALS:
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
void shutdownResult();
void runawayException(const QString &message);

private:
/// Pass fatal exception message to UI thread
void handleRunawayException(const std::exception_ptr e);

interfaces::Node& m_node;
};

/** Main Bitcoin application object */
class BitcoinApplication: public QApplication
{
Expand Down Expand Up @@ -113,7 +90,7 @@ public Q_SLOTS:
bool event(QEvent* e) override;

private:
QThread *coreThread;
std::optional<InitExecutor> m_executor;
OptionsModel *optionsModel;
ClientModel *clientModel;
BitcoinGUI *window;
Expand Down
Loading
Loading