-
Notifications
You must be signed in to change notification settings - Fork 155
155 lines (134 loc) · 7.91 KB
/
refresh-ledger-bootstrap.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Copyright (c) 2018-2023 The MobileCoin Foundation
#
# Daily job to refresh ledger db files
name: Refresh ledger bootstrap
on:
schedule:
- cron: '0 0 * * *'
# Start mobilecoind
# Monitor mobilecoind until ledger has finished syncing
# Stop mobilecoind
# Copy ledger/watcher to azure blob
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: write
jobs:
refresh-ledger:
runs-on: mcf-dev-large-x64
container:
image: mobilecoin/gha-azure-helper:latest
strategy:
fail-fast: false
matrix:
network:
- chain_id: test
min_signatures: "5"
block_info_url: https://node1.test.mobilecoin.com:443/gw/consensus_common.BlockchainAPI/GetLastBlockInfo
peers: mc://node1.test.mobilecoin.com:443/,mc://node2.test.mobilecoin.com:443/,mc://node3.test.mobilecoin.com/,mc://node1.consensus.mob.staging.namda.net:443/,mc://node2.consensus.mob.staging.namda.net:443/
quorum_set: |-
{ "threshold": 3, "members": [{"args":"node1.test.mobilecoin.com:443","type":"Node"},{"args":"node2.test.mobilecoin.com:443","type":"Node"},{"args":"node3.test.mobilecoin.com:443","type":"Node"},{"args":"node1.consensus.mob.staging.namda.net:443","type":"Node"},{"args":"node2.consensus.mob.staging.namda.net:443","type":"Node"}] }
tx_source_urls: https://s3-us-west-1.amazonaws.com/mobilecoin.chain/node1.test.mobilecoin.com/,https://s3-us-west-1.amazonaws.com/mobilecoin.chain/node2.test.mobilecoin.com/,https://s3-us-west-1.amazonaws.com/mobilecoin.chain/node3.test.mobilecoin.com/,https://s3-eu-central-1.amazonaws.com/staging-namda-payments-ledger/node1.consensus.mob.staging.namda.net/,https://s3-eu-central-1.amazonaws.com/staging-namda-payments-ledger/node2.consensus.mob.staging.namda.net/
- chain_id: main
min_signatures: "10"
block_info_url: https://node1.prod.mobilecoinww.com:443/gw/consensus_common.BlockchainAPI/GetLastBlockInfo
peers: mc://node1.prod.mobilecoinww.com:443/,mc://node2.prod.mobilecoinww.com:443/,mc://node3.prod.mobilecoinww.com/,mc://node1.consensus.mob.production.namda.net:443/,mc://node2.consensus.mob.production.namda.net:443/,mc://blockdaemon.mobilecoin.bdnodes.net:443/,mc://binance.mobilecoin.bdnodes.net:443/,mc://ideasbeyondborders.mobilecoin.bdnodes.net:443/,mc://ignite.mobilecoin.bdnodes.net:443/,mc://ams1-mc-node1.dreamhost.com:3223/
quorum_set: |
{ "threshold": 7, "members": [{"args":"node1.prod.mobilecoinww.com:443","type":"Node"},{"args":"node2.prod.mobilecoinww.com:443","type":"Node"},{"args":"node3.prod.mobilecoinww.com:443","type":"Node"},{"args":"node1.consensus.mob.production.namda.net:443","type":"Node"},{"args":"node2.consensus.mob.production.namda.net:443","type":"Node"},{"args":"blockdaemon.mobilecoin.bdnodes.net:443","type":"Node"},{"args":"binance.mobilecoin.bdnodes.net:443","type":"Node"},{"args":"ideasbeyondborders.mobilecoin.bdnodes.net:443","type":"Node"},{"args":"ignite.mobilecoin.bdnodes.net:443","type":"Node"},{"args":"ams1-mc-node1.dreamhost.com:3223","type":"Node"}] }
tx_source_urls: https://ledger.mobilecoinww.com/node1.prod.mobilecoinww.com/,https://ledger.mobilecoinww.com/node2.prod.mobilecoinww.com/,https://ledger.mobilecoinww.com/node3.prod.mobilecoinww.com/,https://s3-eu-central-1.amazonaws.com/production-namda-payments-ledger/node1.consensus.mob.production.namda.net/,https://s3-eu-central-1.amazonaws.com/production-namda-payments-ledger/node2.consensus.mob.production.namda.net/,https://bd-mobilecoin-ledger.s3.amazonaws.com/blockdaemon.mobilecoin.bdnodes.net/,https://bd-mobilecoin-ledger.s3.amazonaws.com/binance.mobilecoin.bdnodes.net/,https://bd-mobilecoin-ledger.s3.amazonaws.com/ideasbeyondborders.mobilecoin.bdnodes.net/,https://bd-mobilecoin-ledger.s3.amazonaws.com/ignite.mobilecoin.bdnodes.net/,https://s3-eu-west-1.amazonaws.com/dh-mobilecoin-eu/ams1-mc-node1.dreamhost.com/
env:
DOWNLOAD_DIR: ${{ github.workspace }}/.tmp
MC_LEDGER_DB: ${{ github.workspace }}/.tmp/ledger
MC_WATCHER_DB: ${{ github.workspace }}/.tmp/watcher
MC_MOBILECOIND_DB: ${{ github.workspace }}/.tmp/mobilecoind_db
steps:
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Download latest linux release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
mkdir -p "${DOWNLOAD_DIR}"
gh release download v6.0.1 \
-p '${{ matrix.network.chain_id }}net-mobilecoind-linux-x86_64-*.tar.gz' \
-O "${DOWNLOAD_DIR}/linux.tar.gz"
- name: Unpack mobilecoind
run: |
cd "${DOWNLOAD_DIR}"
tar --skip-old-files -xvzf linux.tar.gz
- name: Download current watcher and ledger databases
shell: bash
run: |
cd "${DOWNLOAD_DIR}"
# Download the current ledger db
echo "Downloading ledger database..."
export AZURE_STORAGE_CONNECTION_STRING='${{ secrets.MC_LEDGER_DB_AZURE_STORAGE_CONNECTION_STRING }}'
if az storage blob download -f ./ledger-data.mdb -c ${{ matrix.network.chain_id }} -n mcd/ledger/data.mdb --overwrite
then
ls -l ./ledger-data.mdb
md5sum ./ledger-data.mdb
mkdir -p "${MC_LEDGER_DB}"
mv ./ledger-data.mdb "${MC_LEDGER_DB}/data.mdb"
fi
# Download the current watcher db
echo "Downloading watcher database..."
if az storage blob download -f ./watcher-data.mdb -c ${{ matrix.network.chain_id }} -n mcd/watcher/data.mdb --overwrite
then
ls -l ./watcher-data.mdb
md5sum ./watcher-data.mdb
mkdir -p "${MC_WATCHER_DB}"
mv ./watcher-data.mdb "${MC_WATCHER_DB}/data.mdb"
fi
- name: Run mobilecoind mobilecoind-json - wait for ledger sync
shell: bash
env:
MC_FOG_INGEST_ENCLAVE_CSS: ./ingest-enclave.css
MC_CHAIN_ID: ${{ matrix.network.chain_id }}
MC_PEER: ${{ matrix.network.peers }}
MC_TX_SOURCE_URL: ${{ matrix.network.tx_source_urls }}
MC_QUORUM_SET: ${{ matrix.network.quorum_set }}
MC_POLL_INTERVAL: "1"
MC_LISTEN_URI: insecure-mobilecoind://127.0.0.1:3229/
MC_IP_INFO_TOKEN: ${{ secrets.IP_INFO_TOKEN }}
MC_MOBILECOIND_URI: insecure-mobilecoind://127.0.0.1:3229/
BLOCK_INFO_URL: ${{ matrix.network.block_info_url }}
MIN_SIGNATURES: ${{ matrix.network.min_signatures }}
RUST_LOG: error
run: |
set -e
pushd "${DOWNLOAD_DIR}/mobilecoind-linux/bin"
# Start mobilecoind
./mobilecoind &
# Capture pid
mc_pid=${!}
echo "${mc_pid}"
# Start mobilecoind-json
./mobilecoind-json --listen-host 127.0.0.1 --listen-port 9090 &
# Capture pid
mcj_pid=${!}
echo "${mcj_pid}"
echo "wait for mobilecoind to sync all the blocks"
"${GITHUB_WORKSPACE}/.internal-ci/util/wait-for-mobilecoind.sh"
echo "ledger is in sync, stop mobilecoind"
kill ${mcj_pid}
kill ${mc_pid}
md5sum "${MC_LEDGER_DB}/data.mdb"
md5sum "${MC_WATCHER_DB}/data.mdb"
echo "mobilecoind shutdown successfully"
- name: copy ledger/watcher data.mdb to Azure Blob Storage
shell: bash
run: |
# Sync to MC
pushd "${MC_LEDGER_DB}"
export AZURE_STORAGE_CONNECTION_STRING='${{ secrets.MC_LEDGER_DB_AZURE_STORAGE_CONNECTION_STRING }}'
az storage blob upload -f ./data.mdb -c ${{ matrix.network.chain_id }} -n mcd/ledger/data.mdb --overwrite
pushd "${MC_WATCHER_DB}"
az storage blob upload -f ./data.mdb -c ${{ matrix.network.chain_id }} -n mcd/watcher/data.mdb --overwrite
- name: Send failure notification
if: failure()
uses: slackapi/[email protected]
with:
payload: '{"text": "Github Actions Job - Refresh ledger bootstrap failed for ${{ matrix.network.chain_id }}"}'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_OPS_MONITORING }}