Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Nov 24, 2023
2 parents e9618fe + 930bcfd commit 6c03708
Show file tree
Hide file tree
Showing 36 changed files with 500 additions and 217 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ jobs:
# ancestors from the rev-list output as described in:
# https://git-scm.com/docs/git-rev-list
echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD ^$(git rev-list -n1 --merges HEAD)^@ | head -1)" >> "$GITHUB_ENV"
- run: sudo apt install clang ccache build-essential libtool autotools-dev automake pkg-config bsdmainutils python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
- run: |
sudo apt-get update
sudo apt-get install clang ccache build-essential libtool autotools-dev automake pkg-config bsdmainutils python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
- name: Compile and run tests
run: |
# Run tests on commits after the last merge commit and before the PR head commit
Expand Down
9 changes: 0 additions & 9 deletions ci/lint/06_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@ else
fi
export COMMIT_RANGE

# This only checks that the trees are pure subtrees, it is not doing a full
# check with -r to not have to fetch all the remotes.
test/lint/git-subtree-check.sh src/crypto/ctaes
test/lint/git-subtree-check.sh src/secp256k1
test/lint/git-subtree-check.sh src/minisketch
test/lint/git-subtree-check.sh src/leveldb
test/lint/git-subtree-check.sh src/crc32c
RUST_BACKTRACE=1 "${LINT_RUNNER_PATH}/test_runner"
test/lint/check-doc.py
test/lint/all-lint.py

if [ "$CIRRUS_REPO_FULL_NAME" = "groestlcoin/groestlcoin" ] && [ "$CIRRUS_PR" = "" ] ; then
# Sanity check only the last few commits to get notified of missing sigs,
Expand Down
1 change: 1 addition & 0 deletions ci/lint_imagefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ENV LC_ALL=C.UTF-8
COPY ./.python-version /.python-version
COPY ./ci/lint/container-entrypoint.sh /entrypoint.sh
COPY ./ci/lint/04_install.sh /install.sh
COPY ./test/lint/test_runner /test/lint/test_runner

RUN /install.sh && \
echo 'alias lint="./ci/lint/06_script.sh"' >> ~/.bashrc && \
Expand Down
1 change: 0 additions & 1 deletion ci/test/00_setup_env_i686_multiprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ export DEP_OPTS="DEBUG=1 MULTIPROCESS=1"
export GOAL="install"
export GROESTLCOIN_CONFIG="--enable-debug CC='clang -m32' CXX='clang++ -m32' \
LDFLAGS='--rtlib=compiler-rt -lgcc_s' CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE'"
export NO_WERROR=1 # Temporary workaround to avoid -Wdeprecated-declarations from KJ
8 changes: 1 addition & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
CXXFLAGS="$TEMP_CXXFLAGS"

# ARM
AX_CHECK_COMPILE_FLAG([-march=armv8-a+crc], [ARM_CRC_CXXFLAGS="-march=armv8-a+crc"], [], [$CXXFLAG_WERROR])
AX_CHECK_COMPILE_FLAG([-march=armv8-a+crc+crypto], [ARM_CRC_CXXFLAGS="-march=armv8-a+crc+crypto"], [], [$CXXFLAG_WERROR])
AX_CHECK_COMPILE_FLAG([-march=armv8-a+crypto], [ARM_SHANI_CXXFLAGS="-march=armv8-a+crypto"], [], [$CXXFLAG_WERROR])

TEMP_CXXFLAGS="$CXXFLAGS"
Expand Down Expand Up @@ -986,12 +986,6 @@ if test "$use_hardening" != "no"; then
AX_CHECK_LINK_FLAG([-Wl,-z,now], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"], [], [$LDFLAG_WERROR])
AX_CHECK_LINK_FLAG([-Wl,-z,separate-code], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,separate-code"], [], [$LDFLAG_WERROR])
AX_CHECK_LINK_FLAG([-fPIE -pie], [PIE_FLAGS="-fPIE"; HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"], [], [$CXXFLAG_WERROR])

case $host in
*mingw*)
AC_CHECK_LIB([ssp], [main], [], [AC_MSG_ERROR([libssp missing])])
;;
esac
fi

dnl These flags are specific to ld64, and may cause issues with other linkers.
Expand Down
8 changes: 2 additions & 6 deletions contrib/guix/manifest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,8 @@ inspecting signatures in Mach-O binaries.")
`(append ,flags
;; https://gcc.gnu.org/install/configure.html
(list "--enable-threads=posix",
building-on)))
((#:make-flags flags)
;; Uses the SSP functions from glibc instead of from libssp.so.
;; Our 'symbol-check' script will complain if we link against libssp.so,
;; and thus will ensure that this works properly.
`(cons "gcc_cv_libc_provides_ssp=yes" ,flags))))))
"--enable-default-ssp=yes",
building-on)))))))

(define-public linux-base-gcc
(package
Expand Down
4 changes: 2 additions & 2 deletions depends/packages/native_libmultiprocess.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package=native_libmultiprocess
$(package)_version=61d5a0e661f20a4928fbf868ec9c3c6f17883cc7
$(package)_version=414542f81e0997354b45b8ade13ca144a3e35ff1
$(package)_download_path=https://github.com/chaincodelabs/libmultiprocess/archive
$(package)_file_name=$($(package)_version).tar.gz
$(package)_sha256_hash=5cfda224cc2ce913f2493f843317e0fca3184f6d7c1434c9754b2e7dca440ab5
$(package)_sha256_hash=8542dbaf8c4fce8fd7af6929f5dc9b34dffa51c43e9ee360e93ee0f34b180bc2
$(package)_dependencies=native_capnp

define $(package)_config_cmds
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ FUZZ_WALLET_SRC = \

if USE_SQLITE
FUZZ_WALLET_SRC += \
wallet/test/fuzz/notifications.cpp
wallet/test/fuzz/notifications.cpp \
wallet/test/fuzz/scriptpubkeyman.cpp
endif # USE_SQLITE

BITCOIN_TEST_SUITE += \
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.test_fuzz.include
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ TEST_FUZZ_H = \
test/fuzz/fuzz.h \
test/fuzz/FuzzedDataProvider.h \
test/fuzz/util.h \
test/fuzz/util/descriptor.h \
test/fuzz/util/mempool.h \
test/fuzz/util/net.h

Expand All @@ -19,6 +20,7 @@ libtest_fuzz_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libtest_fuzz_a_SOURCES = \
test/fuzz/fuzz.cpp \
test/fuzz/util.cpp \
test/fuzz/util/descriptor.cpp \
test/fuzz/util/mempool.cpp \
test/fuzz/util/net.cpp \
$(TEST_FUZZ_H)
2 changes: 1 addition & 1 deletion src/bench/load_external.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void LoadExternalBlockFile(benchmark::Bench& bench)
bench.run([&] {
// "rb" is "binary, O_RDONLY", positioned to the start of the file.
// The file will be closed by LoadExternalBlockFile().
CAutoFile file{fsbridge::fopen(blkfile, "rb"), CLIENT_VERSION};
AutoFile file{fsbridge::fopen(blkfile, "rb")};
testing_setup->m_node.chainman->LoadExternalBlockFile(file, &pos, &blocks_with_unknown_parent);
});
fs::remove(blkfile);
Expand Down
3 changes: 1 addition & 2 deletions src/bench/pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ static void PoolAllocator_StdUnorderedMapWithPoolResource(benchmark::Bench& benc
std::hash<uint64_t>,
std::equal_to<uint64_t>,
PoolAllocator<std::pair<const uint64_t, uint64_t>,
sizeof(std::pair<const uint64_t, uint64_t>) + 4 * sizeof(void*),
alignof(void*)>>;
sizeof(std::pair<const uint64_t, uint64_t>) + 4 * sizeof(void*)>>;

// make sure the resource supports large enough pools to hold the node. We do this by adding the size of a few pointers to it.
auto pool_resource = Map::allocator_type::ResourceType();
Expand Down
2 changes: 1 addition & 1 deletion src/bench/streams_findbyte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
static void FindByte(benchmark::Bench& bench)
{
// Setup
CAutoFile file{fsbridge::fopen("streams_tmp", "w+b"), 0};
AutoFile file{fsbridge::fopen("streams_tmp", "w+b")};
const size_t file_size = 200;
uint8_t data[file_size] = {0};
data[file_size-1] = 1;
Expand Down
3 changes: 1 addition & 2 deletions src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ using CCoinsMap = std::unordered_map<COutPoint,
SaltedOutpointHasher,
std::equal_to<COutPoint>,
PoolAllocator<std::pair<const COutPoint, CCoinsCacheEntry>,
sizeof(std::pair<const COutPoint, CCoinsCacheEntry>) + sizeof(void*) * 4,
alignof(void*)>>;
sizeof(std::pair<const COutPoint, CCoinsCacheEntry>) + sizeof(void*) * 4>>;

using CCoinsMapMemoryResource = CCoinsMap::allocator_type::ResourceType;

Expand Down
2 changes: 1 addition & 1 deletion src/index/txindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ bool TxIndex::FindTx(const uint256& tx_hash, uint256& block_hash, CTransactionRe
return false;
}

CAutoFile file{m_chainstate->m_blockman.OpenBlockFile(postx, true)};
AutoFile file{m_chainstate->m_blockman.OpenBlockFile(postx, true)};
if (file.IsNull()) {
return error("%s: OpenBlockFile failed", __func__);
}
Expand Down
22 changes: 22 additions & 0 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2716,6 +2716,17 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
continue;
}

// Do not make automatic outbound connections to addnode peers, to
// not use our limited outbound slots for them and to ensure
// addnode connections benefit from their intended protections.
if (AddedNodesContain(addr)) {
LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "Not making automatic %s%s connection to %s peer selected for manual (addnode) connection%s\n",
preferred_net.has_value() ? "network-specific " : "",
ConnectionTypeAsString(conn_type), GetNetworkName(addr.GetNetwork()),
fLogIPs ? strprintf(": %s", addr.ToStringAddrPort()) : "");
continue;
}

addrConnect = addr;
break;
}
Expand Down Expand Up @@ -3455,6 +3466,17 @@ bool CConnman::RemoveAddedNode(const std::string& strNode)
return false;
}

bool CConnman::AddedNodesContain(const CAddress& addr) const
{
AssertLockNotHeld(m_added_nodes_mutex);
const std::string addr_str{addr.ToStringAddr()};
const std::string addr_port_str{addr.ToStringAddrPort()};
LOCK(m_added_nodes_mutex);
return (m_added_node_params.size() < 24 // bound the query to a reasonable limit
&& std::any_of(m_added_node_params.cbegin(), m_added_node_params.cend(),
[&](const auto& p) { return p.m_added_node == addr_str || p.m_added_node == addr_port_str; }));
}

size_t CConnman::GetNodeCount(ConnectionDirection flags) const
{
LOCK(m_nodes_mutex);
Expand Down
1 change: 1 addition & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ class CConnman

bool AddNode(const AddedNodeParams& add) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
bool RemoveAddedNode(const std::string& node) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
bool AddedNodesContain(const CAddress& addr) const EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
std::vector<AddedNodeInfo> GetAddedNodeInfo(bool include_connected) const EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);

/**
Expand Down
35 changes: 22 additions & 13 deletions src/node/blockstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@

#include <node/blockstorage.h>

#include <arith_uint256.h>
#include <chain.h>
#include <clientversion.h>
#include <consensus/params.h>
#include <consensus/validation.h>
#include <dbwrapper.h>
#include <flatfile.h>
#include <hash.h>
#include <kernel/chain.h>
#include <kernel/blockmanager_opts.h>
#include <kernel/chainparams.h>
#include <kernel/messagestartchars.h>
#include <kernel/notifications_interface.h>
#include <logging.h>
#include <pow.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <reverse_iterator.h>
#include <serialize.h>
#include <signet.h>
#include <span.h>
#include <streams.h>
#include <sync.h>
#include <tinyformat.h>
#include <uint256.h>
#include <undo.h>
#include <util/batchpriority.h>
#include <util/check.h>
#include <util/fs.h>
#include <util/signalinterrupt.h>
#include <util/strencodings.h>
Expand Down Expand Up @@ -656,7 +665,7 @@ CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock) const
{
// Open history file to append
CAutoFile fileout{OpenUndoFile(pos)};
AutoFile fileout{OpenUndoFile(pos)};
if (fileout.IsNull()) {
return error("%s: OpenUndoFile failed", __func__);
}
Expand Down Expand Up @@ -691,7 +700,7 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
}

// Open history file to read
CAutoFile filein{OpenUndoFile(pos, true)};
AutoFile filein{OpenUndoFile(pos, true)};
if (filein.IsNull()) {
return error("%s: OpenUndoFile failed", __func__);
}
Expand Down Expand Up @@ -810,15 +819,15 @@ FlatFileSeq BlockManager::UndoFileSeq() const
return FlatFileSeq(m_opts.blocks_dir, "rev", UNDOFILE_CHUNK_SIZE);
}

CAutoFile BlockManager::OpenBlockFile(const FlatFilePos& pos, bool fReadOnly) const
AutoFile BlockManager::OpenBlockFile(const FlatFilePos& pos, bool fReadOnly) const
{
return CAutoFile{BlockFileSeq().Open(pos, fReadOnly), CLIENT_VERSION};
return AutoFile{BlockFileSeq().Open(pos, fReadOnly)};
}

/** Open an undo file (rev?????.dat) */
CAutoFile BlockManager::OpenUndoFile(const FlatFilePos& pos, bool fReadOnly) const
AutoFile BlockManager::OpenUndoFile(const FlatFilePos& pos, bool fReadOnly) const
{
return CAutoFile{UndoFileSeq().Open(pos, fReadOnly), CLIENT_VERSION};
return AutoFile{UndoFileSeq().Open(pos, fReadOnly)};
}

fs::path BlockManager::GetBlockPosFilename(const FlatFilePos& pos) const
Expand Down Expand Up @@ -950,7 +959,7 @@ bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFileP
bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
{
// Open history file to append
CAutoFile fileout{OpenBlockFile(pos)};
AutoFile fileout{OpenBlockFile(pos)};
if (fileout.IsNull()) {
return error("WriteBlockToDisk: OpenBlockFile failed");
}
Expand Down Expand Up @@ -1016,7 +1025,7 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos) cons
block.SetNull();

// Open history file to read
CAutoFile filein{OpenBlockFile(pos, true)};
AutoFile filein{OpenBlockFile(pos, true)};
if (filein.IsNull()) {
return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString());
}
Expand Down Expand Up @@ -1059,7 +1068,7 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
{
FlatFilePos hpos = pos;
hpos.nPos -= 8; // Seek back 8 bytes for meta header
CAutoFile filein{OpenBlockFile(hpos, true)};
AutoFile filein{OpenBlockFile(hpos, true)};
if (filein.IsNull()) {
return error("%s: OpenBlockFile failed for %s", __func__, pos.ToString());
}
Expand Down Expand Up @@ -1151,7 +1160,7 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
if (!fs::exists(chainman.m_blockman.GetBlockPosFilename(pos))) {
break; // No block files left to reindex
}
CAutoFile file{chainman.m_blockman.OpenBlockFile(pos, true)};
AutoFile file{chainman.m_blockman.OpenBlockFile(pos, true)};
if (file.IsNull()) {
break; // This error is logged in OpenBlockFile
}
Expand All @@ -1172,7 +1181,7 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile

// -loadblock=
for (const fs::path& path : vImportFiles) {
CAutoFile file{fsbridge::fopen(path, "rb"), CLIENT_VERSION};
AutoFile file{fsbridge::fopen(path, "rb")};
if (!file.IsNull()) {
LogPrintf("Importing blocks file %s...\n", fs::PathToString(path));
chainman.LoadExternalBlockFile(file);
Expand Down
16 changes: 8 additions & 8 deletions src/node/blockstorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@
#include <attributes.h>
#include <chain.h>
#include <dbwrapper.h>
#include <flatfile.h>
#include <kernel/blockmanager_opts.h>
#include <kernel/chain.h>
#include <kernel/chainparams.h>
#include <kernel/cs_main.h>
#include <kernel/messagestartchars.h>
#include <primitives/block.h>
#include <streams.h>
#include <sync.h>
#include <uint256.h>
#include <util/fs.h>
#include <util/hasher.h>

#include <array>
#include <atomic>
#include <cstdint>
#include <functional>
#include <limits>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

class BlockValidationState;
class CAutoFile;
class CBlock;
class CBlockUndo;
class CChainParams;
class Chainstate;
class ChainstateManager;
struct CCheckpointData;
struct FlatFilePos;
namespace Consensus {
struct Params;
}
Expand Down Expand Up @@ -162,7 +162,7 @@ class BlockManager
FlatFileSeq BlockFileSeq() const;
FlatFileSeq UndoFileSeq() const;

CAutoFile OpenUndoFile(const FlatFilePos& pos, bool fReadOnly = false) const;
AutoFile OpenUndoFile(const FlatFilePos& pos, bool fReadOnly = false) const;

bool WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const;
bool UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock) const;
Expand Down Expand Up @@ -350,7 +350,7 @@ class BlockManager
void UpdatePruneLock(const std::string& name, const PruneLockInfo& lock_info) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);

/** Open a block file (blk?????.dat) */
CAutoFile OpenBlockFile(const FlatFilePos& pos, bool fReadOnly = false) const;
AutoFile OpenBlockFile(const FlatFilePos& pos, bool fReadOnly = false) const;

/** Translation to a filesystem path */
fs::path GetBlockPosFilename(const FlatFilePos& pos) const;
Expand Down
Loading

0 comments on commit 6c03708

Please sign in to comment.