@@ -34,12 +34,16 @@ spec:
3434 initContainers :
3535 # Download Cardano snapshot using mithril-client
3636 - name : mithril-snapshot
37- image : {{ .Values.image.repository }}:{{ .Values.image.tag }}
38- imagePullPolicy : {{ .Values.image.pullPolicy }}
37+ securityContext :
38+ runAsUser : 0
39+ runAsGroup : 0
40+ image : {{ .Values.mithril.image.repository | default .Values.image.repository }}:{{ .Values.mithril.image.tag | default .Values.image.tag }}
41+ imagePullPolicy : {{ .Values.mithril.image.pullPolicy }}
3942 command : ["/bin/sh", "-c"]
4043 args :
4144 - |
4245 set -e
46+ export PATH=/app/bin:$PATH
4347 NETWORK="{{ .Values.cardano_network }}"
4448
4549 if [ "$DEBUG_INIT" = "true" ]; then
5054 ls -la /data/db/ || true
5155 fi
5256
53- if ! command -v jq >/dev/null 2>&1; then
54- echo "ERROR: jq is required but not found in the image"
55- exit 1
56- fi
57+
5758 if ! command -v mithril-client >/dev/null 2>&1; then
5859 echo "ERROR: mithril-client is required but not found in the image"
5960 exit 1
@@ -88,15 +89,26 @@ spec:
8889 fi
8990
9091 # Read keys from image config files if they exist, otherwise use values from helm chart
92+ # Read keys from image config files if they exist, otherwise use values from helm chart or fall back to known defaults
9193 if [ -f "/opt/cardano/config/${NETWORK}/genesis.vkey" ] && [ -s "/opt/cardano/config/${NETWORK}/genesis.vkey" ]; then
9294 GENESIS_VERIFICATION_KEY=$(cat /opt/cardano/config/${NETWORK}/genesis.vkey)
9395 export GENESIS_VERIFICATION_KEY
9496 elif [ -n "{{ .Values.mithril.genesisVerificationKey }}" ]; then
9597 export GENESIS_VERIFICATION_KEY="{{ .Values.mithril.genesisVerificationKey }}"
9698 else
97- echo "ERROR: Genesis verification key not found in image or values.yaml"
98- echo "Please set mithril.genesisVerificationKey in values.yaml"
99- exit 1
99+ echo "Resolving default genesis verification key automatically for ${NETWORK}..."
100+ case ${NETWORK} in
101+ mainnet)
102+ export GENESIS_VERIFICATION_KEY="5b3139312c36362c3134302c3138352c3133382c31312c3233372c3230372c3235302c3134342c32372c322c3138382c33302c31322c38312c3135352c3230342c31302c3137392c37352c32332c3133382c3139362c3231372c352c31342c32302c35372c37392c33392c3137365d"
103+ ;;
104+ preview|preprod)
105+ export GENESIS_VERIFICATION_KEY="5b3132372c37332c3132342c3136312c362c3133372c3133312c3231332c3230372c3131372c3139382c38352c3137362c3139392c3136322c3234312c36382c3132332c3131392c3134352c31332c3233322c3234332c34392c3232392c322c3234392c3230352c3230352c33392c3233352c34345d"
106+ ;;
107+ *)
108+ echo "ERROR: Genesis verification key not found and no default for ${NETWORK}"
109+ exit 1
110+ ;;
111+ esac
100112 fi
101113
102114 if [ -f "/opt/cardano/config/${NETWORK}/ancillary.vkey" ] && [ -s "/opt/cardano/config/${NETWORK}/ancillary.vkey" ]; then
@@ -105,7 +117,18 @@ spec:
105117 elif [ -n "{{ .Values.mithril.ancillaryVerificationKey }}" ]; then
106118 export ANCILLARY_VERIFICATION_KEY="{{ .Values.mithril.ancillaryVerificationKey }}"
107119 else
108- echo "No ancillary verification key found (optional - skipping fast bootstrap)"
120+ echo "Resolving default ancillary verification key automatically for ${NETWORK}..."
121+ case ${NETWORK} in
122+ mainnet)
123+ export ANCILLARY_VERIFICATION_KEY="5b32332c37312c39362c3133332c34372c3235332c3232362c3133362c3233352c35372c3136342c3130362c3138362c322c32312c32392c3132302c3136332c38392c3132312c3137372c3133382c3230382c3133382c3231342c39392c35382c32322c302c35382c33322c36395d"
124+ ;;
125+ preview|preprod)
126+ export ANCILLARY_VERIFICATION_KEY="5b3138392c3139322c3231362c3135302c3131342c3231362c3233372c3231302c34352c31382c32312c3139362c3230382c3234362c3134362c322c3235322c3234332c3235312c3139372c32382c3135372c3230342c3134352c33302c31342c3232382c3136382c3132392c38332c3133362c33365d"
127+ ;;
128+ *)
129+ echo "No ancillary verification key default found for ${NETWORK} (optional)"
130+ ;;
131+ esac
109132 fi
110133
111134 export AGGREGATOR_ENDPOINT=https://aggregator.${__path}.api.mithril.network/aggregator
@@ -122,7 +145,7 @@ spec:
122145 echo "Using configured snapshot digest: ${SNAPSHOT_DIGEST}"
123146 else
124147 echo "Fetching latest snapshot digest from ${AGGREGATOR_ENDPOINT}..."
125- SNAPSHOT_DIGEST=$(mithril-client cardano-db snapshot list --json | jq -r '.[0].hash' )
148+ SNAPSHOT_DIGEST=$(mithril-client cardano-db snapshot list --json | grep -o '"hash":"[^"]*' | head -n 1 | cut -d'"' -f4 )
126149 echo "Latest snapshot digest: ${SNAPSHOT_DIGEST}"
127150 fi
128151
0 commit comments