-
Notifications
You must be signed in to change notification settings - Fork 5
372 lines (318 loc) · 12.4 KB
/
create-geth-arb-network.yml
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
name: Create Geth and ARB Initial State
run-name: Creating Geth and ARB init state for ${{ inputs.tag }}-${{ inputs.genesis_validators }}-node${{ inputs.docker_image_tag_suffix }}
on:
workflow_dispatch:
inputs:
tag:
description: Which tag should we deploy against?
required: true
genesis_validators:
description: The aggregate key generated from generate-genesis-keys
type: choice
options:
- "1"
- "3"
chainflip_backend_ref:
description: The branch, tag or commit of chainflip-backend to use
required: true
default: "main"
nitro_testnodes_ref:
description: The branch, tag or commit of nitro-testnodes to use
required: true
default: "feat/setup-from-scratch"
docker_image_tag_suffix:
description: A suffix to append to the image tag
required: false
default: ""
env:
SEED: test test test test test test test test test test test junk
NUM_GENESIS_VALIDATORS: ${{ inputs.genesis_validators }}
GOV_KEY: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
COMM_KEY: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
REDEMPTION_DELAY: "120"
GENESIS_STAKE: "1000000000000000000000"
DEPLOYER_ACCOUNT_INDEX: "0"
DEPLOY_ARTEFACT_ID: "docker"
IMAGE_TAG: ${{ inputs.tag }}-${{ inputs.genesis_validators }}-node${{ inputs.docker_image_tag_suffix }}
jobs:
build-geth-base:
runs-on: [self-hosted, linux, x64, ephemeral]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}/geth-base
flavor: |
latest=true
tags: |
type=semver,pattern={{raw}}
type=raw,value=latest
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ci/docker/arb-geth/
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-geth-state:
runs-on: [self-hosted, linux, x64, ephemeral]
outputs:
image-tag: ${{ env.IMAGE_TAG }}
needs:
- build-geth-base
services:
geth:
image: ghcr.io/${{ github.repository }}/geth-base:latest
ports:
- 8545:8545
- 8546:8546
- 8551:8551
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.tag }}
- name: Checkout chainflip-backend @ ${{ inputs.chainflip_backend_ref }}
uses: actions/checkout@v3
with:
token: ${{ secrets.CF_GITHUB_BOT_READONLY_BACKEND_REPO }}
repository: chainflip-io/chainflip-backend
path: chainflip-backend
ref: ${{ inputs.chainflip_backend_ref }}
- name: Fetch agg_key
run: |
echo "AGG_KEY=$(jq -r .eth_agg_key chainflip-backend/localnet/init/keyshare/${{ inputs.genesis_validators }}-node/agg_keys.json)" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Python virtualenv
run: pip install virtualenv
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Install Poetry
uses: snok/install-poetry@v1
- run: npm install --global ganache-cli
- run: npm install --global yarn
- run: yarn
- run: poetry install
- name: Add the network
run: poetry run brownie networks add Ethereum docker host=http://localhost:8545 chainid=10997
- name: Deploy contracts
run: poetry run brownie run deploy_contracts --network docker
- name: Commit and push new geth image
run: |
CONTAINER=$(docker ps --format '{{.Names}}' | grep geth)
echo "geth_container=$CONTAINER" >> $GITHUB_ENV
docker commit $CONTAINER ghcr.io/chainflip-io/chainflip-eth-contracts/geth:${{ env.IMAGE_TAG }}
docker push ghcr.io/chainflip-io/chainflip-eth-contracts/geth:${{ env.IMAGE_TAG }}
- name: Copy initial Geth state
run: |
docker cp ${{ env.geth_container }}:/datadir ${{ github.workspace }}/datadir
- name: Summary
run: |
CONTRACTS=$(jq . ./scripts/.artefacts/docker.json)
echo "## Deployed Contracts for \`${{ inputs.genesis_validators }}-node\`" >> $GITHUB_STEP_SUMMARY
echo "\`agg_key\` = \`${{ env.AGG_KEY }}\`" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
echo "$CONTRACTS" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "## Docker Image" >> $GITHUB_STEP_SUMMARY
echo "\`ghcr.io/chainflip-io/chainflip-eth-contracts/geth:${{ env.IMAGE_TAG }}\`" >> $GITHUB_STEP_SUMMARY
- name: Save agg key to file
run: echo ${{ env.AGG_KEY }} > agg_key
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.IMAGE_TAG }}
path: |
agg_key
./scripts/.artefacts/docker.json
${{ github.workspace }}/datadir
build-arb-state:
runs-on: [self-hosted, linux, x64, ephemeral]
env:
GETH_INITIAL_STATE_DIR: ci-geth-initial-state
GETH_BASE_IMAGE: ghcr.io/chainflip-io/chainflip-eth-contracts/geth:${{ inputs.tag }}-${{ inputs.genesis_validators }}-node${{ inputs.docker_image_tag_suffix }}
needs:
- build-geth-state
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout chainflip-io/nitro-testnode @ ${{ inputs.nitro_testnodes_ref }}
uses: actions/checkout@v3
with:
token: ${{ secrets.CF_GITHUB_BOT_READONLY_BACKEND_REPO }}
repository: chainflip-io/nitro-testnode
path: nitro-testnode
ref: ${{ inputs.nitro_testnodes_ref }}
submodules: true
- name: Checkout chainflip-backend @ ${{ inputs.chainflip_backend_ref }}
uses: actions/checkout@v3
with:
token: ${{ secrets.CF_GITHUB_BOT_READONLY_BACKEND_REPO }}
repository: chainflip-io/chainflip-backend
path: chainflip-backend
ref: ${{ inputs.chainflip_backend_ref }}
- name: Fetch agg_key
run: |
echo "AGG_KEY=$(jq -r .eth_agg_key chainflip-backend/localnet/init/keyshare/${{ inputs.genesis_validators }}-node/agg_keys.json)" >> $GITHUB_ENV
- name: Download Geth Initial State
uses: actions/download-artifact@v3
with:
name: ${{ env.IMAGE_TAG }}
path: ./nitro-testnode/${{ env.GETH_INITIAL_STATE_DIR }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Update directory permissions
working-directory: nitro-testnode
run: |
chmod -R 777 ./${{ env.GETH_INITIAL_STATE_DIR }}
- name: Update Docker user
run: |
sudo usermod -aG docker $USER
newgrp docker
- name: Build Arbitrum Network
working-directory: nitro-testnode
run: |
mkdir -p ./data
chmod -R 777 ./data
./test-node.bash --init --detach
./test-node.bash script send-l2 --to address_0x076d3803349fd5FB48863c5Fc33483cB2243C0Df --ethamount 10000
./test-node.bash script send-l2 --to address_0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --ethamount 10000
- name: Install Python virtualenv
run: pip install virtualenv
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Install Poetry
uses: snok/install-poetry@v1
- run: npm install --global ganache-cli
- run: npm install --global yarn
- run: yarn
- run: poetry install
- name: Add the network
run: poetry run brownie networks add Ethereum arb-l2 host=http://localhost:8547 chainid=412346
- name: Deploy contracts
run: poetry run brownie run deploy_contracts --network arb-l2
- name: Stop Containers
run: |
# Stop ARB containers in order to preserve a clean state
docker stop nitro-testnode-poster-1
docker stop nitro-testnode-staker-unsafe-1
docker stop nitro-testnode-sequencer-1
docker stop nitro-testnode-redis-1
docker stop nitro-testnode-geth-1
# Stop any other containers that may be running
docker stop $(docker ps -a -q)
- name: Summary
run: |
CONTRACTS=$(jq . ./scripts/.artefacts/docker.json)
echo "## Deployed L2 Contracts for \`${{ inputs.genesis_validators }}-node\`" >> $GITHUB_STEP_SUMMARY
echo "\`agg_key\` = \`${{ env.AGG_KEY }}\`" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
echo "$CONTRACTS" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "## Docker Image" >> $GITHUB_STEP_SUMMARY
echo "\`ghcr.io/chainflip-io/chainflip-eth-contracts/geth:${{ env.IMAGE_TAG }}\`" >> $GITHUB_STEP_SUMMARY
- name: Save agg key to file
run: echo ${{ env.AGG_KEY }} > agg_key
- name: Update permissions
run: |
sudo chown -R $USER:$USER ./nitro-testnode/data
sudo chmod -R 777 ./nitro-testnode/data
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.IMAGE_TAG }}-localnet-initial-state
path: |
${{ github.workspace }}/nitro-testnode/data
- name: Clean Up docker containers 🧹
if: always()
working-directory: ./nitro-testnode
continue-on-error: true
run: |
ls -laR ./data
docker ps -a
docker compose logs
docker compose down --rmi all --volumes --remove-orphans
build-initial-state-container:
needs:
- build-arb-state
runs-on: [self-hosted, linux, x64, ephemeral]
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU ⚙️
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx 👷
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Docker meta 🔖
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}/localnet-initial-state
tags: ${{ env.IMAGE_TAG }}
- name: Login to GitHub Container Registry ➡️🦑
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download Initial State from previous job
uses: actions/download-artifact@v3
with:
name: ${{ env.IMAGE_TAG }}-localnet-initial-state
path: ./localnet-initial-state
- name: List files
run: ls -laR ./localnet-initial-state
- name: Get Current Time ⌚️
id: get_time
run: echo "current_datetime=$(date -u +"%b %d, %Y at %R UTC")" >> $GITHUB_OUTPUT
- name: Build Initial State Image 🫙
uses: docker/build-push-action@v4
with:
context: .
file: ci/docker/localnet-initial-state.Dockerfile
push: true
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_DATETIME="${{ steps.get_time.outputs.current_datetime }}"
VCS_REF="${{ github.sha }}"
BACKEND_REF="${{ inputs.chainflip_backend_ref }}"