-
Notifications
You must be signed in to change notification settings - Fork 5
457 lines (390 loc) Β· 16.3 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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
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: ""
permissions:
contents: read
packages: write
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"
DEPLOY_RAW_TX_ID: "arbRawDeploymentTxs"
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@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226
- name: Docker meta
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4
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@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
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@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ inputs.tag }}
- name: Checkout chainflip-backend @ ${{ inputs.chainflip_backend_ref }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
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@465a07811f14bebb1938fbed4728c6a1ff8901fc
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@8f152de45cc393bb48ce5d89d36b731f54556e65
with:
node-version: "16"
- name: Install Poetry
uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b
- 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@c7d193f32edcb7bfad88892161225aeda64e9392
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@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Checkout chainflip-io/nitro-testnode @ ${{ inputs.nitro_testnodes_ref }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
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@b4ffde65f46336ab88eb53be808477a3936bae11
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@7a1cd3216ca9260cd8022db641d960b1db4d1be4
with:
name: ${{ env.IMAGE_TAG }}
path: ./nitro-testnode/${{ env.GETH_INITIAL_STATE_DIR }}
- name: Login to GitHub Container Registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
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
./test-node.bash script send-l2 --to address_0x70997970C51812dc3A010C7d01b50e0d17dc79C8 --ethamount 10000
- 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: Update permissions
run: |
sudo chown -R $USER:$USER ./nitro-testnode/data
sudo chmod -R 777 ./nitro-testnode/data
- name: Save Initial State Artifacts
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
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]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up QEMU βοΈ
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3
- name: Set up Docker Buildx π·
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Docker meta π
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4
with:
images: ghcr.io/${{ github.repository }}/localnet-initial-state
tags: ${{ env.IMAGE_TAG }}
- name: Login to GitHub Container Registry β‘οΈπ¦
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download Initial State from previous job
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
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@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
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 }}"
get-l2-contracts-raw-tx:
env:
AGG_KEY: "346529871269487315764593845752985329862751012"
needs:
- build-initial-state-container
runs-on: [self-hosted, linux, x64, ephemeral]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up QEMU βοΈ
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3
- name: Set up Docker Buildx π·
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Docker meta π
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4
with:
images: ghcr.io/${{ github.repository }}/arbitrum-gizmo-shop
tags: ${{ env.IMAGE_TAG }}
- name: Login to GitHub Container Registry β‘οΈπ¦
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Update Docker user π³
run: |
sudo usermod -aG docker $USER
newgrp docker
- name: Start Arb Network π
run: |
docker compose pull > /dev/null 2>&1
docker compose up init -d
docker compose up -d
- name: Install Python virtualenv
run: pip install virtualenv
- name: Setup Node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
with:
node-version: "16"
- name: Install Poetry
uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b
- 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: Get raw deployment transactions
run: poetry run brownie run store_raw_deployment_txs --network arb-l2
- 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: Save ARB Raw Deployment Txs Artifacts
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
with:
name: Arbitrum raw deployment transactions
path: |
./scripts/.artefacts/arbRawDeploymentTxs.json
- name: Get Current Time βοΈ
id: get_time
run: echo "current_datetime=$(date -u +"%b %d, %Y at %R UTC")" >> $GITHUB_OUTPUT
- name: Build Arbitrum Gizmo Shop Image πͺ
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: .
file: ci/docker/arbitrum-gizmo-shop.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 }}"
- name: Clean Up docker containers π§Ή
if: always()
continue-on-error: true
run: |
docker ps -a
docker compose logs
docker compose down --rmi all --volumes --remove-orphans