Skip to content

Commit 13c76c8

Browse files
fix(heimdall): update snapshot download (#440)
--------- Co-authored-by: Carlos Jorge <carlos@graphops.xyz>
1 parent bb5ddba commit 13c76c8

File tree

3 files changed

+28
-33
lines changed

3 files changed

+28
-33
lines changed

charts/heimdall/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ We do not recommend that you upgrade the application by overriding `image.tag`.
5454
| heimdall.config.ethRpcUrl | Ethereum RPC address | string | `""` |
5555
| heimdall.config.extraArgs | Additional CLI arguments to pass to Heimdall | list | `[]` |
5656
| heimdall.config.fromSnapshot.enabled | Enable initialising Heimdall from a remote Snapshot | bool | `false` |
57-
| heimdall.config.fromSnapshot.snapshotUrl | URL to snapshot to download and extract, see [here](https://snapshots.matic.today) | string | `nil` |
57+
| heimdall.config.fromSnapshot.snapshotUrl | URL to snapshot to download and extract, see [here](https://docs.polygon.technology/pos/how-to/snapshots/) | string | `nil` |
5858
| heimdall.config.logLevel | Log level setup | string | `"main:info,state:info,*:error"` |
5959
| heimdall.config.logsType | Logs format | string | `"json"` |
6060
| heimdall.config.metrics.enabled | Enable metrics | bool | `true` |

charts/heimdall/templates/heimdall/statefulset.yaml

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,17 @@ spec:
4949
configMap:
5050
name: {{ include "heimdall.fullname" . }}-{{ $componentName }}
5151
initContainers:
52-
- name: {{ $componentName }}-init
52+
- name: {{ $componentName }}-init-config
5353
image: "{{ $values.image.repository }}:{{ $values.image.tag | default .Chart.AppVersion }}"
54-
imagePullPolicy: {{ $values.image.pullPolicy }}
55-
# securityContext:
56-
# readOnlyRootFilesystem: false
57-
# capabilities:
58-
# drop:
59-
# - ALL
60-
# command: ["sh", "-c", "HEIMDALL_DIR=/storage /root/heimdall/docker/entrypoint.sh start"]
6154
command:
6255
- sh
6356
- -c
6457
- |
6558
set -ex
66-
6759
HEIMDALLD_HOME="/storage"
6860
69-
# If config hasn't been boostrapped already, do it
61+
# If config hasn't been bootstrapped already, do it
7062
if [ ! -f "$HEIMDALLD_HOME/config/config.toml" ]; then
71-
# Write out init config for Heimdall
7263
heimdalld --home $HEIMDALLD_HOME init
7364
fi
7465
@@ -87,15 +78,6 @@ spec:
8778
else
8879
sed -iE "s#^prometheus \?=.*#prometheus = false#" config.toml
8980
fi
90-
91-
# If enabled and snapshot URL has been provided, bootstrap snapshot
92-
if [ "${BOOTSTRAP}" = 1 ] && [ "${SNAPSHOT_URL}" != "" ]; then
93-
if [ ! -f "$HEIMDALLD_HOME/from_snapshot" ] || [ "$(cat $HEIMDALLD_HOME/from_snapshot)" != "${SNAPSHOT_URL}" ]; then
94-
mkdir -p ${HEIMDALLD_HOME}/data
95-
wget -c "${SNAPSHOT_URL}" -O - | tar -xz -C ${HEIMDALLD_HOME}/data
96-
echo "${SNAPSHOT_URL}" > ${HEIMDALLD_HOME}/from_snapshot
97-
fi
98-
fi
9981
volumeMounts:
10082
- name: storage
10183
mountPath: /storage
@@ -112,19 +94,32 @@ spec:
11294
- name: METRICS_PORT
11395
value: {{ index $values.service.ports "http-metrics" | quote }}
11496
{{- end }}
115-
{{- if $values.config.fromSnapshot.enabled }}
116-
- name: BOOTSTRAP
117-
value: "1"
97+
98+
{{- if and $values.config.fromSnapshot.enabled $values.config.fromSnapshot.snapshotUrl }}
99+
- name: {{ $componentName }}-init-snapshot
100+
## TODO: update tag
101+
image: ghcr.io/graphops/docker-builds/init-stream-download@sha256:acbe5bff3b273b6e56b7aad20e8368ab9ddb091250b744e41ad66d6e7c2d0901
102+
command:
103+
- sh
104+
- -c
105+
- |
106+
set -ex
107+
HEIMDALLD_HOME="/storage"
108+
# If enabled and snapshot URL has been provided, bootstrap snapshot
109+
if [ ! -f "$HEIMDALLD_HOME/from_snapshot" ] || [ "$(cat $HEIMDALLD_HOME/from_snapshot)" != "${SNAPSHOT_URL}" ]; then
110+
mkdir -p ${HEIMDALLD_HOME}/data
111+
wget -c "${SNAPSHOT_URL}" -O snapshot.tar.lz4 || { echo "Download failed. Exiting."; exit 1; }
112+
lz4 -d snapshot.tar.lz4 snapshot.tar || { echo "Decompression failed. Exiting."; exit 1; }
113+
tar -xvf snapshot.tar -C ${HEIMDALLD_HOME}/data || { echo "Extraction failed. Exiting."; exit 1; }
114+
echo "${SNAPSHOT_URL}" > ${HEIMDALLD_HOME}/from_snapshot
115+
fi
116+
volumeMounts:
117+
- name: storage
118+
mountPath: /storage
119+
env:
118120
- name: SNAPSHOT_URL
119121
value: {{ $values.config.fromSnapshot.snapshotUrl }}
120-
{{- end }}
121-
{{- with $values.env }}
122-
{{- range $key, $val := .}}
123-
- name: {{ $key }}
124-
value: {{ $val | quote }}
125-
{{- end }}
126-
{{- end }}
127-
122+
{{- end }}
128123
containers:
129124
- name: {{ $componentName }}
130125
image: "{{ $values.image.repository }}:{{ $values.image.tag | default .Chart.AppVersion }}"

charts/heimdall/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ heimdall:
7272
fromSnapshot:
7373
# -- Enable initialising Heimdall from a remote Snapshot
7474
enabled: false
75-
# -- URL to snapshot to download and extract, see [here](https://snapshots.matic.today)
75+
# -- URL to snapshot to download and extract, see [here](https://docs.polygon.technology/pos/how-to/snapshots/)
7676
snapshotUrl:
7777

7878
# -- Options for Heimdall rest-server sidecar

0 commit comments

Comments
 (0)