From a2f009a16845c4b54187c5817e2e8df4d531382d Mon Sep 17 00:00:00 2001 From: Konrad Feldmeier Date: Thu, 13 Mar 2025 15:15:11 +0100 Subject: [PATCH 1/4] WIP: Allow alternativ configuration for ETHEREUM_WS Fixes: #8 --- setup-wizard.yml | 2 +- shutter/scripts/configure_keyper.sh | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/setup-wizard.yml b/setup-wizard.yml index 2ea3fed..a7a2013 100644 --- a/setup-wizard.yml +++ b/setup-wizard.yml @@ -29,7 +29,7 @@ fields: type: environment name: ETHEREUM_WS service: shutter - required: true + required: false - id: enable_push_logs title: Enable Push Logs diff --git a/shutter/scripts/configure_keyper.sh b/shutter/scripts/configure_keyper.sh index 0c731f1..ddb0e23 100755 --- a/shutter/scripts/configure_keyper.sh +++ b/shutter/scripts/configure_keyper.sh @@ -6,6 +6,15 @@ # shellcheck disable=SC1091 . "${ASSETS_DIR}/variables.env" +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 +25,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 From 63db2e4b5db0b6f0944e0e5d9d9a28fbb5f2fe25 Mon Sep 17 00:00:00 2001 From: Konrad Feldmeier Date: Mon, 14 Apr 2025 08:45:51 +0000 Subject: [PATCH 2/4] Install wscat inside Dockerfile --- shutter/Dockerfile | 14 ++++++++++++++ shutter/scripts/configure_keyper.sh | 7 +++++++ 2 files changed, 21 insertions(+) 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 ddb0e23..c581ec6 100755 --- a/shutter/scripts/configure_keyper.sh +++ b/shutter/scripts/configure_keyper.sh @@ -6,6 +6,13 @@ # 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 From 01229c94abe9cad0bb253fcbe31979c0060a39eb Mon Sep 17 00:00:00 2001 From: Konrad Feldmeier Date: Mon, 14 Apr 2025 12:09:56 +0000 Subject: [PATCH 3/4] Better help text --- setup-wizard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-wizard.yml b/setup-wizard.yml index a7a2013..e9ba1de 100644 --- a/setup-wizard.yml +++ b/setup-wizard.yml @@ -24,7 +24,7 @@ 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 From 302d123b6974703e9bee9f384e293aecb18bf3c1 Mon Sep 17 00:00:00 2001 From: Konrad Feldmeier Date: Mon, 28 Apr 2025 15:31:20 +0000 Subject: [PATCH 4/4] Add README note --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.