diff --git a/README.md b/README.md index e7b1b17..13d158e 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The setup wizard provides options for users to configure the package. These valu - `KEYPER_NAME`: a unique name for your keyper so it can be identified in the network. - `SHUTTER_API_NODE_PRIVATEKEY`: A privatekey for an ethereum externally owned account. - - `ETHEREUM_WS`: An ethereum websocket RPC url. This can either point to an external RPC, or an RPC node running on your dappnode. + - `ETHEREUM_WS`: An optional ethereum websocket RPC url. This can either point to an external RPC, or an RPC node running on your dappnode. If it is not given, shutter will try to use an internal RPC through the 'staker scripts' mechanism. - `SHUTTER_PUSH_METRICS_ENABLED`: A boolean flag deciding whether metrics will be pushed (see values below). - `PUSHGATEWAY_URL`: You don't need to change the default here. - `PUSHGATEWAY_USERNAME`: A username for the push gateway from above. diff --git a/setup-wizard.yml b/setup-wizard.yml index 2ea3fed..e9ba1de 100644 --- a/setup-wizard.yml +++ b/setup-wizard.yml @@ -24,12 +24,12 @@ fields: - id: external_ws_rpc title: External WS RPC description: | - A websocket connection to an external ethereum RPC. + A websocket connection to an external ethereum RPC (e.g. 'wss://some.external.url' or 'ws://1.2.3.4:8545'). If this is given, shutter will use this RPC to connect to the network. If not, shutter will try to use an RPC service on this dappnode. target: type: environment name: ETHEREUM_WS service: shutter - required: true + required: false - id: enable_push_logs title: Enable Push Logs diff --git a/shutter/Dockerfile b/shutter/Dockerfile index 244209f..b159296 100644 --- a/shutter/Dockerfile +++ b/shutter/Dockerfile @@ -58,6 +58,20 @@ RUN echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com # promtail & rotatelogs (from apache2) RUN apt-get update && apt-get -y install promtail apache2 +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl + +ARG NODE_VERSION=22.14.0 +ARG NODE_PACKAGE=node-v$NODE_VERSION-linux-x64 +ARG NODE_HOME=/opt/$NODE_PACKAGE + +ENV NODE_PATH $NODE_HOME/lib/node_modules +ENV PATH $NODE_HOME/bin:$PATH + +RUN curl https://nodejs.org/dist/v$NODE_VERSION/$NODE_PACKAGE.tar.gz | tar -xzC /opt/ + +RUN npm install -g wscat # Placed here to rebuild less layers ENV CHAIN_PORT=${CHAIN_PORT} \ diff --git a/shutter/scripts/configure_keyper.sh b/shutter/scripts/configure_keyper.sh index 0c731f1..c581ec6 100755 --- a/shutter/scripts/configure_keyper.sh +++ b/shutter/scripts/configure_keyper.sh @@ -6,6 +6,22 @@ # shellcheck disable=SC1091 . "${ASSETS_DIR}/variables.env" +NODE_VERSION=22.14.0 +NODE_PACKAGE=node-v$NODE_VERSION-linux-x64 +NODE_HOME=/opt/$NODE_PACKAGE + +NODE_PATH=$NODE_HOME/lib/node_modules +PATH=$NODE_HOME/bin:$PATH + +function test_ethereum_url() { + RESULT=$(wscat -c "$SHUTTER_NETWORK_NODE_ETHEREUMURL" -x '{"jsonrpc": "2.0", "method": "eth_syncing", "params": [], "id": 1}') + if [[ $RESULT =~ '"id":1' ]]; then return 0; else + echo "Could not find DAppNode RPC/WS url for this package!" + echo "Please configure 'ETHEREUM_WS' to point to an applicable websocket RPC service." + exit 1; + fi +} + echo "[INFO | configure] Calculating keyper configuration values..." SUPPORTED_NETWORKS="gnosis" @@ -16,8 +32,11 @@ if [[ ! "$SHUTTER_P2P_LISTENADDRESSES" =~ ^\[.*\]$ ]]; then fi export SHUTTER_P2P_ADVERTISEADDRESSES="[\"/ip4/${_DAPPNODE_GLOBAL_PUBLIC_IP}/tcp/${KEYPER_PORT}\", \"/ip4/${_DAPPNODE_GLOBAL_PUBLIC_IP}/udp/${KEYPER_PORT}/quic-v1\"]" -export SHUTTER_NETWORK_NODE_ETHEREUMURL=${ETHEREUM_WS} + +export SHUTTER_NETWORK_NODE_ETHEREUMURL=${ETHEREUM_WS:-$(get_execution_ws_url_from_global_env "$NETWORK" "$SUPPORTED_NETWORKS")} echo "[DEBUG | configure] SHUTTER_NETWORK_NODE_ETHEREUMURL is ${SHUTTER_NETWORK_NODE_ETHEREUMURL}" +test_ethereum_url + export VALIDATOR_PUBLIC_KEY=$(cat "${SHUTTER_CHAIN_DIR}/config/priv_validator_pubkey.hex") export SHUTTER_METRICS_ENABLED=${SHUTTER_PUSH_METRICS_ENABLED} export FLOODSUB_DISCOVERY_ENABLED=true