Skip to content

Commit 79c69ac

Browse files
Merge pull request #10 from shutter-network/main
Shutter Gnosis DAppNode Release 0.1.2
1 parent e3d578d commit 79c69ac

File tree

10 files changed

+213
-18
lines changed

10 files changed

+213
-18
lines changed

docker-compose.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@ services:
1414
context: shutter
1515
args:
1616
ASSETS_VERSION: shutter-gnosis-1000-set1.3 # $NETWORK-10*$CHAIN_ID-set-$VERSION
17-
UPSTREAM_VERSION: v1.3.6
17+
UPSTREAM_VERSION: v1.3.10
1818
KEYPER_CONFIG_DIR: /keyper/config
1919
SHUTTER_CHAIN_DIR: /chain
2020
STAKER_SCRIPTS_VERSION: v0.1.0
2121
restart: unless-stopped
2222
environment:
23-
SHUTTER_GNOSIS_NODE_PRIVATEKEY: ""
24-
SHUTTER_PUSH_METRICS_ENABLED: false
25-
KEYPER_NAME: ""
23+
- SHUTTER_GNOSIS_NODE_PRIVATEKEY=""
24+
- SHUTTER_PUSH_METRICS_ENABLED=false
25+
- KEYPER_NAME=""
26+
- SHUTTER_PUSH_LOGS_ENABLED=false
27+
- PUSHGATEWAY_USERNAME=""
28+
- PUSHGATEWAY_PASSWORD=""
29+
- ETHEREUM_WS=
30+
- BEACON_HTTP=
2631
volumes:
2732
- chain:/chain
2833
- keyper-config:/keyper/config
@@ -34,11 +39,11 @@ services:
3439
ASSETS_VERSION: shutter-gnosis-1000-set1.3 # $NETWORK-10*$CHAIN_ID-set-$VERSION
3540
restart: on-failure
3641
environment:
37-
SHUTTER_PUSH_METRICS_ENABLED: false
38-
KEYPER_NAME: ""
39-
PUSHGATEWAY_URL: "https://keyperingest.metrics.shutter.network/api/v1/write"
40-
PUSHGATEWAY_USERNAME: ""
41-
PUSHGATEWAY_PASSWORD: ""
42+
- SHUTTER_PUSH_METRICS_ENABLED=false
43+
- KEYPER_NAME=""
44+
- PUSHGATEWAY_URL="https://keyperingest.metrics.shutter.network/api/v1/write"
45+
- PUSHGATEWAY_USERNAME=""
46+
- PUSHGATEWAY_PASSWORD=""
4247
volumes:
4348
- metrics-config:/config
4449

setup-wizard.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,39 @@ fields:
2121
required: false
2222
secret: true
2323

24+
25+
- id: external_ws_rpc
26+
title: External WS RPC
27+
description: |
28+
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.
29+
target:
30+
type: environment
31+
name: ETHEREUM_WS
32+
service: shutter
33+
required: false
34+
35+
- id: external_beacon_http_rpc
36+
title: External Beacon HTTP RPC
37+
description: |
38+
A HTTP connection to an external ethereum beacon RPC (e.g. 'https://some.external.url' or 'http://1.2.3.4:4000'). If this is given, shutter will use this beacon api to connect to the network. If not, shutter will try to use an beacon api service on this dappnode.
39+
target:
40+
type: environment
41+
name: BEACON_HTTP
42+
service: shutter
43+
required: false
44+
45+
- id: enable_push_logs
46+
title: Enable Push Logs
47+
description: |
48+
Enable the push logs feature to send logs to an external server controlled by Shutter.
49+
target:
50+
type: environment
51+
name: SHUTTER_PUSH_LOGS_ENABLED
52+
service: [shutter, metrics]
53+
enum:
54+
- "true"
55+
- "false"
56+
2457
- id: enable_push_metrics
2558
title: Enable Push Metrics
2659
description: |
@@ -51,7 +84,7 @@ fields:
5184
target:
5285
type: environment
5386
name: PUSHGATEWAY_USERNAME
54-
service: metrics
87+
service: [metrics, shutter]
5588
required: false
5689
if: { enable_push_metrics: { "enum": ["true"] } }
5790

@@ -62,7 +95,7 @@ fields:
6295
target:
6396
type: environment
6497
name: PUSHGATEWAY_PASSWORD
65-
service: metrics
98+
service: [metrics, shutter]
6699
required: false
67100
secret: true
68101
if: { enable_push_metrics: { "enum": ["true"] } }

shutter/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,40 @@ ADD ${STAKER_SCRIPTS_URL}/dvt_lsd_tools.sh /etc/profile.d/
4141

4242
COPY go-shutter-settings ${SHUTTER_SETTINGS_SRC_DIR}
4343
COPY supervisord.conf /etc/supervisord.conf
44+
COPY promtail_config.yaml /etc/promtail_config.yaml
4445

4546
RUN go build -C ${SHUTTER_SETTINGS_SRC_DIR} -o /usr/local/bin/go_shutter_settings
4647

4748
RUN mkdir -p ${KEYPER_CONFIG_DIR} ${SHUTTER_CHAIN_DIR} ${ASSETS_DIR} /opt/supervisor && \
4849
chmod +rx /etc/profile.d/dvt_lsd_tools.sh
4950

5051
COPY scripts /usr/local/bin/
52+
RUN chmod +x /usr/local/bin/*.sh
5153
COPY --from=assets ${ASSETS_DIR}/ ${ASSETS_DIR}/
5254

55+
# For pushing logs to loki
56+
RUN apt-get -y install wget gpg
57+
RUN mkdir -p /etc/apt/keyrings/
58+
RUN wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor > /etc/apt/keyrings/grafana.gpg
59+
RUN echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | tee /etc/apt/sources.list.d/grafana.list
60+
# promtail & rotatelogs (from apache2)
61+
RUN apt-get update && apt-get -y install promtail apache2
62+
63+
RUN apt-get update && apt-get install -y \
64+
ca-certificates \
65+
curl
66+
67+
ARG NODE_VERSION=22.14.0
68+
ARG NODE_PACKAGE=node-v$NODE_VERSION-linux-x64
69+
ARG NODE_HOME=/opt/$NODE_PACKAGE
70+
71+
ENV NODE_PATH $NODE_HOME/lib/node_modules
72+
ENV PATH $NODE_HOME/bin:$PATH
73+
74+
RUN curl https://nodejs.org/dist/v$NODE_VERSION/$NODE_PACKAGE.tar.gz | tar -xzC /opt/
75+
76+
RUN npm install -g wscat
77+
5378
# Placed here to rebuild less layers
5479
ENV CHAIN_PORT=${CHAIN_PORT} \
5580
SHUTTER_P2P_LISTENADDRESSES="/ip4/0.0.0.0/tcp/${KEYPER_PORT},/ip4/0.0.0.0/udp/${KEYPER_PORT}/quic-v1" \

shutter/promtail_config.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
server:
2+
http_listen_port: 9080
3+
grpc_listen_port: 0
4+
5+
positions:
6+
filename: /tmp/positions.yaml
7+
8+
client:
9+
url: https://logs.metrics.shutter.network/insert/loki/api/v1/push
10+
basic_auth:
11+
username: ${PUSHGATEWAY_USERNAME}
12+
password: ${PUSHGATEWAY_PASSWORD}
13+
14+
scrape_configs:
15+
- job_name: configure
16+
pipeline_stages:
17+
- docker:
18+
static_configs:
19+
- targets:
20+
- localhost
21+
labels:
22+
job: configure
23+
host: ${KEYPER_NAME}
24+
__path__: /tmp/configure.log
25+
26+
- job_name: keyper
27+
pipeline_stages:
28+
- docker:
29+
static_configs:
30+
- targets:
31+
- localhost
32+
labels:
33+
job: keyper
34+
host: ${KEYPER_NAME}
35+
__path__: /tmp/keyper.log
36+
37+
- job_name: chain
38+
pipeline_stages:
39+
- docker:
40+
static_configs:
41+
- targets:
42+
- localhost
43+
labels:
44+
job: chain
45+
host: ${KEYPER_NAME}
46+
__path__: /tmp/chain.log

shutter/scripts/configure_keyper.sh

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,43 @@
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+
# FIXME: This is a workaround for the issue with the [email protected] not setting get_execution_ws_url_from_global_env correctly in the environment variables.
18+
# Git Issue: https://github.com/dappnode/staker-package-scripts/issues/11
19+
export SHUTTER_GNOSIS_NODE_ETHEREUMURL=${ETHEREUM_WS:-$(get_execution_ws_url_from_global_env ${NETWORK} ${SUPPORTED_NETWORKS})}
20+
RESULT=$(wscat -c "$SHUTTER_GNOSIS_NODE_ETHEREUMURL" -x '{"jsonrpc": "2.0", "method": "eth_syncing", "params": [], "id": 1}')
21+
if [[ $RESULT =~ '"id":1' ]]; then return 0; else
22+
export SHUTTER_GNOSIS_NODE_ETHEREUMURL=ws://execution.${NETWORK}.dncore.dappnode:8545
23+
RESULT=$(wscat -c "$SHUTTER_GNOSIS_NODE_ETHEREUMURL" -x '{"jsonrpc": "2.0", "method": "eth_syncing", "params": [], "id": 1}')
24+
if [[ $RESULT =~ '"id":1' ]]; then return 0; else
25+
echo "Could not find DAppNode RPC/WS url for this package!"
26+
echo "Please configure 'ETHEREUM_WS' to point to an applicable websocket RPC service."
27+
exit 1
28+
fi
29+
fi
30+
}
31+
32+
function test_beacon_url() {
33+
export SHUTTER_BEACONAPIURL=${BEACON_HTTP:-$(get_beacon_api_url_from_global_env "$NETWORK" "$SUPPORTED_NETWORKS")}
34+
RESULT=$(curl -X GET "${SHUTTER_BEACONAPIURL}/eth/v1/beacon/genesis" -H "Accept: application/json")
35+
if [[ $RESULT =~ '"genesis_time"' ]]; then return 0; else
36+
export SHUTTER_BEACONAPIURL=http://beacon-chain.${NETWORK}.dncore.dappnode:4000
37+
RESULT=$(curl -X GET "${SHUTTER_BEACONAPIURL}/eth/v1/beacon/genesis" -H "Accept: application/json")
38+
if [[ $RESULT =~ '"genesis_time"' ]]; then return 0; else
39+
echo "Could not find DAppNode Beacon API url for this package!"
40+
echo "Please configure 'BEACON_HTTP' to point to an applicable HTTP API service."
41+
exit 1;
42+
fi
43+
fi
44+
}
45+
946
echo "[INFO | configure] Calculating keyper configuration values..."
1047

1148
SUPPORTED_NETWORKS="gnosis"
@@ -16,9 +53,16 @@ if [[ ! "$SHUTTER_P2P_LISTENADDRESSES" =~ ^\[.*\]$ ]]; then
1653
fi
1754

1855
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_BEACONAPIURL=$(get_beacon_api_url_from_global_env "$NETWORK" "$SUPPORTED_NETWORKS")
56+
57+
58+
test_beacon_url
59+
echo "[DEBUG | configure] SHUTTER_BEACONAPIURL is ${SHUTTER_BEACONAPIURL}"
60+
2061
export SHUTTER_GNOSIS_NODE_CONTRACTSURL=http://execution.gnosis.dncore.dappnode:8545
21-
export SHUTTER_GNOSIS_NODE_ETHEREUMURL=$(get_execution_ws_url_from_global_env "$NETWORK" "$SUPPORTED_NETWORKS")
62+
63+
test_ethereum_url
64+
echo "[DEBUG | configure] SHUTTER_GNOSIS_NODE_ETHEREUMURL is ${SHUTTER_GNOSIS_NODE_ETHEREUMURL}"
65+
2266
export VALIDATOR_PUBLIC_KEY=$(cat "${SHUTTER_CHAIN_DIR}/config/priv_validator_pubkey.hex")
2367
export SHUTTER_DISCOVERY_NAMESPACE="${_ASSETS_DISCOVERY_NAME_PREFIX}-${_ASSETS_INSTANCE_ID}"
2468
export SHUTTER_METRICS_ENABLED=${SHUTTER_PUSH_METRICS_ENABLED}

shutter/scripts/run_chain.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
run_chain() {
44

55
echo "[INFO | chain] Starting chain..."
6-
7-
$SHUTTER_BIN chain --config "$SHUTTER_CHAIN_CONFIG_FILE"
6+
if [[ SHUTTER_PUSH_LOGS_ENABLED=true ]];
7+
then
8+
$SHUTTER_BIN chain --config "$SHUTTER_CHAIN_CONFIG_FILE" |& rotatelogs -n 1 -e -c /tmp/chain.log 5M
9+
else
10+
$SHUTTER_BIN chain --config "$SHUTTER_CHAIN_CONFIG_FILE"
11+
fi
812
}
913

1014
run_chain

shutter/scripts/run_configure.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
4+
if [[ SHUTTER_PUSH_LOGS_ENABLED=true ]];
5+
then
6+
configure.sh |& rotatelogs -n 1 -e -c /tmp/configure.log 5M
7+
else
8+
configure.sh
9+
fi

shutter/scripts/run_keyper.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ perform_chain_healthcheck() {
1818
}
1919

2020
run_keyper() {
21-
$SHUTTER_BIN gnosiskeyper --config "$KEYPER_CONFIG_FILE"
21+
if [[ SHUTTER_PUSH_LOGS_ENABLED=true ]];
22+
then
23+
$SHUTTER_BIN gnosiskeyper --config "$KEYPER_CONFIG_FILE" |& rotatelogs -n 1 -e -c /tmp/keyper.log 5M
24+
else
25+
$SHUTTER_BIN gnosiskeyper --config "$KEYPER_CONFIG_FILE"
26+
fi
2227
}
2328

2429
perform_chain_healthcheck

shutter/scripts/run_promtail.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
run_promtail() {
4+
if [[ $SHUTTER_PUSH_LOGS_ENABLED=true ]];
5+
then
6+
promtail -config.expand-env=true -log-config-reverse-order -print-config-stderr -config.file /etc/promtail_config.yaml
7+
else
8+
tail -f /dev/null
9+
fi
10+
}
11+
12+
run_promtail

shutter/supervisord.conf

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
1818
serverurl=unix:///var/run/supervisor.sock
1919

2020
[program:configure]
21-
command = configure.sh
21+
command = run_configure.sh
2222
priority = 1
2323
autostart = true
2424
autorestart = false
@@ -47,4 +47,16 @@ autorestart = true
4747
stdout_logfile = /dev/stdout
4848
stdout_logfile_maxbytes = 0
4949
stderr_logfile = /dev/stderr
50-
stderr_logfile_maxbytes = 0
50+
stderr_logfile_maxbytes = 0
51+
52+
[program:promtail]
53+
command = run_promtail.sh ; we ingest 'rotatelogs' managed logfiles -- there is potential for some missed log lines.
54+
priority = 4
55+
autostart = %(ENV_SHUTTER_PUSH_LOGS_ENABLED)s
56+
startretries = 9999 ; A large number enough to cover node updates
57+
autorestart = %(ENV_SHUTTER_PUSH_LOGS_ENABLED)s
58+
environment = KEYPER_NAME="%(ENV_KEYPER_NAME)s",PUSHGATEWAY_USERNAME="%(ENV_PUSHGATEWAY_USERNAME)s",PUSHGATEWAY_PASSWORD="%(ENV_PUSHGATEWAY_PASSWORD)s",SHUTTER_PUSH_LOGS_ENABLED="%(ENV_SHUTTER_PUSH_LOGS_ENABLED)s"
59+
stdout_logfile = /dev/stdout
60+
stdout_logfile_maxbytes = 0
61+
stderr_logfile = /dev/stderr
62+
stderr_logfile_maxbytes = 0

0 commit comments

Comments
 (0)