nimbus-eth2/scripts/signers/web3signer.sh
zah 8833acbe23
Add support for using custom remote signers in local sim (#4989)
* Add support for using custom remote signers in local sim

Other changes:

* Enable the Nimbus remote signer in the minimal simulation
* Move all log files into the `logs` folder of the simulation
* Create PID files for all processes and use them during the clean-up
  phase instead of the previous more fragile methods for killing the
  remaining processes.
2023-05-25 15:05:38 +00:00

48 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/bash
# Copyright (c) 2023 Status Research & Development GmbH.
# Licensed under either of:
# - Apache License, version 2.0
# - MIT license
# at your option. This file may not be copied, modified, or distributed
# except according to those terms.
if ! command javac > /dev/null || ! javac -version > /dev/null; then
# On macOS, homebrew doesn't make java available in your PATH by default.
# Instead, macOS ships with a stub executable that displays a message that
# Java is not installed (javac -version exits with an error code 1).
# If the user is running under these default settings, but a homebrew
# installation is disovered, we are happy to use it just in this script:
if [[ -d /opt/homebrew/opt/openjdk/bin ]]; then
export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
fi
fi
WEB3SIGNER_NODE_IDX=$1
local secrets_dir="${DATA_DIR}/secrets_shares/$((WEB3SIGNER_NODE_IDX + 1))"
local keystores_dir="${DATA_DIR}/validators_shares/$((WEB3SIGNER_NODE_IDX + 1))"
# We re-arrange the keystore files to match the layout expected by the Web3Signer
# TODO generateSimulationDeposits can be refactored to produce the right layout from the start
for validator_pubkey in $(ls "$secrets_dir")
do
mv "$secrets_dir/$validator_pubkey" "$secrets_dir/$validator_pubkey.txt"
mv "$keystores_dir/$validator_pubkey/keystore.json" "$keystores_dir/$validator_pubkey.json"
done
# still participate in set -e, ideally
# TODO find some way for this and other background-launched processes to
"${WEB3SIGNER_BINARY}" \
--http-listen-port=$(( BASE_REMOTE_SIGNER_PORT + WEB3SIGNER_NODE_IDX )) \
--logging=DEBUG \
--metrics-enabled=true \
--metrics-port=$(( BASE_REMOTE_SIGNER_METRICS_PORT + WEB3SIGNER_NODE_IDX )) \
eth2 \
--slashing-protection-enabled=false \
--keystores-passwords-path="${secrets_dir}" \
--keystores-path="${keystores_dir}" \
--network="${RUNTIME_CONFIG_FILE}" &> "${DATA_DIR}/logs/web3signer.${WEB3SIGNER_NODE_IDX}.log" &
echo $! > "${DATA_DIR}/pids/web3signer.${WEB3SIGNER_NODE_IDX}"