nimbus-eth2/scripts/signers/custom.sh

55 lines
2.4 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.
# This script will receive a single numeric argument representing the
# instance ID of the signer. It will range from 0 to 9.
# Usually, only a single signer will be launched to produce signatures
# for all validators, but if threshold signing is enabled through the
# `--signer-nodes N` parameter, the simulation script will launch
# multiple instances working with partial validator keys.
SIGNER_NODE_IDX=$1
# These directories store the keystores and secrets generated by the
# simulation script. These are either full validator keys or partial
# validator keys depending on the `--signer-nodes` parameter (see above).
SECRETS_DIR="${DATA_DIR}/secrets_shares/$((SIGNER_NODE_IDX + 1))"
KEYSTORES_DIR="${DATA_DIR}/validators_shares/$((SIGNER_NODE_IDX + 1))"
# You can re-arrange the keystore files to match the layout expected by
# your signer. The example below demonstrates how this is done when working
# with the Consensys Web3Signer:
#
# 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
# Here you need to launch your signer server process.
# You must make sure that it will listen on the `$((BASE_REMOTE_SIGNER_PORT + SIGNER_NODE_IDX))` port.
# The new process must be launched in the background.
# Preferrably, you will also create a log file in the `${DATA_DIR}/logs` directory.
# Here is an example way to achieve the above with the web3signer binary:
#
# web3signer \
# --http-listen-port=$(( BASE_REMOTE_SIGNER_PORT + SIGNER_NODE_IDX )) \
# --logging=DEBUG \
# --metrics-enabled=true \
# --metrics-port=$(( BASE_REMOTE_SIGNER_METRICS_PORT + SIGNER_NODE_IDX )) \
# eth2 \
# --slashing-protection-enabled=false \
# --keystores-passwords-path="${SECRETS_DIR}" \
# --keystores-path="${KEYSTORES_DIR}" \
# --network="${RUNTIME_CONFIG_FILE}" &> "${DATA_DIR}/web3signer.log" &
# Finally, you must write the PIDs of any created processes in the `pids` directory
# The names of the PID files can be arbitrary, but make sure they are unique for each launched instance
echo $! > "${DATA_DIR}/pids/my-custom-signer.${SIGNER_NODE_IDX}"