Skip to content

Commit e69db76

Browse files
authored
fix sharding ordinal with eso
1 parent d611ff3 commit e69db76

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

charts/horcrux/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: horcrux
33
description: A production-grade Helm chart for deploying Horcrux remote signer for Cosmos chains
44
type: application
5-
version: 1.0.6
5+
version: 1.0.7
66
appVersion: "v3.3.2"
77
keywords:
88
- cosmos

charts/horcrux/templates/externalsecrets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{- if and (eq .Values.shards.method "externalSecret") .Values.shards.externalSecrets.enabled }}
22
{{- range $i := until (int .Values.replicaCount) }}
3-
{{- $shardId := add $i 1 }}
43
{{- $shardConfig := index $.Values.shards.externalSecrets.shardConfigs $i }}
4+
{{- $shardId := int $shardConfig.shardId }}
55
---
66
apiVersion: external-secrets.io/v1
77
kind: ExternalSecret

charts/horcrux/templates/statefulset.yaml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,16 @@ spec:
4949
- |
5050
set -e
5151
ORDINAL=${HOSTNAME##*-}
52-
SHARD_ID=$((ORDINAL + 1))
53-
echo "Initializing co-signer ${SHARD_ID}"
52+
echo "Initializing co-signer with ordinal ${ORDINAL}"
5453
55-
# Copy shard files to emptyDir
56-
cp /horcrux/shards/shard-${SHARD_ID}/{{ .Values.chain.id }}_shard.json /shard-files/{{ .Values.chain.id }}_shard.json
57-
cp /horcrux/shards/shard-${SHARD_ID}/ecies_keys.json /shard-files/ecies_keys.json
54+
# Copy shard files to emptyDir (using ordinal as array index)
55+
cp /horcrux/shards/shard-${ORDINAL}/{{ .Values.chain.id }}_shard.json /shard-files/{{ .Values.chain.id }}_shard.json
56+
cp /horcrux/shards/shard-${ORDINAL}/ecies_keys.json /shard-files/ecies_keys.json
5857
5958
# Initialize state if it doesn't exist
6059
if [ ! -f /horcrux/state/{{ .Values.chain.id }}_priv_validator_state.json ]; then
6160
echo "Initializing state from shard..."
62-
cp /horcrux/shards/shard-${SHARD_ID}/{{ .Values.chain.id }}_priv_validator_state.json /horcrux/state/
61+
cp /horcrux/shards/shard-${ORDINAL}/{{ .Values.chain.id }}_priv_validator_state.json /horcrux/state/
6362
chmod 600 /horcrux/state/{{ .Values.chain.id }}_priv_validator_state.json
6463
else
6564
echo "State already exists, skipping initialization"
@@ -68,7 +67,7 @@ spec:
6867
# Create raft directory
6968
mkdir -p /horcrux/raft
7069
71-
echo "Initialization complete for shard ${SHARD_ID}"
70+
echo "Initialization complete for ordinal ${ORDINAL}"
7271
volumeMounts:
7372
- name: shards
7473
mountPath: /horcrux/shards
@@ -166,17 +165,32 @@ spec:
166165
projected:
167166
defaultMode: 0400
168167
sources:
168+
{{- if eq .Values.shards.method "externalSecret" }}
169+
{{- range $i, $shardConfig := .Values.shards.externalSecrets.shardConfigs }}
170+
{{- $shardId := int $shardConfig.shardId }}
171+
- secret:
172+
name: {{ include "horcrux.shardSecretName" (dict "root" $ "shardId" $shardId) }}
173+
items:
174+
- key: {{ $.Values.chain.id }}_shard.json
175+
path: shard-{{ $i }}/{{ $.Values.chain.id }}_shard.json
176+
- key: ecies_keys.json
177+
path: shard-{{ $i }}/ecies_keys.json
178+
- key: {{ $.Values.chain.id }}_priv_validator_state.json
179+
path: shard-{{ $i }}/{{ $.Values.chain.id }}_priv_validator_state.json
180+
{{- end }}
181+
{{- else }}
169182
{{- range $i := until (int .Values.replicaCount) }}
170183
{{- $shardId := add $i 1 }}
171184
- secret:
172185
name: {{ include "horcrux.shardSecretName" (dict "root" $ "shardId" $shardId) }}
173186
items:
174187
- key: {{ $.Values.chain.id }}_shard.json
175-
path: shard-{{ $shardId }}/{{ $.Values.chain.id }}_shard.json
188+
path: shard-{{ $i }}/{{ $.Values.chain.id }}_shard.json
176189
- key: ecies_keys.json
177-
path: shard-{{ $shardId }}/ecies_keys.json
190+
path: shard-{{ $i }}/ecies_keys.json
178191
- key: {{ $.Values.chain.id }}_priv_validator_state.json
179-
path: shard-{{ $shardId }}/{{ $.Values.chain.id }}_priv_validator_state.json
192+
path: shard-{{ $i }}/{{ $.Values.chain.id }}_priv_validator_state.json
193+
{{- end }}
180194
{{- end }}
181195
- name: shard-files
182196
emptyDir: {}

0 commit comments

Comments
 (0)