@@ -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"
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