diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 8c7ffabd70f..00000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "configurations": [ - { - "type": "lldb-dap", - "request": "launch", - "name": "testnet", - "program": "${workspaceRoot}/build/firedancer-dev", - "args": [], - "env": [], - "cwd": "${workspaceRoot}", - "preLaunchTask": "build-firedancer-dev", - } - ] -} diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 1206e0cee0b..00000000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "build-firedancer-dev", - "type": "shell", - "command": "make", - "args": [ - "-j", - "firedancer-dev" - ], - "group": { - "kind": "build", - "isDefault": true - }, - "presentation": { - "echo": true, - "reveal": "silent", - "close": true, - "clear": true, - "focus": false, - "panel": "shared", - "group": "build", - "revealProblems": "onProblem", - "showReuseMessage": false, - }, - "problemMatcher": [] - } - ] -} diff --git a/contrib/debug.gdb b/contrib/debug.gdb deleted file mode 100644 index c4a787e4a0a..00000000000 --- a/contrib/debug.gdb +++ /dev/null @@ -1,5 +0,0 @@ -break fd_log_private_2 -run -if $_exitcode == 0 - quit -end diff --git a/contrib/test/run_script_tests.sh b/contrib/test/run_script_tests.sh index 0f5eb345cbf..df3219b09f0 100755 --- a/contrib/test/run_script_tests.sh +++ b/contrib/test/run_script_tests.sh @@ -22,7 +22,6 @@ $UNIT_TEST/test_alloc_ctl > $LOG_PATH/alloc_ctl 2>&1 || test_status=1 $UNIT_TEST/test_pod_ctl > $LOG_PATH/pod_ctl 2>&1 || test_status=1 $UNIT_TEST/test_tango_ctl > $LOG_PATH/tango_ctl 2>&1 || test_status=1 $UNIT_TEST/test_wksp_helper > $LOG_PATH/wksp_helper 2>&1 || test_status=1 # allocates a gigantic page -$UNIT_TEST/test_gdb_base58.sh > $LOG_PATH/gdb_base58 2>&1 || test_status=1 # Multi-tile tests $UNIT_TEST/test_cnc --tile-cpus 0,2 2> $LOG_PATH/cnc || test_status=1 diff --git a/contrib/tool/fd_gdb b/contrib/tool/fd_gdb deleted file mode 100755 index 9c281c79e9c..00000000000 --- a/contrib/tool/fd_gdb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec gdb -iex 'add-auto-load-safe-path .' "$@" diff --git a/src/app/fddbg/Local.mk b/src/app/fddbg/Local.mk deleted file mode 100644 index 6ac405a6838..00000000000 --- a/src/app/fddbg/Local.mk +++ /dev/null @@ -1,5 +0,0 @@ -ifdef FD_HAS_HOSTED -ifdef FD_HAS_LINUX -$(call make-bin,fddbg,main,fd_util) -endif -endif diff --git a/src/app/fddbg/main.c b/src/app/fddbg/main.c deleted file mode 100644 index 7892653780d..00000000000 --- a/src/app/fddbg/main.c +++ /dev/null @@ -1,148 +0,0 @@ -/* This is a pretty strange wrapper... - - We want to support "F5" debugging from, eg, VS code. To do that, VS - code has an agent on our development box running as the user. It is - not root and has no capabilities. That agent forks a child process - that then exec's "gdb", which then loads and runs our program. - - We need to run our program as root sometimes. You might imagine a few - ways to do that, - - (a) Run the agent as root? Not supported by VS code. It's probably - feasible to make changes to the agent code itself to get this - working but it seems difficult. - (b) Run gdb as root? The agent won't launch it as root, but we - could for example setuid the gdb binary itself. This doesn't - work quite right because it prevents VS code from communicating - with GDB, eg, to pause execution. See this bug - https://github.com/microsoft/vscode-cpptools/issues/4243 - (c) Run the program as root, eg, using setuid? This isn't really - possible. A non-root GDB will not attach to a root program for - security reasons. - - So we can't really get the program running as root in any scenario. - What else can we do? Just run it with all capabilities... that's what - this program does. - - The sequence here is that, VS code sets this binary as it's "gdb" - path, then, when launched this program, - - (1) Fork off a sudo process which `setcaps` the current binary to - have all capabilities. - (2) The parent waits for the sudo process, then reruns itself - again to have all capabilities - (3) Now running with capabilities, we do a `CAP_AMBIENT_RAISE` so - that capabilities survive a `/bin/gdb` invocation which would - normally strip them for security reasons. - (4) Now we finally exec `/bin/gdb` with the arguments provided by - the IDE. */ -#define _GNU_SOURCE - -#include "../../util/fd_util.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static int -has_all_capabilities( void ) { - struct __user_cap_header_struct capheader; - struct __user_cap_data_struct capdata[2]; - - capheader.version = _LINUX_CAPABILITY_VERSION_3; - capheader.pid = 0; - FD_TEST( syscall( SYS_capget, &capheader, &capdata ) >= 0 ); - return - capdata[0].permitted == 0xFFFFFFFF && - ( capdata[1].permitted & 0x000001FF ) == 0x000001FF; -} - -static void -raise_all_capabilities( void ) { - struct __user_cap_header_struct capheader; - struct __user_cap_data_struct capdata[2]; - - capheader.version = _LINUX_CAPABILITY_VERSION_3; - capheader.pid = 0; - FD_TEST( syscall( SYS_capget, &capheader, &capdata ) >= 0 ); - - capdata[0].effective = 0xFFFFFFFF; - capdata[0].inheritable = 0xFFFFFFFF; - capdata[1].effective = 0xFFFFFFFF; - capdata[1].inheritable = 0xFFFFFFFF; - FD_TEST( syscall(SYS_capset, &capheader, &capdata) >= 0 ); - - for ( int cap = 0; cap <= CAP_LAST_CAP; cap++ ) - FD_TEST( !prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, cap, 0, 0) ); -} - -static void -self_exe( char * path ) { - long count = readlink( "/proc/self/exe", path, PATH_MAX ); - FD_TEST( count >= 0 && count < PATH_MAX ); - path[ count ] = '\0'; -} - -int -main( int argc, - char ** argv ) { - fd_boot( &argc, &argv ); - - if( FD_UNLIKELY( argc > 1 && !strcmp( argv[1], "--setcap" ) ) ) { - struct vfs_cap_data { - __le32 magic_etc; - struct { - __le32 permitted; - __le32 inheritable; - } data[2]; - } cap_data; - - cap_data.magic_etc = VFS_CAP_REVISION_2; - cap_data.data[0].permitted = 0xFFFFFFFF; - cap_data.data[0].inheritable = 0xFFFFFFFF; - cap_data.data[1].permitted = 0xFFFFFFFF; - cap_data.data[1].inheritable = 0xFFFFFFFF; - - char self_path[ PATH_MAX ]; - self_exe( self_path ); - FD_TEST( !setxattr( self_path, "security.capability", &cap_data, sizeof(cap_data), 0) ); - } else { - if( FD_UNLIKELY( !has_all_capabilities() ) ) { - if ( FD_UNLIKELY( argc > 1 && !strcmp( argv[1], "--withcap" ) ) ) FD_LOG_ERR(( "missing capabilities" )); - - char self_path[ PATH_MAX ]; - self_exe( self_path ); - - pid_t child = fork(); - FD_TEST( child >= 0 ); - if( child == 0 ) execv( "/bin/sudo", (char *[]){ "sudo", self_path, "--setcap", NULL } ); - else { - int wstatus; - FD_TEST( waitpid( child, &wstatus, 0 ) >= 0 ); - FD_TEST( WIFEXITED( wstatus ) && !WEXITSTATUS( wstatus ) ); - char self_path[ PATH_MAX ]; - self_exe( self_path ); - FD_TEST( execv( self_path, (char *[]){ "fddbg", "--withcap", NULL } ) >= 0 ); - } - } else { - raise_all_capabilities(); - - char * args[ 32 ]; - int start = argc > 1 && !strcmp( argv[1], "--withcap" ) ? 2 : 1; - args[0] = "/bin/gdb"; - for( int i=start; i= 0 ); - } - } -} diff --git a/src/app/firedancer-dev/main.c b/src/app/firedancer-dev/main.c index 78d2751b645..76a71acae26 100644 --- a/src/app/firedancer-dev/main.c +++ b/src/app/firedancer-dev/main.c @@ -2,7 +2,6 @@ #include "../firedancer/topology.h" #include "../firedancer/config.h" #include "../shared_dev/boot/fd_dev_boot.h" -#include "../shared/gdb/fd_gdb_scripts.h" int main( int argc, diff --git a/src/app/shared/gdb/Local.mk b/src/app/shared/gdb/Local.mk deleted file mode 100644 index b88369ef212..00000000000 --- a/src/app/shared/gdb/Local.mk +++ /dev/null @@ -1,5 +0,0 @@ -$(call add-asms,fd_gdb_scripts,fddev_shared) -$(OBJDIR)/obj/app/shared/gdb/fd_gdb_scripts.o: src/app/shared/gdb/fd_base58_gdb.py - -$(call make-unit-test,test_gdb_base58,test_gdb_base58 fd_gdb_scripts,fd_util) -$(call add-test-scripts,test_gdb_base58.sh) diff --git a/src/app/shared/gdb/fd_base58_gdb.py b/src/app/shared/gdb/fd_base58_gdb.py deleted file mode 100644 index 617df3af180..00000000000 --- a/src/app/shared/gdb/fd_base58_gdb.py +++ /dev/null @@ -1,102 +0,0 @@ -# Base58 printing support for GDB - -import gdb - -_BASE58_CHARS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" - -def fd_base58_encode( raw ): - out = [] - num = int.from_bytes( raw, "big" ) - while num: - num, rem = divmod( num, 58 ) - out.append( _BASE58_CHARS[ rem ] ) - for byte in raw: # Leading zero bytes become leading '1's - if byte: break - out.append( _BASE58_CHARS[ 0 ] ) - out.reverse() - return "".join( out ) or _BASE58_CHARS[ 0 ] - -def _read_bytes( val, sz ): - """Extract sz bytes out of a gdb.Value, or None if unavailable.""" - if val.address is not None: - try: - return bytes( gdb.selected_inferior().read_memory( val.address, sz ) ) - except ( gdb.MemoryError, gdb.error ): - return None - try: # Value lives in a register or is otherwise synthetic - uc = val[ "uc" ] - return bytes( int( uc[ i ] ) & 0xff for i in range( sz ) ) - except ( gdb.error, KeyError ): - return None - -class _FdBase58Printer: - def __init__( self, val, sz ): - self._val = val - self._sz = sz - def to_string( self ): - raw = _read_bytes( self._val, self._sz ) - if raw is None: return "" - return fd_base58_encode( raw ) - -# Types rendered as base58, keyed by union tag => encoded length - -_FD_BASE58_TYPES = { - "fd_hash": 32, - "fd_pubkey": 32, - "fd_signature": 64, -} - -def fd_base58_lookup( val ): - try: - typ = val.type.strip_typedefs() - except gdb.error: - return None - if typ.code != gdb.TYPE_CODE_UNION: return None - sz = _FD_BASE58_TYPES.get( typ.tag or typ.name ) - if sz is None or typ.sizeof != sz: return None - return _FdBase58Printer( val, sz ) - -class _FdBase58Command( gdb.Command ): - """Print memory as base58. - -Usage: b58 EXPR [LEN] - -EXPR may be a pointer, an array, or an lvalue of any type. LEN defaults -to 32, or to sizeof(EXPR) when EXPR is not a pointer.""" - - def __init__( self ): - super( _FdBase58Command, self ).__init__( "b58", gdb.COMMAND_DATA ) - - def invoke( self, arg, from_tty ): - argv = gdb.string_to_argv( arg ) - if not argv: raise gdb.GdbError( "usage: b58 EXPR [LEN]" ) - - sz = None - val = None - try: # The whole argument is usually just an expression - val = gdb.parse_and_eval( " ".join( argv ) ) - except gdb.error as err: - if len( argv )<2: raise gdb.GdbError( str( err ) ) - try: # Retry with the trailing token split off as LEN - sz = int( gdb.parse_and_eval( argv[ -1 ] ) ) - val = gdb.parse_and_eval( " ".join( argv[ :-1 ] ) ) - except gdb.error: - raise gdb.GdbError( str( err ) ) - - typ = val.type.strip_typedefs() - if typ.code==gdb.TYPE_CODE_PTR: - addr = int( val ) - if sz is None: sz = 32 - else: - if val.address is None: raise gdb.GdbError( "expression has no address" ) - addr = int( val.address ) - if sz is None: sz = int( typ.sizeof ) - - if sz<=0: raise gdb.GdbError( "invalid length" ) - raw = bytes( gdb.selected_inferior().read_memory( addr, sz ) ) - gdb.write( fd_base58_encode( raw ) + "\n" ) - -if not any( getattr( fn, "__name__", "" )=="fd_base58_lookup" - for fn in gdb.pretty_printers ): - gdb.pretty_printers.append( fd_base58_lookup ) - _FdBase58Command() diff --git a/src/app/shared/gdb/fd_gdb_scripts.S b/src/app/shared/gdb/fd_gdb_scripts.S deleted file mode 100644 index 25675063aef..00000000000 --- a/src/app/shared/gdb/fd_gdb_scripts.S +++ /dev/null @@ -1,25 +0,0 @@ -/* fd_gdb_scripts.S embeds GDB helper Python scripts. */ - -#if defined(__ELF__) - -.pushsection ".debug_gdb_scripts","MS",@progbits,1 - -.byte 4 -.ascii "fd_base58_gdb.py\n" -.incbin "src/app/shared/gdb/fd_base58_gdb.py" -.byte 0 - -.popsection - -#endif - -/* dummy symbol that main.c can reference to force this object file - to be linked in */ - -.section .rodata.fd_gdb,"a",@progbits -.globl fd_gdb_scripts -.hidden fd_gdb_scripts -fd_gdb_scripts: -.byte 0 - -.section .note.GNU-stack,"",@progbits diff --git a/src/app/shared/gdb/fd_gdb_scripts.h b/src/app/shared/gdb/fd_gdb_scripts.h deleted file mode 100644 index e59dd581d40..00000000000 --- a/src/app/shared/gdb/fd_gdb_scripts.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef HEADER_fd_src_app_shared_gdb_fd_gdb_scripts_h -#define HEADER_fd_src_app_shared_gdb_fd_gdb_scripts_h - -/* Including fd_gdb_scripts.h injects Firedancer's GDB Python scripts into - the build. This currently includes Base58 pretty printing. */ - -extern char const fd_gdb_scripts[]; - -__attribute__((used)) static char const * const -fd_gdb_scripts_ref = fd_gdb_scripts; - -#endif /* HEADER_fd_src_app_shared_gdb_fd_gdb_scripts_h */ diff --git a/src/app/shared/gdb/test_gdb_base58.c b/src/app/shared/gdb/test_gdb_base58.c deleted file mode 100644 index 6dcd6f08b77..00000000000 --- a/src/app/shared/gdb/test_gdb_base58.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Fixture for test_gdb_base58.sh, which pretty prints the globals - below in GDB. */ - -#include "fd_gdb_scripts.h" -#include "../../../flamenco/fd_flamenco_base.h" - -/* SPL Token program: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA */ - -fd_pubkey_t test_pubkey = {{ - 0x06, 0xdd, 0xf6, 0xe1, 0xd7, 0x65, 0xa1, 0x93, 0xd9, 0xcb, 0xe1, 0x46, 0xce, 0xeb, 0x79, 0xac, - 0x1c, 0xb4, 0x85, 0xed, 0x5f, 0x5b, 0x37, 0x91, 0x3a, 0x8c, 0xf5, 0x85, 0x7e, 0xff, 0x00, 0xa9 -}}; - -/* Leading zero bytes encode as leading '1's */ - -fd_hash_t test_hash = {{ - 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, - 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0xff -}}; - -fd_hash_t test_zero = {{ 0 }}; - -fd_signature_t test_sig = {{ - 0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x00 -}}; - -int -main( void ) { - return 0; -} diff --git a/src/app/shared/gdb/test_gdb_base58.sh b/src/app/shared/gdb/test_gdb_base58.sh deleted file mode 100755 index dafa0dc761e..00000000000 --- a/src/app/shared/gdb/test_gdb_base58.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# Checks that the GDB scripts embedded by fd_gdb_scripts.S print -# fd_hash_t / fd_pubkey_t / fd_signature_t as base58. - -set -u - -#shellcheck disable=SC2128 -BIN=$(dirname -- "$BASH_SOURCE")/test_gdb_base58 - -command -v gdb > /dev/null || { echo "SKIP: gdb not installed"; exit 0; } -gdb --batch -nx -ex "python print( 'ok' )" 2>/dev/null | grep -q ok || \ - { echo "SKIP: gdb has no Python support"; exit 0; } - -expected=$(cat <<'EOF' -$1 = TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA -$2 = 1113ev7KArKmSeNWXoiX44de25oM4BcoUZHC9RfTKL -$3 = 11111111111111111111111111111111 -$4 = 66hqP5QbfXgdkSGN7KwA7f7LmgJkwHmuw3awmwMLQ4aWL63AZ8kTidNvLHtJqbeBDfWuRJL9Wn6MmQqH4tBjdS4F -TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA -66hqP5QbfXgdkSGN7KwA7f7LmgJkwHmuw3awmwMLQ4aWL63AZ8kTidNvLHtJqbeBDfWuRJL9Wn6MmQqH4tBjdS4F -4wBqpZM9xaSheZzJSMawUKKwhdpChKbZ5eu5ky4Vigw -EOF -) - -actual=$(gdb --batch -nx -iex "set auto-load safe-path /" \ - -ex "p test_pubkey" -ex "p test_hash" -ex "p test_zero" -ex "p test_sig" \ - -ex "b58 &test_pubkey" -ex "b58 test_sig.uc 64" -ex "b58 test_sig.uc + 1" \ - "$BIN" 2>&1) - -if [[ "$actual" != "$expected" ]]; then - diff <( echo "$expected" ) <( echo "$actual" ) - echo FAIL - exit 1 -fi - -echo pass diff --git a/src/flamenco/runtime/tests/run_ledger_backtest.sh b/src/flamenco/runtime/tests/run_ledger_backtest.sh index ba5c0b99595..6da90f3aa9f 100755 --- a/src/flamenco/runtime/tests/run_ledger_backtest.sh +++ b/src/flamenco/runtime/tests/run_ledger_backtest.sh @@ -15,7 +15,6 @@ INGEST_MODE="shredcap" DUMP_DIR=${DUMP_DIR:="./dump"} ONE_OFFS="" HUGE_TLBFS_MOUNT_PATH=${HUGE_TLBFS_MOUNT_PATH:="/mnt/.fd"} -DEBUG=( ) WATCH=( ) LOG_LEVEL_STDERR=NOTICE EXECRP_TILE_COUNT="10" @@ -81,10 +80,6 @@ while [[ $# -gt 0 ]]; do GENESIS=1 shift ;; - --debug) - DEBUG=( gdb -q -x contrib/debug.gdb --args ) - shift - ;; --log) LOG="$2" shift @@ -274,10 +269,10 @@ rm -f "${ACCOUNTS_DB:-$DUMP/accounts.db}" set -x if [[ -n "$CI" ]]; then - "${DEBUG[@]}" $OBJDIR/bin/firedancer-dev backtest --config ${DUMP_DIR}/${LEDGER}_backtest.toml "${WATCH[@]}" &> /dev/null + $OBJDIR/bin/firedancer-dev backtest --config ${DUMP_DIR}/${LEDGER}_backtest.toml "${WATCH[@]}" &> /dev/null { status=$?; set +x; } &> /dev/null else - "${DEBUG[@]}" $OBJDIR/bin/firedancer-dev backtest --config ${DUMP_DIR}/${LEDGER}_backtest.toml "${WATCH[@]}" + $OBJDIR/bin/firedancer-dev backtest --config ${DUMP_DIR}/${LEDGER}_backtest.toml "${WATCH[@]}" { status=$?; set +x; } fi