Skip to content

Commit

Permalink
Merge branch 'auxpow'
Browse files Browse the repository at this point in the history
  • Loading branch information
domob1812 committed Nov 18, 2024
2 parents 6927e03 + 73c0f4b commit 12ef104
Show file tree
Hide file tree
Showing 100 changed files with 1,935 additions and 475 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,20 @@ jobs:
run: |
# Run tests on commits after the last merge commit and before the PR head commit
# Use clang++, because it is a bit faster and uses less memory than g++
git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && CC=clang CXX=clang++ cmake -B build -DWERROR=ON -DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_BDB=ON -DWITH_USDT=ON -DCMAKE_CXX_FLAGS='-Wno-error=unused-member-function' && cmake --build build -j $(nproc) && ctest --output-on-failure --test-dir build -j $(nproc) && ./build/test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }}
git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && CC=clang CXX=clang++ cmake -B build -DWERROR=ON -DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_BDB=ON -DWITH_USDT=ON -DCMAKE_CXX_FLAGS='-Wno-error=unused-member-function' && cmake --build build -j $(nproc) && ctest --output-on-failure --stop-on-failure --test-dir build -j $(nproc) && ./build/test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }}
macos-native-arm64:
name: 'macOS 14 native, arm64, no depends, sqlite only, gui'
# Use latest image, but hardcode version to avoid silent upgrades (and breaks).
# See: https://github.com/actions/runner-images#available-images.
runs-on: macos-14

# No need to run on the read-only mirror, unless it is a PR.
if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request'
# When a contributor maintains a fork of the repo, any pull request they make
# to their own fork, or to the main repository, will trigger two CI runs:
# one for the branch push and one for the pull request.
# This can be avoided by setting SKIP_BRANCH_PUSH=true as a custom env variable
# in Github repository settings.
if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }}

timeout-minutes: 120

Expand Down Expand Up @@ -135,8 +139,7 @@ jobs:
# See: https://github.com/actions/runner-images#available-images.
runs-on: windows-2022

# No need to run on the read-only mirror, unless it is a PR.
if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request'
if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }}

env:
PYTHONUTF8: 1
Expand Down Expand Up @@ -199,7 +202,7 @@ jobs:
- name: Run test suite
working-directory: build
run: |
ctest --output-on-failure -j $env:NUMBER_OF_PROCESSORS -C Release
ctest --output-on-failure --stop-on-failure -j $env:NUMBER_OF_PROCESSORS -C Release
- name: Run functional tests
working-directory: build
Expand All @@ -215,8 +218,7 @@ jobs:
asan-lsan-ubsan-integer-no-depends-usdt:
name: 'ASan + LSan + UBSan + integer, no depends, USDT'
runs-on: ubuntu-24.04 # has to match container in ci/test/00_setup_env_native_asan.sh for tracing tools
# No need to run on the read-only mirror, unless it is a PR.
if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request'
if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }}
timeout-minutes: 120
env:
FILE_ENV: "./ci/test/00_setup_env_native_asan.sh"
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_i686_centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export LC_ALL=C.UTF-8
export HOST=i686-pc-linux-gnu
export CONTAINER_NAME=ci_i686_centos
export CI_IMAGE_NAME_TAG="quay.io/centos/amd64:stream9"
export CI_BASE_PACKAGES="gcc-c++ glibc-devel.x86_64 libstdc++-devel.x86_64 glibc-devel.i686 libstdc++-devel.i686 ccache make git python3 python3-pip which patch lbzip2 xz procps-ng dash rsync coreutils bison util-linux e2fsprogs cmake"
export CI_BASE_PACKAGES="gcc-c++ glibc-devel.x86_64 libstdc++-devel.x86_64 glibc-devel.i686 libstdc++-devel.i686 ccache make git python3 python3-pip which patch lbzip2 xz procps-ng dash rsync coreutils bison e2fsprogs cmake"
export PIP_PACKAGES="pyzmq"
export GOAL="install"
export NO_WERROR=1 # Suppress error: #warning _FORTIFY_SOURCE > 2 is treated like 2 on this platform [-Werror=cpp]
Expand Down
2 changes: 1 addition & 1 deletion ci/test/03_test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ if [ "$RUN_CHECK_DEPS" = "true" ]; then
fi

if [ "$RUN_UNIT_TESTS" = "true" ]; then
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" CTEST_OUTPUT_ON_FAILURE=ON ctest "${MAKEJOBS}" --timeout $(( TEST_RUNNER_TIMEOUT_FACTOR * 60 ))
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" CTEST_OUTPUT_ON_FAILURE=ON ctest --stop-on-failure "${MAKEJOBS}" --timeout $(( TEST_RUNNER_TIMEOUT_FACTOR * 60 ))
fi

if [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
Expand Down
3 changes: 0 additions & 3 deletions cmake/bitcoin-build-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@
*/
#cmakedefine01 HAVE_DECL_SETSID

/* Define this symbol if evhttp_connection_get_peer expects const char** */
#cmakedefine HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR 1

/* Define to 1 if fdatasync is available. */
#cmakedefine HAVE_FDATASYNC 1

Expand Down
60 changes: 33 additions & 27 deletions cmake/module/FindLibevent.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,46 +35,52 @@ function(check_evhttp_connection_get_peer target)
" HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR
)
cmake_pop_check_state()
set(HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR ${HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR} PARENT_SCOPE)
target_compile_definitions(${target} INTERFACE
$<$<BOOL:${HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR}>:HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR>
)
endfunction()

set(_libevent_components core extra)
if(NOT WIN32)
list(APPEND _libevent_components pthreads)
endif()

find_package(Libevent ${Libevent_FIND_VERSION} QUIET
NO_MODULE
)

include(FindPackageHandleStandardArgs)
if(VCPKG_TARGET_TRIPLET)
find_package(Libevent ${Libevent_FIND_VERSION} NO_MODULE QUIET
COMPONENTS extra
if(Libevent_FOUND)
find_package(Libevent ${Libevent_FIND_VERSION} QUIET
REQUIRED COMPONENTS ${_libevent_components}
NO_MODULE
)
find_package_handle_standard_args(Libevent
REQUIRED_VARS Libevent_DIR
VERSION_VAR Libevent_VERSION
)
check_evhttp_connection_get_peer(libevent::extra)
add_library(libevent::libevent ALIAS libevent::extra)
mark_as_advanced(Libevent_DIR)
mark_as_advanced(_event_h)
mark_as_advanced(_event_lib)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(libevent QUIET
IMPORTED_TARGET
libevent>=${Libevent_FIND_VERSION}
)
set(_libevent_required_vars libevent_LIBRARY_DIRS libevent_FOUND)
if(NOT WIN32)
pkg_check_modules(libevent_pthreads QUIET
IMPORTED_TARGET
libevent_pthreads>=${Libevent_FIND_VERSION}
foreach(component IN LISTS _libevent_components)
pkg_check_modules(libevent_${component}
REQUIRED QUIET
IMPORTED_TARGET GLOBAL
libevent_${component}>=${Libevent_FIND_VERSION}
)
list(APPEND _libevent_required_vars libevent_pthreads_FOUND)
endif()
if(TARGET PkgConfig::libevent_${component} AND NOT TARGET libevent::${component})
add_library(libevent::${component} ALIAS PkgConfig::libevent_${component})
endif()
endforeach()
find_package_handle_standard_args(Libevent
REQUIRED_VARS ${_libevent_required_vars}
VERSION_VAR libevent_VERSION
REQUIRED_VARS libevent_core_LIBRARY_DIRS
VERSION_VAR libevent_core_VERSION
)
unset(_libevent_required_vars)
check_evhttp_connection_get_peer(PkgConfig::libevent)
add_library(libevent::libevent ALIAS PkgConfig::libevent)
if(NOT WIN32)
add_library(libevent::pthreads ALIAS PkgConfig::libevent_pthreads)
endif()
check_evhttp_connection_get_peer(PkgConfig::libevent_extra)
endif()

unset(_libevent_components)

mark_as_advanced(Libevent_DIR)
mark_as_advanced(_event_h)
mark_as_advanced(_event_lib)
7 changes: 5 additions & 2 deletions cmake/module/FindUSDT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ if(USDT_INCLUDE_DIR)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${USDT_INCLUDE_DIR})
check_cxx_source_compiles("
// Setting SDT_USE_VARIADIC lets systemtap (sys/sdt.h) know that we want to use
// the optional variadic macros to define tracepoints.
#define SDT_USE_VARIADIC 1
#include <sys/sdt.h>
int main()
{
DTRACE_PROBE(context, event);
STAP_PROBEV(context, event);
int a, b, c, d, e, f, g;
DTRACE_PROBE7(context, event, a, b, c, d, e, f, g);
STAP_PROBEV(context, event, a, b, c, d, e, f, g);
}
" HAVE_USDT_H
)
Expand Down
3 changes: 1 addition & 2 deletions contrib/guix/manifest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(gnu packages gawk)
(gnu packages gcc)
((gnu packages installers) #:select (nsis-x86_64))
((gnu packages linux) #:select (linux-libre-headers-6.1 util-linux))
((gnu packages linux) #:select (linux-libre-headers-6.1))
(gnu packages llvm)
(gnu packages mingw)
(gnu packages moreutils)
Expand Down Expand Up @@ -493,7 +493,6 @@ inspecting signatures in Mach-O binaries.")
bash-minimal
which
coreutils-minimal
util-linux
;; File(system) inspection
file
grep
Expand Down
8 changes: 4 additions & 4 deletions contrib/tracing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ about the connection. Peers can be selected individually to view recent P2P
messages.

```
$ python3 contrib/tracing/p2p_monitor.py ./build/src/bitcoind
$ python3 contrib/tracing/p2p_monitor.py $(pidof bitcoind)
```

Lists selectable peers and traffic and connection information.
Expand Down Expand Up @@ -150,7 +150,7 @@ lost. BCC prints: `Possibly lost 2 samples` on lost messages.


```
$ python3 contrib/tracing/log_raw_p2p_msgs.py ./build/src/bitcoind
$ python3 contrib/tracing/log_raw_p2p_msgs.py $(pidof bitcoind)
```

```
Expand Down Expand Up @@ -241,7 +241,7 @@ A BCC Python script to log the UTXO cache flushes. Based on the
`utxocache:flush` tracepoint.

```bash
$ python3 contrib/tracing/log_utxocache_flush.py ./build/src/bitcoind
$ python3 contrib/tracing/log_utxocache_flush.py $(pidof bitcoind)
```

```
Expand Down Expand Up @@ -300,7 +300,7 @@ comprising a timestamp along with all event data available via the event's
tracepoint.

```console
$ python3 contrib/tracing/mempool_monitor.py ./build/src/bitcoind
$ python3 contrib/tracing/mempool_monitor.py $(pidof bitcoind)
```

```
Expand Down
13 changes: 7 additions & 6 deletions contrib/tracing/log_raw_p2p_msgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ def print_message(event, inbound):
)


def main(bitcoind_path):
bitcoind_with_usdts = USDT(path=str(bitcoind_path))
def main(pid):
print(f"Hooking into bitcoind with pid {pid}")
bitcoind_with_usdts = USDT(pid=int(pid))

# attaching the trace functions defined in the BPF program to the tracepoints
bitcoind_with_usdts.enable_probe(
Expand Down Expand Up @@ -176,8 +177,8 @@ def handle_outbound(_, data, size):


if __name__ == "__main__":
if len(sys.argv) < 2:
print("USAGE:", sys.argv[0], "path/to/bitcoind")
if len(sys.argv) != 2:
print("USAGE:", sys.argv[0], "<pid of bitcoind>")
exit()
path = sys.argv[1]
main(path)
pid = sys.argv[1]
main(pid)
13 changes: 7 additions & 6 deletions contrib/tracing/log_utxocache_flush.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ def print_event(event):
))


def main(bitcoind_path):
bitcoind_with_usdts = USDT(path=str(bitcoind_path))
def main(pid):
print(f"Hooking into bitcoind with pid {pid}")
bitcoind_with_usdts = USDT(pid=int(pid))

# attaching the trace functions defined in the BPF program
# to the tracepoints
Expand Down Expand Up @@ -99,9 +100,9 @@ def handle_flush(_, data, size):


if __name__ == "__main__":
if len(sys.argv) < 2:
print("USAGE: ", sys.argv[0], "path/to/bitcoind")
if len(sys.argv) != 2:
print("USAGE: ", sys.argv[0], "<pid of bitcoind>")
exit(1)

path = sys.argv[1]
main(path)
pid = sys.argv[1]
main(pid)
11 changes: 6 additions & 5 deletions contrib/tracing/mempool_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@
"""


def main(bitcoind_path):
bitcoind_with_usdts = USDT(path=str(bitcoind_path))
def main(pid):
print(f"Hooking into bitcoind with pid {pid}")
bitcoind_with_usdts = USDT(pid=int(pid))

# attaching the trace functions defined in the BPF program
# to the tracepoints
Expand Down Expand Up @@ -365,8 +366,8 @@ def timestamp_age(timestamp):

if __name__ == "__main__":
if len(sys.argv) < 2:
print("USAGE: ", sys.argv[0], "path/to/bitcoind")
print("USAGE: ", sys.argv[0], "<pid of bitcoind>")
exit(1)

path = sys.argv[1]
main(path)
pid = sys.argv[1]
main(pid)
22 changes: 14 additions & 8 deletions contrib/tracing/p2p_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
# outbound P2P messages. The eBPF program submits the P2P messages to
# this script via a BPF ring buffer.

import sys
import curses
import os
import sys
from curses import wrapper, panel
from bcc import BPF, USDT

Expand Down Expand Up @@ -115,10 +116,10 @@ def add_message(self, message):
self.total_outbound_msgs += 1


def main(bitcoind_path):
def main(pid):
peers = dict()

bitcoind_with_usdts = USDT(path=str(bitcoind_path))
print(f"Hooking into bitcoind with pid {pid}")
bitcoind_with_usdts = USDT(pid=int(pid))

# attaching the trace functions defined in the BPF program to the tracepoints
bitcoind_with_usdts.enable_probe(
Expand Down Expand Up @@ -245,9 +246,14 @@ def render(screen, peers, cur_list_pos, scroll, ROWS_AVALIABLE_FOR_LIST, info_pa
(msg.msg_type, msg.size), curses.A_NORMAL)


def running_as_root():
return os.getuid() == 0

if __name__ == "__main__":
if len(sys.argv) < 2:
print("USAGE:", sys.argv[0], "path/to/bitcoind")
if len(sys.argv) != 2:
print("USAGE:", sys.argv[0], "<pid of bitcoind>")
exit()
path = sys.argv[1]
main(path)
if not running_as_root():
print("You might not have the privileges required to hook into the tracepoints!")
pid = sys.argv[1]
main(pid)
9 changes: 4 additions & 5 deletions depends/packages/libevent.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ $(package)_download_path=https://github.com/libevent/libevent/releases/download/
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb
$(package)_patches=cmake_fixups.patch
$(package)_patches+=fix_mingw_link.patch
$(package)_build_subdir=build

# When building for Windows, we set _WIN32_WINNT to target the same Windows
Expand All @@ -23,8 +22,7 @@ define $(package)_set_vars
endef

define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/cmake_fixups.patch && \
patch -p1 < $($(package)_patch_dir)/fix_mingw_link.patch
patch -p1 < $($(package)_patch_dir)/cmake_fixups.patch
endef

define $(package)_config_cmds
Expand All @@ -40,7 +38,8 @@ define $(package)_stage_cmds
endef

define $(package)_postprocess_cmds
rm -rf bin && \
rm -rf bin lib/pkgconfig && \
rm include/ev*.h && \
rm include/event2/*_compat.h
rm include/event2/*_compat.h && \
rm lib/libevent.a
endef
Loading

0 comments on commit 12ef104

Please sign in to comment.