8787 cardano_transactions_enabled : ${{ steps.prepare.outputs.cardano_transactions_enabled }}
8888 cardano_stake_distribution_enabled : ${{ steps.prepare.outputs.cardano_stake_distribution_enabled }}
8989 cardano_database_v2_enabled : ${{ steps.prepare.outputs.cardano_database_v2_enabled }}
90+ available_cardano_database_backends : ${{ steps.prepare.outputs.available_cardano_database_backends }}
9091 steps :
9192 - name : Prepare
9293 id : prepare
@@ -104,19 +105,26 @@ jobs:
104105
105106 echo "GENESIS_VERIFICATION_KEY=$(curl -s ${{ inputs.genesis_verification_key }})" >> $GITHUB_OUTPUT
106107 echo "ANCILLARY_VERIFICATION_KEY=$(curl -s ${{ inputs.ancillary_verification_key }})" >> $GITHUB_OUTPUT
107-
108+
108109 wget -q -O - ${{ inputs.aggregator_endpoint }} > aggregator_capabilities.json
110+ CARDANO_DATABASE_V2_CAPABILITY=$(jq '.capabilities.signed_entity_types | contains(["CardanoDatabase"])' aggregator_capabilities.json)
111+
109112 echo "cardano_transactions_enabled=$(jq '.capabilities.signed_entity_types | contains(["CardanoTransactions"])' aggregator_capabilities.json)" >> $GITHUB_OUTPUT
110113 echo "cardano_stake_distribution_enabled=$(jq '.capabilities.signed_entity_types | contains(["CardanoStakeDistribution"])' aggregator_capabilities.json)" >> $GITHUB_OUTPUT
111- echo "cardano_database_v2_enabled=$(jq '.capabilities.signed_entity_types | contains(["CardanoDatabase"])' aggregator_capabilities.json)" >> $GITHUB_OUTPUT
114+ echo "cardano_database_v2_enabled=$CARDANO_DATABASE_V2_CAPABILITY" >> $GITHUB_OUTPUT
115+
116+ if [[ $CARDANO_DATABASE_V2_CAPABILITY == "true" ]]; then
117+ echo 'available_cardano_database_backends=["v1","v2"]' >> $GITHUB_OUTPUT
118+ else
119+ echo 'available_cardano_database_backends=["v1"]' >> $GITHUB_OUTPUT
120+ fi
112121
113122 test-binaries :
114123 needs : [prepare]
115124 strategy :
116125 fail-fast : false
117126 matrix :
118127 os : [ubuntu-24.04, ubuntu-24.04-arm, macos-14, windows-latest]
119- extra_args : ["", "--include-ancillary"]
120128
121129 runs-on : ${{ matrix.os }}
122130 env :
@@ -153,37 +161,6 @@ jobs:
153161 ./mithril-client ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db snapshot list --backend v1
154162 echo "CDB_SNAPSHOT_DIGEST=$(./mithril-client --origin-tag CI cardano-db snapshot list --backend v1 --json | jq -r '.[0].digest')" >> $GITHUB_ENV
155163
156- - name : Cardano Database Snapshot / download & restore latest
157- shell : bash
158- working-directory : ./bin
159- run : ./mithril-client ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db download $CDB_SNAPSHOT_DIGEST --backend v1 --download-dir v1 ${{ matrix.extra_args }} 2>&1 | tee cdb-download-output.txt
160-
161- - name : Cardano Database Snapshot / verify Cardano node starts successfully
162- if : matrix.os == 'ubuntu-24.04'
163- shell : bash
164- run : .github/workflows/scripts/verify-cardano-db-restoration.sh ./bin/cdb-download-output.txt "${{ matrix.extra_args }}"
165-
166- # The 'snapshot-converter' binary is not currently supported on Linux ARM64 platforms.
167- - name : Ledger state snapshot conversion from InMemory to LMDB
168- if : matrix.os != 'ubuntu-24.04-arm' && matrix.extra_args == '--include-ancillary'
169- env :
170- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
171- shell : bash
172- working-directory : ./bin
173- run : ./mithril-client ${{ needs.prepare.outputs.debug_level }} tools utxo-hd snapshot-converter --db-directory v1/db --cardano-node-version latest --utxo-hd-flavor LMDB --commit
174-
175- - name : Remove downloaded artifacts to free up disk space (Linux, Windows)
176- if : runner.os != 'macOS'
177- shell : bash
178- working-directory : ./bin
179- run : rm --force v1/db/immutable/*.{chunk,primary,secondary}
180-
181- - name : Remove downloaded artifacts to free up disk space (macOs)
182- if : runner.os == 'macOS'
183- shell : bash
184- working-directory : ./bin
185- run : sudo rm -rf v1/db/
186-
187164 - name : Mithril Stake Distribution / list and get last hash
188165 shell : bash
189166 working-directory : ./bin
@@ -263,25 +240,77 @@ jobs:
263240 working-directory : ./bin
264241 run : ./mithril-client --origin-tag CI cardano-db snapshot show $CARDANO_DATABASE_V2_SNAPSHOT_HASH
265242
266- - name : Cardano Database V2 Snapshot / download & restore latest (Full restoration)
267- if : needs.prepare.outputs.cardano_database_v2_enabled == 'true'
243+ test-binaries-cdb-download :
244+ needs : [prepare]
245+ strategy :
246+ fail-fast : false
247+ matrix :
248+ backend : ${{ fromJson(needs.prepare.outputs.available_cardano_database_backends) }}
249+ os : [ubuntu-24.04, ubuntu-24.04-arm, macos-14, windows-latest]
250+ extra_args : ["", "--include-ancillary"]
251+
252+ runs-on : ${{ matrix.os }}
253+ env :
254+ GENESIS_VERIFICATION_KEY : ${{ needs.prepare.outputs.genesis_verification_key }}
255+ ANCILLARY_VERIFICATION_KEY : ${{ needs.prepare.outputs.ancillary_verification_key }}
256+ steps :
257+ - name : Checkout sources
258+ uses : actions/checkout@v4
259+
260+ - name : Checkout binary
261+ uses : dawidd6/action-download-artifact@v6
262+ with :
263+ name : mithril-distribution-${{ runner.os }}-${{ runner.arch }}
264+ path : ./bin
265+ commit : ${{ needs.prepare.outputs.sha }}
266+ branch : ${{ needs.prepare.outputs.branch }}
267+ workflow : ci.yml
268+ workflow_conclusion : success
269+
270+ - name : Set permissions
268271 shell : bash
269272 working-directory : ./bin
270- run : ./mithril-client ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db download --download-dir v2 $CARDANO_DATABASE_V2_SNAPSHOT_HASH ${{ matrix.extra_args }} 2>&1 | tee cdb-v2-download-output.txt
273+ run : chmod +x ./mithril-client
274+
275+ - name : fetch latest snapshot hash
276+ id : last_snapshot
277+ shell : bash
278+ working-directory : ./bin
279+ run : |
280+ if [ "${{ matrix.backend }}" == "v1" ]; then
281+ echo "hash=$(./mithril-client --origin-tag CI cardano-db snapshot list --backend ${{ matrix.backend }} --json | jq -r '.[0].digest')" >> $GITHUB_OUTPUT
282+ else
283+ echo "hash=$(./mithril-client --origin-tag CI cardano-db snapshot list --backend ${{ matrix.backend }} --json | jq -r '.[0].hash')" >> $GITHUB_OUTPUT
284+ fi
285+
286+ - name : Cardano Database Snapshot / download & restore latest
287+ shell : bash
288+ working-directory : ./bin
289+ run : |
290+ ./mithril-client ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db download ${{ steps.last_snapshot.outputs.hash }} --backend ${{ matrix.backend }} --download-dir "${{ matrix.backend }}" ${{ matrix.extra_args }} 2>&1 | tee cdb-${{ matrix.backend }}-download-output.txt
291+
292+ - name : Ledger state snapshot conversion from InMemory to LMDB
293+ # The 'snapshot-converter' binary is not currently supported on Linux ARM64 platforms.
294+ if : matrix.os != 'ubuntu-24.04-arm' && matrix.extra_args == '--include-ancillary' && matrix.backend == 'v2'
295+ env :
296+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
297+ shell : bash
298+ working-directory : ./bin
299+ run : ./mithril-client ${{ needs.prepare.outputs.debug_level }} tools utxo-hd snapshot-converter --db-directory v2/db --cardano-node-version latest --utxo-hd-flavor LMDB --commit
271300
272301 - name : Cardano Database V2 Snapshot / verify immutables
273- if : needs.prepare.outputs.cardano_database_v2_enabled == 'true '
302+ if : matrix.backend == 'v2 '
274303 shell : bash
275304 working-directory : ./bin
276- run : ./mithril-client ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db verify --db-dir v2/db $CARDANO_DATABASE_V2_SNAPSHOT_HASH | tee cdb-v2-verify-output.txt
305+ run : ./mithril-client ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db verify --db-dir v2/db ${{ steps.last_snapshot.outputs.hash }}
277306
278- - name : Cardano Database V2 Snapshot / verify Cardano node starts successfully
279- if : matrix.os == 'ubuntu-24.04' && needs.prepare.outputs.cardano_database_v2_enabled == 'true'
307+ - name : Cardano Database Snapshot / verify Cardano node starts successfully
308+ if : matrix.os == 'ubuntu-24.04'
280309 shell : bash
281- run : .github/workflows/scripts/verify-cardano-db-restoration.sh ./bin/cdb-v2 -download-output.txt "${{ matrix.extra_args }}"
310+ run : .github/workflows/scripts/verify-cardano-db-restoration.sh ./bin/cdb-${{ matrix.backend }} -download-output.txt "${{ matrix.extra_args }}"
282311
283312 - name : Cardano Database V2 Snapshot / verify tampered and missing immutables from a specific range
284- if : needs.prepare.outputs.cardano_database_v2_enabled == 'true '
313+ if : matrix.backend == 'v2 '
285314 shell : bash
286315 working-directory : ./bin
287316 run : |
@@ -292,7 +321,7 @@ jobs:
292321 echo "tampered chunk 5" > v2/db/immutable/00005.chunk
293322 echo "tampered primary 9" > v2/db/immutable/00009.primary
294323 echo "tampered outside verification range" > v2/db/immutable/00012.chunk
295- ./mithril-client ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db verify --end 10 --db-dir v2/db $CARDANO_DATABASE_V2_SNAPSHOT_HASH
324+ ./mithril-client ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db verify --end 10 --db-dir v2/db ${{ steps.last_snapshot.outputs.hash }}
296325 # Check missing files in immutables_verification_error-*.json
297326 jq -r '.["missing-files"] | sort | @csv' immutables_verification_error-*.json | grep -qx '"00007.chunk","00007.primary","00007.secondary"' || { echo "Error: missing-files array does not match expected values!"; exit 1; }
298327 # Check tampered files in immutables_verification_error-*.json
@@ -306,7 +335,6 @@ jobs:
306335 fail-fast : false
307336 matrix :
308337 os : [ubuntu-24.04]
309- extra_args : ["", "--include-ancillary"]
310338 runs-on : ${{ matrix.os }}
311339 env :
312340 GENESIS_VERIFICATION_KEY : ${{ needs.prepare.outputs.genesis_verification_key }}
@@ -337,19 +365,6 @@ jobs:
337365 ${{ steps.command.outputs.mithril_client }} --origin-tag CI cardano-db snapshot list --backend v1
338366 echo "CDB_SNAPSHOT_DIGEST=$(${{ steps.command.outputs.mithril_client }} --origin-tag CI cardano-db snapshot list --backend v1 --json | jq -r '.[0].digest')" >> $GITHUB_ENV
339367
340- - name : Cardano Database Snapshot / download & restore latest
341- shell : bash
342- run : ${{ steps.command.outputs.mithril_client }} ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db download $CDB_SNAPSHOT_DIGEST --backend v1 --download-dir /app/data/v1 ${{ matrix.extra_args }}
343-
344- - name : Ledger state snapshot conversion from InMemory to LMDB
345- if : matrix.extra_args == '--include-ancillary'
346- shell : bash
347- run : ${{ steps.command.outputs.mithril_client }} ${{ needs.prepare.outputs.debug_level }} tools utxo-hd snapshot-converter --db-directory /app/data/v1/db --cardano-node-version latest --utxo-hd-flavor LMDB --commit
348-
349- - name : Remove downloaded artifacts to free up disk space
350- shell : bash
351- run : sudo rm -rf $PWD/data/v1/db/
352-
353368 - name : Mithril Stake Distribution / list and get last hash
354369 shell : bash
355370 run : |
@@ -418,15 +433,59 @@ jobs:
418433 shell : bash
419434 run : ${{ steps.command.outputs.mithril_client }} --origin-tag CI cardano-db snapshot show $CARDANO_DATABASE_V2_SNAPSHOT_HASH
420435
421- - name : Cardano Database V2 Snapshot / download & restore latest (Full restoration)
422- if : needs.prepare.outputs.cardano_database_v2_enabled == 'true'
436+ test-docker-cdb-download :
437+ needs : [prepare]
438+ strategy :
439+ fail-fast : false
440+ matrix :
441+ backend : ${{ fromJson(needs.prepare.outputs.available_cardano_database_backends) }}
442+ os : [ubuntu-24.04]
443+ extra_args : ["", "--include-ancillary"]
444+
445+ runs-on : ${{ matrix.os }}
446+ env :
447+ GENESIS_VERIFICATION_KEY : ${{ needs.prepare.outputs.genesis_verification_key }}
448+ ANCILLARY_VERIFICATION_KEY : ${{ needs.prepare.outputs.ancillary_verification_key }}
449+ steps :
450+ - name : Prepare environment variables
451+ shell : bash
452+ run : |
453+ echo "MITHRIL_IMAGE_ID=${{ inputs.docker_image_id }}" >> $GITHUB_ENV
454+
455+ - name : Prepare Mithril client command
456+ id : command
457+ env :
458+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
459+ shell : bash
460+ run : |
461+ mkdir -p $PWD/data
462+ chmod -R a+w $PWD/data
463+ echo "mithril_client=docker run --rm -e NETWORK=$NETWORK -e GENESIS_VERIFICATION_KEY=$GENESIS_VERIFICATION_KEY -e ANCILLARY_VERIFICATION_KEY=$ANCILLARY_VERIFICATION_KEY -e AGGREGATOR_ENDPOINT=$AGGREGATOR_ENDPOINT -e GITHUB_TOKEN=$GITHUB_TOKEN --name='mithril-client' -v $PWD/data:/app/data ghcr.io/input-output-hk/mithril-client:$MITHRIL_IMAGE_ID" >> $GITHUB_OUTPUT
464+
465+ - name : fetch latest snapshot hash
466+ id : last_snapshot
423467 shell : bash
424- run : ${{ steps.command.outputs.mithril_client }} ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db download $CARDANO_DATABASE_V2_SNAPSHOT_HASH --download-dir /app/data/v2 ${{ matrix.extra_args }}
468+ run : |
469+ if [ "${{ matrix.backend }}" == "v1" ]; then
470+ echo "hash=$(${{ steps.command.outputs.mithril_client }} --origin-tag CI cardano-db snapshot list --backend ${{ matrix.backend }} --json | jq -r '.[0].digest')" >> $GITHUB_OUTPUT
471+ else
472+ echo "hash=$(${{ steps.command.outputs.mithril_client }} --origin-tag CI cardano-db snapshot list --backend ${{ matrix.backend }} --json | jq -r '.[0].hash')" >> $GITHUB_OUTPUT
473+ fi
474+
475+ - name : Cardano Database Snapshot / download & restore latest
476+ shell : bash
477+ run : |
478+ ${{ steps.command.outputs.mithril_client }} ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db download ${{ steps.last_snapshot.outputs.hash }} --backend ${{ matrix.backend }} --download-dir "/app/data/${{ matrix.backend }}" ${{ matrix.extra_args }}
479+
480+ - name : Ledger state snapshot conversion from InMemory to LMDB
481+ if : matrix.extra_args == '--include-ancillary' && matrix.backend == 'v2'
482+ shell : bash
483+ run : ${{ steps.command.outputs.mithril_client }} ${{ needs.prepare.outputs.debug_level }} tools utxo-hd snapshot-converter --db-directory /app/data/v2/db --cardano-node-version latest --utxo-hd-flavor LMDB --commit
425484
426485 - name : Cardano Database V2 Snapshot / verify immutables
427- if : needs.prepare.outputs.cardano_database_v2_enabled == 'true '
486+ if : matrix.backend == 'v2 '
428487 shell : bash
429- run : ${{ steps.command.outputs.mithril_client }} ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db verify $CARDANO_DATABASE_V2_SNAPSHOT_HASH --db-dir /app/data/v2/db
488+ run : ${{ steps.command.outputs.mithril_client }} ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db verify --db-dir /app/data/v2/db ${{ steps.last_snapshot.outputs.hash }}
430489
431490 test-mithril-client-wasm :
432491 needs : [prepare]
0 commit comments