Skip to content

Commit 0f6b076

Browse files
authored
Merge pull request #9 from shutter-network/rpc_configuration
Allow alternativ configuration for ETHEREUM_WS
2 parents 87f5342 + 302d123 commit 0f6b076

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The setup wizard provides options for users to configure the package. These valu
3030

3131
- `KEYPER_NAME`: a unique name for your keyper so it can be identified in the network.
3232
- `SHUTTER_API_NODE_PRIVATEKEY`: A privatekey for an ethereum externally owned account.
33-
- `ETHEREUM_WS`: An ethereum websocket RPC url. This can either point to an external RPC, or an RPC node running on your dappnode.
33+
- `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.
3434
- `SHUTTER_PUSH_METRICS_ENABLED`: A boolean flag deciding whether metrics will be pushed (see values below).
3535
- `PUSHGATEWAY_URL`: You don't need to change the default here.
3636
- `PUSHGATEWAY_USERNAME`: A username for the push gateway from above.

setup-wizard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ fields:
2424
- id: external_ws_rpc
2525
title: External WS RPC
2626
description: |
27-
A websocket connection to an external ethereum RPC.
27+
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.
2828
target:
2929
type: environment
3030
name: ETHEREUM_WS
3131
service: shutter
32-
required: true
32+
required: false
3333

3434
- id: enable_push_logs
3535
title: Enable Push Logs

shutter/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ RUN echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com
5858
# promtail & rotatelogs (from apache2)
5959
RUN apt-get update && apt-get -y install promtail apache2
6060

61+
RUN apt-get update && apt-get install -y \
62+
ca-certificates \
63+
curl
64+
65+
ARG NODE_VERSION=22.14.0
66+
ARG NODE_PACKAGE=node-v$NODE_VERSION-linux-x64
67+
ARG NODE_HOME=/opt/$NODE_PACKAGE
68+
69+
ENV NODE_PATH $NODE_HOME/lib/node_modules
70+
ENV PATH $NODE_HOME/bin:$PATH
71+
72+
RUN curl https://nodejs.org/dist/v$NODE_VERSION/$NODE_PACKAGE.tar.gz | tar -xzC /opt/
73+
74+
RUN npm install -g wscat
6175

6276
# Placed here to rebuild less layers
6377
ENV CHAIN_PORT=${CHAIN_PORT} \

shutter/scripts/configure_keyper.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66
# shellcheck disable=SC1091
77
. "${ASSETS_DIR}/variables.env"
88

9+
NODE_VERSION=22.14.0
10+
NODE_PACKAGE=node-v$NODE_VERSION-linux-x64
11+
NODE_HOME=/opt/$NODE_PACKAGE
12+
13+
NODE_PATH=$NODE_HOME/lib/node_modules
14+
PATH=$NODE_HOME/bin:$PATH
15+
16+
function test_ethereum_url() {
17+
RESULT=$(wscat -c "$SHUTTER_NETWORK_NODE_ETHEREUMURL" -x '{"jsonrpc": "2.0", "method": "eth_syncing", "params": [], "id": 1}')
18+
if [[ $RESULT =~ '"id":1' ]]; then return 0; else
19+
echo "Could not find DAppNode RPC/WS url for this package!"
20+
echo "Please configure 'ETHEREUM_WS' to point to an applicable websocket RPC service."
21+
exit 1;
22+
fi
23+
}
24+
925
echo "[INFO | configure] Calculating keyper configuration values..."
1026

1127
SUPPORTED_NETWORKS="gnosis"
@@ -16,8 +32,11 @@ if [[ ! "$SHUTTER_P2P_LISTENADDRESSES" =~ ^\[.*\]$ ]]; then
1632
fi
1733

1834
export SHUTTER_P2P_ADVERTISEADDRESSES="[\"/ip4/${_DAPPNODE_GLOBAL_PUBLIC_IP}/tcp/${KEYPER_PORT}\", \"/ip4/${_DAPPNODE_GLOBAL_PUBLIC_IP}/udp/${KEYPER_PORT}/quic-v1\"]"
19-
export SHUTTER_NETWORK_NODE_ETHEREUMURL=${ETHEREUM_WS}
35+
36+
export SHUTTER_NETWORK_NODE_ETHEREUMURL=${ETHEREUM_WS:-$(get_execution_ws_url_from_global_env "$NETWORK" "$SUPPORTED_NETWORKS")}
2037
echo "[DEBUG | configure] SHUTTER_NETWORK_NODE_ETHEREUMURL is ${SHUTTER_NETWORK_NODE_ETHEREUMURL}"
38+
test_ethereum_url
39+
2140
export VALIDATOR_PUBLIC_KEY=$(cat "${SHUTTER_CHAIN_DIR}/config/priv_validator_pubkey.hex")
2241
export SHUTTER_METRICS_ENABLED=${SHUTTER_PUSH_METRICS_ENABLED}
2342
export FLOODSUB_DISCOVERY_ENABLED=true

0 commit comments

Comments
 (0)