-
Notifications
You must be signed in to change notification settings - Fork 1
453 lines (389 loc) · 14.2 KB
/
ci.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
name: CI with PostgreSQL
on: push
permissions:
contents: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: rollupsdb
options: --name postgres
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Clone Node V2 (avoid submodules)
run: |
git clone -b feature/new-build --recurse-submodules https://github.com/cartesi/rollups-node.git
- name: Wait for PostgreSQL to be ready
run: |
for i in {1..30}; do
if pg_isready -h localhost -p 5432 -U postgres; then
echo "PostgreSQL is ready";
exit 0;
fi;
sleep 2;
done;
echo "PostgreSQL did not become ready in time";
exit 1;
- name: Migrate Node V2 DB
run: |
cd rollups-node
eval $(make env)
make migrate
- name: Migrate Espresso DB
run: |
eval $(make env)
make migrate
make generate-db
- name: Deps and Cartesi Machine
run: |
export CARTESI_MACHINE_VERSION=0.18.1
sudo apt-get update
sudo apt-get install -y libboost-all-dev lua5.4 libslirp0
wget https://github.com/cartesi/machine-emulator/releases/download/v0.18.1/cartesi-machine-v${CARTESI_MACHINE_VERSION}_amd64.deb
sudo dpkg -i ./cartesi-machine-v${CARTESI_MACHINE_VERSION}_amd64.deb
rm ./cartesi-machine-v${CARTESI_MACHINE_VERSION}_amd64.deb
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Run devnet (Anvil)
run: |
cd rollups-node
make devnet
make run-devnet
- name: Build Espresso image
run: |
docker build -t espresso -f ./ci/Dockerfile .
- name: Dump database
env:
PGPASSWORD: password
run: |
pg_dump -h localhost -U postgres -d rollupsdb > rollupsdb-dump.sql
- name: Save Docker image
run: |
docker save cartesi/rollups-node-devnet:devel -o docker-devnet-image.tar
docker save espresso -o docker-espresso-image.tar
- name: Tar DB bindings
run: |
tar -czf rollupsdb-postgres-bindings.tar.gz internal/repository/postgres/db/
- name: Upload Docker image
uses: actions/upload-artifact@v4
with:
name: my-images
path: docker-*
- name: Upload database dump
uses: actions/upload-artifact@v4
with:
name: db-dump
path: rollupsdb-*
integration_test:
name: Integration tests
runs-on: ubuntu-latest
needs: [build]
services:
postgres:
image: postgres:16
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: rollupsdb
options: --name postgres
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Download DB files
uses: actions/download-artifact@v4
with:
name: db-dump
- name: Restore DB bindings
run: |
mkdir -p internal/repository/postgres/db/
tar -xzf rollupsdb-postgres-bindings.tar.gz
- name: Wait for PostgreSQL to be ready
run: |
for i in {1..30}; do
if pg_isready -h localhost -p 5432 -U postgres; then
echo "PostgreSQL is ready";
exit 0;
fi;
sleep 2;
done;
echo "PostgreSQL did not become ready in time";
exit 1;
- name: Restore database
env:
PGPASSWORD: password
run: |
psql -h localhost -U postgres -d rollupsdb < rollupsdb-dump.sql
- name: Download Docker image
uses: actions/download-artifact@v4
with:
name: my-images
- name: Load Docker image
run: |
docker load -i docker-devnet-image.tar
docker load -i docker-espresso-image.tar
- name: Run devnet (Anvil)
run: |
docker run --rm --name devnet -p 8545:8545 -d cartesi/rollups-node-devnet:devel
- name: Run Espresso image (Default input disabled)
env:
CARTESI_AUTH_MNEMONIC: ${{ secrets.CARTESI_AUTH_MNEMONIC }}
CARTESI_BLOCKCHAIN_HTTP_ENDPOINT: ${{ secrets.CARTESI_BLOCKCHAIN_HTTP_ENDPOINT }}
CARTESI_BLOCKCHAIN_WS_ENDPOINT: ${{ secrets.CARTESI_BLOCKCHAIN_WS_ENDPOINT }}
run: |
docker run -d --env-file ./ci/env.nodev2-sepolia-no-reader \
-e CARTESI_AUTH_MNEMONIC="$CARTESI_AUTH_MNEMONIC" \
-e CARTESI_BLOCKCHAIN_HTTP_ENDPOINT=$CARTESI_BLOCKCHAIN_HTTP_ENDPOINT \
-e CARTESI_BLOCKCHAIN_WS_ENDPOINT=$CARTESI_BLOCKCHAIN_WS_ENDPOINT \
--rm --network=host \
--name c_espresso espresso
- name: Run integration tests
env:
CARTESI_AUTH_MNEMONIC: ${{ secrets.CARTESI_AUTH_MNEMONIC }}
CARTESI_BLOCKCHAIN_HTTP_ENDPOINT: ${{ secrets.CARTESI_BLOCKCHAIN_HTTP_ENDPOINT }}
CARTESI_BLOCKCHAIN_WS_ENDPOINT: ${{ secrets.CARTESI_BLOCKCHAIN_WS_ENDPOINT }}
CARTESI_BLOCKCHAIN_ID: '11155111'
CARTESI_CONTRACTS_INPUT_BOX_ADDRESS: '0x593E5BCf894D6829Dd26D0810DA7F064406aebB6'
CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER: '6850934'
CARTESI_POSTGRES_ENDPOINT: 'postgres://postgres:password@localhost:5432/rollupsdb?sslmode=disable'
ESPRESSO_BASE_URL: 'https://query.decaf.testnet.espresso.network'
ESPRESSO_STARTING_BLOCK: '1490657'
ESPRESSO_NAMESPACE: '55555'
ESPRESSO_SERVICE_ENDPOINT: '0.0.0.0:8080'
run: |
go test --timeout 1m -p 1 ./...
test:
name: e2e tests (EVM Reader)
runs-on: ubuntu-latest
needs: [build]
services:
postgres:
image: postgres:16
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: rollupsdb
options: --name postgres
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Download database dump
uses: actions/download-artifact@v4
with:
name: db-dump
- name: Download Docker image
uses: actions/download-artifact@v4
with:
name: my-images
- name: Load Docker image
run: |
docker load -i docker-devnet-image.tar
docker load -i docker-espresso-image.tar
- name: Run devnet (Anvil)
run: |
docker run --rm --name devnet -p 8545:8545 -d cartesi/rollups-node-devnet:devel
- name: Wait for PostgreSQL to be ready
run: |
for i in {1..30}; do
if pg_isready -h localhost -p 5432 -U postgres; then
echo "PostgreSQL is ready";
exit 0;
fi;
sleep 2;
done;
echo "PostgreSQL did not become ready in time";
exit 1;
- name: Restore database
env:
PGPASSWORD: password
run: |
psql -h localhost -U postgres -d rollupsdb < rollupsdb-dump.sql
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Run Espresso image (pure with EVM reader)
run: |
docker run -d --env-file ./ci/env.nodev2-local \
--rm --network=host \
--name c_espresso espresso
- name: Install Echo App
run: |
docker logs --timestamps c_espresso
docker exec c_espresso cartesi-rollups-cli app deploy -n echo-dapp -t applications/echo-dapp/ -v
- name: Send input transaction
run: |
INPUT=0xdeadbeef; \
INPUT_BOX_ADDRESS=0x593E5BCf894D6829Dd26D0810DA7F064406aebB6; \
APPLICATION_ADDRESS=0x36B9E60ACb181da458aa8870646395CD27cD0E6E; \
cast send \
--mnemonic "test test test test test test test test test test test junk" \
--rpc-url "http://localhost:8545" \
$INPUT_BOX_ADDRESS "addInput(address,bytes)(bytes32)" $APPLICATION_ADDRESS $INPUT
- name: Query Database for Output
run: |
MAX_RETRIES=30
for i in $(seq 1 $MAX_RETRIES); do
RESULT=$(docker exec -i postgres psql -U postgres -d rollupsdb -t -c "SELECT * FROM public.output;")
if [[ "$RESULT" =~ "deadbeef" ]]; then
echo "Result found: $RESULT"
exit 0
fi
echo "Result: $RESULT"
echo "Waiting for result... attempt $i"
sleep 5
done
echo "Timeout reached: result not found"
docker logs --timestamps c_espresso
exit 1
- name: Copy binaries
run: |
docker cp c_espresso:/usr/bin/cartesi-machine .
docker cp c_espresso:/usr/bin/cartesi-machine-stored-hash .
docker cp c_espresso:/usr/bin/cartesi-rollups-advancer .
docker cp c_espresso:/usr/bin/cartesi-rollups-claimer .
docker cp c_espresso:/usr/bin/cartesi-rollups-cli .
docker cp c_espresso:/usr/bin/cartesi-rollups-espresso-reader .
docker cp c_espresso:/usr/bin/cartesi-rollups-evm-reader .
docker cp c_espresso:/usr/bin/cartesi-rollups-node .
docker cp c_espresso:/usr/bin/cartesi-rollups-validator .
ls -la
- name: Upload binaries as artifact
uses: actions/upload-artifact@v4
with:
name: cartesi-binaries
path: cartesi-*
test_espresso:
name: e2e tests (Espresso Reader)
runs-on: ubuntu-latest
needs: [build]
services:
postgres:
image: postgres:16
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: rollupsdb
options: --name postgres
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Download database dump
uses: actions/download-artifact@v4
with:
name: db-dump
- name: Download Docker image
uses: actions/download-artifact@v4
with:
name: my-images
- name: Load Docker image
run: |
docker load -i docker-devnet-image.tar
docker load -i docker-espresso-image.tar
- name: Run devnet (Anvil)
run: |
docker run --rm --name devnet -p 8545:8545 -d cartesi/rollups-node-devnet:devel
- name: Wait for PostgreSQL to be ready
run: |
for i in {1..30}; do
if pg_isready -h localhost -p 5432 -U postgres; then
echo "PostgreSQL is ready";
exit 0;
fi;
sleep 2;
done;
echo "PostgreSQL did not become ready in time";
exit 1;
- name: Restore database
env:
PGPASSWORD: password
run: |
psql -h localhost -U postgres -d rollupsdb < rollupsdb-dump.sql
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Run Espresso image (Default input disabled)
env:
CARTESI_AUTH_MNEMONIC: ${{ secrets.CARTESI_AUTH_MNEMONIC }}
CARTESI_BLOCKCHAIN_HTTP_ENDPOINT: ${{ secrets.CARTESI_BLOCKCHAIN_HTTP_ENDPOINT }}
CARTESI_BLOCKCHAIN_WS_ENDPOINT: ${{ secrets.CARTESI_BLOCKCHAIN_WS_ENDPOINT }}
run: |
export ESPRESSO_STARTING_BLOCK=$(curl -s https://query.decaf.testnet.espresso.network/v0/status/block-height)
docker run -d --env-file ./ci/env.nodev2-sepolia \
-e CARTESI_AUTH_MNEMONIC="$CARTESI_AUTH_MNEMONIC" \
-e ESPRESSO_STARTING_BLOCK=$ESPRESSO_STARTING_BLOCK \
-e CARTESI_BLOCKCHAIN_HTTP_ENDPOINT=$CARTESI_BLOCKCHAIN_HTTP_ENDPOINT \
-e CARTESI_BLOCKCHAIN_WS_ENDPOINT=$CARTESI_BLOCKCHAIN_WS_ENDPOINT --rm --network=host --name c_espresso espresso
- name: Register Echo App
run: |
docker logs --timestamps c_espresso
docker exec c_espresso cartesi-rollups-cli app register -v -c 0x48F176733DBdEc10EC4d1692e98403E0927E869C -a 0x5a205Fcb6947e200615B75C409ac0aa486D77649 -r "$CARTESI_BLOCKCHAIN_HTTP_ENDPOINT" -n echo-dapp -t applications/echo-dapp/
- name: Send input transaction
env:
SENDER_PRIVATE_KEY: ${{ secrets.SENDER_PRIVATE_KEY }}
run: |
git clone --recurse-submodules https://github.com/Calindra/nonodo.git
cd nonodo/eip712-client-js
npm i
APP_ADDRESS=0x5a205Fcb6947e200615B75C409ac0aa486D77649 node index.js
- name: Query Database for Output
run: |
MAX_RETRIES=30
for i in $(seq 1 $MAX_RETRIES); do
RESULT=$(docker exec -i postgres psql -U postgres -d rollupsdb -t -c "SELECT * FROM public.output;")
if [[ "$RESULT" =~ "deadbeef" ]]; then
echo "Result found: $RESULT"
exit 0
fi
echo "Result: $RESULT"
echo "Waiting for result... attempt $i"
sleep 5
done
echo "Timeout reached: result not found"
docker logs --timestamps c_espresso
exit 1
release:
name: Release
runs-on: ubuntu-latest
needs: [test, test_espresso, integration_test]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
# TODO: remove in the future unrelated binaries.
- name: Download binaries artifact
uses: actions/download-artifact@v4
with:
name: cartesi-binaries
- name: Download DB files
uses: actions/download-artifact@v4
with:
name: db-dump
- name: Publish Github release
uses: softprops/action-gh-release@v2
with:
prerelease: true
body_path: CHANGELOG.md
files: |
cartesi-*
rollupsdb-*