Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/dashpay/dash into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
PastaPastaPasta committed Jul 19, 2024
2 parents f899c0f + debc706 commit b7db492
Show file tree
Hide file tree
Showing 50 changed files with 681 additions and 794 deletions.
6 changes: 3 additions & 3 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

| Version | Supported |
| ------- | ------------------ |
| 0.17 | :white_check_mark: |
| 0.16 | :white_check_mark: |
| < 0.16 | :x: |
| 21 | :white_check_mark: |
| 20.1 | :white_check_mark: |
| < 20.1 | :x: |

## Reporting a Vulnerability

Expand Down
2 changes: 0 additions & 2 deletions ci/dash/build_src.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ if [ "$CHECK_DOC" = 1 ]; then
#test/lint/git-subtree-check.sh src/leveldb
# TODO: Check docs (re-enable after all Bitcoin PRs have been merged and docs fully fixed)
#test/lint/check-doc.py
# Check rpc consistency
test/lint/check-rpc-mappings.py .
# Run all linters
test/lint/lint-all.sh
test/lint/extended-lint-all.sh
Expand Down
1 change: 0 additions & 1 deletion ci/lint/06_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ test/lint/git-subtree-check.sh src/secp256k1
test/lint/git-subtree-check.sh src/univalue
test/lint/git-subtree-check.sh src/leveldb
test/lint/check-doc.py
test/lint/check-rpc-mappings.py .
test/lint/lint-all.sh

if [ "$CIRRUS_REPO_FULL_NAME" = "dashpay/dash" ] && [ -n "$CIRRUS_CRON" ]; then
Expand Down
11 changes: 6 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,12 @@ AX_BOOST_BASE([1.64.0],[],[AC_MSG_ERROR([Boost is not available!])])
if test x$want_boost = xno; then
AC_MSG_ERROR([[only libdashconsensus can be built without boost]])
fi

dnl Prevent use of std::unary_function, which was removed in C++17,
dnl and will generate warnings with newer compilers.
dnl See: https://github.com/boostorg/container_hash/issues/22.
BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_NO_CXX98_FUNCTION_BASE"

AX_BOOST_FILESYSTEM

dnl Opt-in to Boost Process
Expand All @@ -1471,11 +1477,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <boost/process.hpp>]],
fi

if test x$suppress_external_warnings != xno; then
dnl Prevent use of std::unary_function, which was removed in C++17,
dnl and will generate warnings with newer compilers.
dnl See: https://github.com/boostorg/container_hash/issues/22.
BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_NO_CXX98_FUNCTION_BASE"

BOOST_CPPFLAGS=SUPPRESS_WARNINGS($BOOST_CPPFLAGS)
fi

Expand Down
1 change: 1 addition & 0 deletions depends/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ PATCHES_PATH = $(BASEDIR)/patches
BASEDIR = $(CURDIR)
HASH_LENGTH:=11
DOWNLOAD_CONNECT_TIMEOUT:=30
DOWNLOAD_RETRIES:=3
HOST_ID_SALT ?= salt
BUILD_ID_SALT ?= salt

Expand Down
2 changes: 1 addition & 1 deletion depends/builders/darwin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build_darwin_OTOOL:=$(shell xcrun -f otool)
build_darwin_NM:=$(shell xcrun -f nm)
build_darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool)
build_darwin_SHA256SUM=shasum -a 256
build_darwin_DOWNLOAD=curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) -o
build_darwin_DOWNLOAD=curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o

#darwin host on darwin builder. overrides darwin host preferences.
darwin_CC=$(shell xcrun -f clang) -mmacosx-version-min=$(OSX_MIN_VERSION) -isysroot$(shell xcrun --show-sdk-path)
Expand Down
2 changes: 1 addition & 1 deletion depends/builders/linux.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
build_linux_SHA256SUM = sha256sum
build_linux_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) -o
build_linux_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o
2 changes: 0 additions & 2 deletions depends/funcs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ endef
define fetch_file
( test -f $$($(1)_source_dir)/$(4) || \
( $(call fetch_file_inner,$(1),$(2),$(3),$(4),$(5)) || \
(sleep 5 && $(call fetch_file_inner,$(1),$(2),$(3),$(4),$(5))) || \
(sleep 10 && $(call fetch_file_inner,$(1),$(2),$(3),$(4),$(5))) || \
$(call fetch_file_inner,$(1),$(FALLBACK_DOWNLOAD_PATH),$(3),$(4),$(5))))
endef

Expand Down
8 changes: 1 addition & 7 deletions depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,21 @@ $(package)_config_opts_i686_android=address-model=32
$(package)_config_opts_aarch64_android=address-model=64
$(package)_config_opts_x86_64_android=address-model=64
$(package)_config_opts_armv7a_android=address-model=32
unary_function=unary_function
ifneq (,$(findstring clang,$($(package)_cxx)))
$(package)_toolset_$(host_os)=clang
ifeq ($(build_os),darwin)
unary_function=__unary_function
endif
else
$(package)_toolset_$(host_os)=gcc
endif
$(package)_config_libraries=filesystem,test
$(package)_cxxflags=-std=c++17
$(package)_cxxflags=-std=c++11
$(package)_cxxflags_linux=-fPIC
$(package)_cxxflags_freebsd=-fPIC
$(package)_cxxflags_openbsd=-fPIC
$(package)_cxxflags_android=-fPIC
$(package)_cxxflags_x86_64=-fcf-protection=full
endef

# Fix missing unary_function in clang15 on macos, can be removed after upgrading to 1.81
define $(package)_preprocess_cmds
sed -i.old "s/unary_function/$(unary_function)/" boost/container_hash/hash.hpp && \
echo "using $($(package)_toolset_$(host_os)) : : $($(package)_cxx) : <cflags>\"$($(package)_cflags)\" <cxxflags>\"$($(package)_cxxflags)\" <compileflags>\"$($(package)_cppflags)\" <linkflags>\"$($(package)_ldflags)\" <archiver>\"$($(package)_ar)\" <striper>\"$(host_STRIP)\" <ranlib>\"$(host_RANLIB)\" <rc>\"$(host_WINDRES)\" : ;" > user-config.jam
endef

Expand Down
2 changes: 1 addition & 1 deletion src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static bool AppInit(int argc, char* argv[])
// If locking the data directory failed, exit immediately
return false;
}
fRet = AppInitInterfaces(node) && AppInitMain(context, node);
fRet = AppInitInterfaces(node) && AppInitMain(node);
} catch (...) {
PrintExceptionContinue(std::current_exception(), "AppInit()");
}
Expand Down
4 changes: 2 additions & 2 deletions src/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifndef BITCOIN_CONTEXT_H
#define BITCOIN_CONTEXT_H

#include <functional>
#include <variant>
#include <optional>

class ChainstateManager;
class CTxMemPool;
Expand All @@ -15,7 +15,7 @@ struct LLMQContext;
struct NodeContext;
struct WalletContext;

using CoreContext = std::variant<std::nullopt_t,
using CoreContext = std::variant<std::monostate,
std::reference_wrapper<NodeContext>,
std::reference_wrapper<WalletContext>,
std::reference_wrapper<CTxMemPool>,
Expand Down
6 changes: 3 additions & 3 deletions src/httprpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ static bool HTTPReq_JSONRPC(const CoreContext& context, HTTPRequest* req)
return rpcRequest.send_reply(HTTP_UNAUTHORIZED);
}

JSONRPCRequest jreq(context);

JSONRPCRequest jreq;
jreq.context = context;
jreq.peerAddr = req->GetPeer().ToString();
if (!RPCAuthorized(authHeader.second, rpcRequest.user)) {
LogPrintf("ThreadRPCServer incorrect password attempt from %s\n", jreq.peerAddr);
Expand Down Expand Up @@ -335,7 +335,7 @@ bool StartHTTPRPC(const CoreContext& context)
if (!InitRPCAuthentication())
return false;

auto handle_rpc = [&context](HTTPRequest* req, const std::string&) { return HTTPReq_JSONRPC(context, req); };
auto handle_rpc = [context](HTTPRequest* req, const std::string&) { return HTTPReq_JSONRPC(context, req); };
RegisterHTTPHandler("/", true, handle_rpc);
if (g_wallet_init_interface.HasWalletSupport()) {
RegisterHTTPHandler("/wallet/", false, handle_rpc);
Expand Down
10 changes: 5 additions & 5 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ static bool InitSanityCheck()
return true;
}

static bool AppInitServers(const CoreContext& context, NodeContext& node)
static bool AppInitServers(NodeContext& node)
{
const ArgsManager& args = *Assert(node.args);
RPCServer::OnStarted(&OnRPCStarted);
Expand All @@ -969,9 +969,9 @@ static bool AppInitServers(const CoreContext& context, NodeContext& node)
return false;
StartRPC();
node.rpc_interruption_point = RpcInterruptionPoint;
if (!StartHTTPRPC(context))
if (!StartHTTPRPC(node))
return false;
if (args.GetBoolArg("-rest", DEFAULT_REST_ENABLE)) StartREST(context);
if (args.GetBoolArg("-rest", DEFAULT_REST_ENABLE)) StartREST(node);
StartHTTPServer();
return true;
}
Expand Down Expand Up @@ -1536,7 +1536,7 @@ bool AppInitInterfaces(NodeContext& node)
return true;
}

bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
{
const ArgsManager& args = *Assert(node.args);
const CChainParams& chainparams = Params();
Expand Down Expand Up @@ -1643,7 +1643,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
*/
if (args.GetBoolArg("-server", false)) {
uiInterface.InitMessage_connect(SetRPCWarmupStatus);
if (!AppInitServers(context, node))
if (!AppInitServers(node))
return InitError(_("Unable to start HTTP server. See debug log for details."));
}

Expand Down
2 changes: 1 addition & 1 deletion src/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool AppInitInterfaces(NodeContext& node);
* @note This should only be done after daemonization. Call Shutdown() if this function fails.
* @pre Parameters should be parsed and config file should be read, AppInitLockDataDirectory should have been called.
*/
bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);
bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);
void PrepareShutdown(NodeContext& node);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class Node
virtual UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) = 0;

//! List rpc commands.
virtual std::vector<std::pair<std::string, std::string>> listRpcCommands() = 0;
virtual std::vector<std::string> listRpcCommands() = 0;

//! Set RPC timer interface if unset.
virtual void rpcSetTimerInterfaceIfUnset(RPCTimerInterface* iface) = 0;
Expand Down
19 changes: 7 additions & 12 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include <memory>
#include <optional>
#include <utility>
#include <variant>

using interfaces::BlockTip;
using interfaces::Chain;
Expand Down Expand Up @@ -317,7 +318,7 @@ class NodeImpl : public Node
}
bool appInitMain(interfaces::BlockAndHeaderTipInfo* tip_info) override
{
return AppInitMain(m_context_ref, *m_context, tip_info);
return AppInitMain(*m_context, tip_info);
}
void appShutdown() override
{
Expand Down Expand Up @@ -479,13 +480,14 @@ class NodeImpl : public Node
CFeeRate getDustRelayFee() override { return ::dustRelayFee; }
UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) override
{
JSONRPCRequest req(m_context_ref);
JSONRPCRequest req;
req.context = *m_context;
req.params = params;
req.strMethod = command;
req.URI = uri;
return ::tableRPC.execute(req);
}
std::vector<std::pair<std::string, std::string>> listRpcCommands() override { return ::tableRPC.listCommands(); }
std::vector<std::string> listRpcCommands() override { return ::tableRPC.listCommands(); }
void rpcSetTimerInterfaceIfUnset(RPCTimerInterface* iface) override { RPCSetTimerInterfaceIfUnset(iface); }
void rpcUnsetTimerInterface(RPCTimerInterface* iface) override { RPCUnsetTimerInterface(iface); }
bool getUnspentOutput(const COutPoint& output, Coin& coin) override
Expand Down Expand Up @@ -580,15 +582,8 @@ class NodeImpl : public Node
m_gov.setContext(context);
m_llmq.setContext(context);
m_masternodeSync.setContext(context);

if (context) {
m_context_ref = *context;
} else {
m_context_ref = std::nullopt;
}
}
NodeContext* m_context{nullptr};
CoreContext m_context_ref{std::nullopt};
};

bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<RecursiveMutex>& lock, const CChain& active)
Expand Down Expand Up @@ -688,14 +683,14 @@ class RpcHandlerImpl : public Handler
throw;
}
};
::tableRPC.appendCommand(m_command.name, m_command.subname, &m_command);
::tableRPC.appendCommand(m_command.name, &m_command);
}

void disconnect() override final
{
if (m_wrapped_command) {
m_wrapped_command = nullptr;
::tableRPC.removeCommand(m_command.name, m_command.subname, &m_command);
::tableRPC.removeCommand(m_command.name, &m_command);
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,15 +773,11 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_

//Setup autocomplete and attach it
QStringList wordList;
std::vector<std::pair<std::string, std::string>> commandList = m_node.listRpcCommands();
std::vector<std::string> commandList = m_node.listRpcCommands();
for (size_t i = 0; i < commandList.size(); ++i)
{
std::string command = commandList[i].first;
if (!commandList[i].second.empty()) {
command = command + " " + commandList[i].second;
}
wordList << command.c_str();
wordList << ("help " + command).c_str();
wordList << commandList[i].c_str();
wordList << ("help " + commandList[i]).c_str();
}

wordList << "help-console";
Expand Down
25 changes: 17 additions & 8 deletions src/qt/test/rpcnestedtests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,26 @@
#include <QDir>
#include <QtGlobal>

static UniValue rpcNestedTest_rpc(const JSONRPCRequest& request)
static RPCHelpMan rpcNestedTest_rpc()
{
if (request.fHelp) {
return "help message";
}
return request.params.write(0, 0);
return RPCHelpMan{
"rpcNestedTest",
"echo the passed string(s)",
{
{"arg1", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
{"arg2", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
{"arg3", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
},
{},
RPCExamples{""},
[](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
return request.params.write(0, 0);
},
};
}

static const CRPCCommand vRPCCommands[] =
{
{ "test", "rpcNestedTest", &rpcNestedTest_rpc, {} },
static const CRPCCommand vRPCCommands[] = {
{"test", &rpcNestedTest_rpc},
};

void RPCNestedTests::rpcNestedTests()
Expand Down
5 changes: 3 additions & 2 deletions src/rest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ static bool rest_chaininfo(const CoreContext& context, HTTPRequest* req, const s

switch (rf) {
case RetFormat::JSON: {
JSONRPCRequest jsonRequest(context);
JSONRPCRequest jsonRequest;
jsonRequest.context = context;
jsonRequest.params = UniValue(UniValue::VARR);
UniValue chainInfoObject = getblockchaininfo().HandleRequest(jsonRequest);
std::string strJSON = chainInfoObject.write() + "\n";
Expand Down Expand Up @@ -724,7 +725,7 @@ static const struct {
void StartREST(const CoreContext& context)
{
for (const auto& up : uri_prefixes) {
auto handler = [&context, up](HTTPRequest* req, const std::string& prefix) { return up.handler(context, req, prefix); };
auto handler = [context, up](HTTPRequest* req, const std::string& prefix) { return up.handler(context, req, prefix); };
RegisterHTTPHandler(up.prefix, false, handler);
}
}
Expand Down
Loading

0 comments on commit b7db492

Please sign in to comment.