diff --git a/beacon_chain/networking/eth2_network.nim b/beacon_chain/networking/eth2_network.nim index c5af1e7df..8f4755d31 100644 --- a/beacon_chain/networking/eth2_network.nim +++ b/beacon_chain/networking/eth2_network.nim @@ -1964,6 +1964,14 @@ proc p2pProtocolBackendImpl*(p: P2PProtocol): Backend = codecNameLit)) result.implementProtocolInit = proc (p: P2PProtocol): NimNode = + # TODO + # This current approach is not building on good foundations. + # Incrementing a global variable at compile-time fundamentally at odds with + # incremental compilation (because a recompile that doesn't revisit the whole + # program will mess up the counting and create duplicate indices). + # A better approach would build upon the `macrocache` module from the standard + # library, which is compatible with incremental compilation: + # https://nim-lang.org/docs/macrocache.html var id {.global.}: int let tmp = id id += 1 diff --git a/installer/nix/shell.nix b/installer/nix/shell.nix index 7242276cb..ea2499f81 100644 --- a/installer/nix/shell.nix +++ b/installer/nix/shell.nix @@ -1,3 +1,10 @@ +# beacon_chain +# Copyright (c) 2023-2024 Status Research & Development GmbH +# Licensed and distributed under either of +# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). +# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). +# at your option. This file may not be copied, modified, or distributed except according to those terms. + { pkgs ? import {}}: let mkdocs-packages = ps: with ps; [ @@ -16,6 +23,7 @@ mkShell { git git-lfs gnumake + getopt # For the local simulation openssl # for generating the JWT file @@ -34,6 +42,7 @@ mkShell { # will erase `-march=native` because this introduces impurity in the build. # For the purposes of compiling Nimbus, this behavior is not desired: export NIX_ENFORCE_NO_NATIVE=0 + export USE_SYSTEM_GETOPT=1 figlet "Welcome to Nimbus-eth2" ''; diff --git a/scripts/launch_local_testnet.sh b/scripts/launch_local_testnet.sh index 63a60c808..109ac7ce9 100755 --- a/scripts/launch_local_testnet.sh +++ b/scripts/launch_local_testnet.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020-2023 Status Research & Development GmbH. Licensed under +# Copyright (c) 2020-2024 Status Research & Development GmbH. Licensed under # either of: # - Apache License, version 2.0 # - MIT license @@ -34,7 +34,7 @@ PIDS_TO_WAIT="" #################### GETOPT_BINARY="getopt" -if [[ "${OS}" == "macos" ]]; then +if [[ "${OS}" == "macos" && "$USE_SYSTEM_GETOPT" != "1" ]]; then # Without the head -n1 constraint, it gets confused by multiple matches GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null | head -n1 || true) [[ -f "$GETOPT_BINARY" ]] || { echo "GNU getopt not installed. Please run 'brew install gnu-getopt'. Aborting."; exit 1; }