Refresh ledger #601
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2018-2023 The MobileCoin Foundation | |
# | |
# Daily job to refresh ledger db files | |
name: Refresh ledger | |
on: | |
workflow_dispatch: {} | |
schedule: | |
- cron: '0 0 * * *' | |
# Start full-service | |
# Monitor full-service util ledger has finished syncing | |
# Stop full-service | |
# Copy ledger to azure blob | |
jobs: | |
refresh-ledger: | |
runs-on: mco-dev-small-x64 | |
container: | |
image: mobilecoin/gha-azure-helper:latest | |
strategy: | |
fail-fast: false | |
matrix: | |
network: | |
- chain_id: test | |
peer: mc://node3.test.mobilecoin.com/ | |
tx_source_url: https://s3-us-west-1.amazonaws.com/mobilecoin.chain/node3.test.mobilecoin.com/ | |
- chain_id: main | |
peer: mc://node3.prod.mobilecoinww.com/ | |
tx_source_url: https://ledger.mobilecoinww.com/node3.prod.mobilecoinww.com/ | |
env: | |
DOWNLOAD_DIR: ./tmp | |
steps: | |
- name: Checkout | |
uses: mobilecoinofficial/gh-actions/checkout@v0 | |
- name: Download latest linux release | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
mkdir -p "${DOWNLOAD_DIR}" | |
gh release download \ | |
-p '*-Linux-X64-${{ matrix.network.chain_id }}net.tar.gz' \ | |
-O "${DOWNLOAD_DIR}/linux.tar.gz" | |
- name: Unpack full-service | |
run: | | |
cd "${DOWNLOAD_DIR}" | |
tar --skip-old-files --strip-components=1 --show-stored-names -xvzf linux.tar.gz | |
- name: Install libdbus and libusb dependencies | |
run: | | |
apt-get update | |
apt-get install -y libdbus-1-3 libusb-1.0-0 | |
- name: Run full-service - wait for ledger sync | |
shell: bash | |
env: | |
MC_LEDGER_DB: ./ledger | |
MC_WALLET_DB: ./wallet/wallet.db | |
MC_FOG_INGEST_ENCLAVE_CSS: ./ingest-enclave.css | |
MC_CHAIN_ID: ${{ matrix.network.chain_id }} | |
MC_PEER: ${{ matrix.network.peer }} | |
MC_TX_SOURCE_URL: ${{ matrix.network.tx_source_url }} | |
RUST_LOG: error | |
run: | | |
set -e | |
pushd "${DOWNLOAD_DIR}" | |
mkdir -p "${MC_LEDGER_DB}" | |
mkdir -p "$(dirname "${MC_WALLET_DB}")" | |
# Download existing ledger db | |
curl -sSfL "https://mcdeveu1ledger.blob.core.windows.net/${MC_CHAIN_ID}/data.mdb" -o "${MC_LEDGER_DB}/data.mdb" | |
# Start full-service | |
./full-service & | |
# Capture pid | |
pid=${!} | |
echo "${pid}" | |
echo "wait for full-service to sync all the blocks" | |
../.internal-ci/util/wait-for-full-service.sh | |
echo "ledger is in sync, stop full-service" | |
kill "${pid}" | |
echo "wait for full-service to fully stop" | |
wait "${pid}" | |
echo "full-service shutdown successfully" | |
- name: copy ledger data.mdb to Azure Blob Storage - westeurope | |
env: | |
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.LEDGER_DB_WESTEUROPE_AZURE_STORAGE_CONNECTION_STRING }} | |
run: | | |
cd "${DOWNLOAD_DIR}/ledger" | |
az storage blob upload -f ./data.mdb -c ${{ matrix.network.chain_id }} -n data.mdb --overwrite | |
- name: copy ledger data.mdb to Azure Blob Storage - centralus | |
env: | |
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.LEDGER_DB_CENTRALUS_AZURE_STORAGE_CONNECTION_STRING }} | |
run: | | |
cd "${DOWNLOAD_DIR}/ledger" | |
az storage blob upload -f ./data.mdb -c ${{ matrix.network.chain_id }} -n data.mdb --overwrite |