-
Notifications
You must be signed in to change notification settings - Fork 55
785 lines (673 loc) · 27.7 KB
/
software-upgrade-test.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
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
name: Test Software Upgrade
on:
pull_request:
push:
branches:
- main
jobs:
retrieve-latest-tag:
runs-on: elys-runner
outputs:
LATEST_TAG: ${{ steps.get-latest-tag.outputs.LATEST_TAG }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Get latest tag
id: get-latest-tag
run: |
git fetch --tags
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_OUTPUT
echo "Latest tag: $LATEST_TAG"
retrieve-snapshot:
runs-on: elys-runner
needs: retrieve-latest-tag
outputs:
SNAPSHOT_DOWNLOAD_URL: ${{ steps.retrieve-info-json.outputs.SNAPSHOT_DOWNLOAD_URL }}
SNAPSHOT_FILE_PATH: ${{ steps.retrieve-info-json.outputs.SNAPSHOT_FILE_PATH }}
steps:
- name: Retrieve info.json and set snapshot path
id: retrieve-info-json
run: |
DOWNLOAD_URL=https://snapshots-testnet.stake-town.com/elys/info.json
curl -L $DOWNLOAD_URL -o /tmp/info.json
echo "Info.json downloaded to check snapshot version."
# retrieve blockHeight field value from info.json
SNAPSHOT_BLOCK_HEIGHT=$(cat /tmp/info.json | awk -F'"' '/"blockHeight":/{print $4}')
echo "SNAPSHOT_BLOCK_HEIGHT=$SNAPSHOT_BLOCK_HEIGHT" >> $GITHUB_ENV
echo "Snapshot block height: $SNAPSHOT_BLOCK_HEIGHT"
# set snapshot download url
SNAPSHOT_DOWNLOAD_URL=https://snapshots-testnet.stake-town.com/elys/elystestnet-1_latest.tar.lz4
echo "SNAPSHOT_DOWNLOAD_URL=$SNAPSHOT_DOWNLOAD_URL" >> $GITHUB_ENV
echo "SNAPSHOT_DOWNLOAD_URL=$SNAPSHOT_DOWNLOAD_URL" >> $GITHUB_OUTPUT
# set snapshot file path
SNAPSHOT_FILE_PATH=/tmp/snapshot.tar.lz4
echo "SNAPSHOT_FILE_PATH=$SNAPSHOT_FILE_PATH" >> $GITHUB_ENV
echo "SNAPSHOT_FILE_PATH=$SNAPSHOT_FILE_PATH" >> $GITHUB_OUTPUT
- name: Cache Snapshot
uses: actions/cache@v4
id: cache-snapshot
with:
path: |
${{ env.SNAPSHOT_FILE_PATH }}
key: ${{ runner.os }}-snapshot-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
lookup-only: true
- name: Download snapshot
run: |
curl -L $SNAPSHOT_DOWNLOAD_URL -o $SNAPSHOT_FILE_PATH
if: steps.cache-snapshot.outputs.cache-hit != 'true'
retrieve-old-binary:
runs-on: elys-runner
needs: retrieve-latest-tag
outputs:
OLD_BINARY_PATH: ${{ steps.set-old-binary-path.outputs.OLD_BINARY_PATH }}
steps:
- name: Set old binary path
id: set-old-binary-path
run: |
OLD_BINARY_PATH=/tmp/elysd-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
echo "OLD_BINARY_PATH=$OLD_BINARY_PATH" >> $GITHUB_ENV
echo "OLD_BINARY_PATH=$OLD_BINARY_PATH" >> $GITHUB_OUTPUT
- name: Cache old binary
uses: actions/cache@v4
id: cache-old-binary
with:
path: |
${{ env.OLD_BINARY_PATH }}
key: ${{ runner.os }}-retrieve-old-binary-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
lookup-only: true
- name: Retrieve latest binary
run: |
DOWNLOAD_URL=https://github.com/elys-network/elys/releases/download/${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}/elysd-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}-linux-amd64
curl -L $DOWNLOAD_URL -o $OLD_BINARY_PATH && chmod +x $OLD_BINARY_PATH
# TODO: retrieve upgrade-assure and upload-snapshot binaries
if: steps.cache-old-binary.outputs.cache-hit != 'true'
build-new-binary:
runs-on: elys-runner
outputs:
NEW_BINARY_PATH: ${{ steps.set-new-binary-paths.outputs.NEW_BINARY_PATH }}
NEW_UPGRADE_ASSURE_BINARY_PATH: ${{ steps.set-new-binary-paths.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH }}
UPLOAD_SNAPSHOT_BINARY_PATH: ${{ steps.set-new-binary-paths.outputs.UPLOAD_SNAPSHOT_BINARY_PATH }}
CACHE_KEY: ${{ steps.set-new-binary-paths.outputs.CACHE_KEY }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set new binary paths
id: set-new-binary-paths
run: |
NEW_BINARY_PATH=./build/elysd
echo "NEW_BINARY_PATH=$NEW_BINARY_PATH" >> $GITHUB_ENV
echo "NEW_BINARY_PATH=$NEW_BINARY_PATH" >> $GITHUB_OUTPUT
NEW_UPGRADE_ASSURE_BINARY_PATH=./build/new-upgrade-assure
echo "NEW_UPGRADE_ASSURE_BINARY_PATH=$NEW_UPGRADE_ASSURE_BINARY_PATH" >> $GITHUB_ENV
echo "NEW_UPGRADE_ASSURE_BINARY_PATH=$NEW_UPGRADE_ASSURE_BINARY_PATH" >> $GITHUB_OUTPUT
UPLOAD_SNAPSHOT_BINARY_PATH=./build/upload-snapshot
echo "UPLOAD_SNAPSHOT_BINARY_PATH=$UPLOAD_SNAPSHOT_BINARY_PATH" >> $GITHUB_ENV
echo "UPLOAD_SNAPSHOT_BINARY_PATH=$UPLOAD_SNAPSHOT_BINARY_PATH" >> $GITHUB_OUTPUT
CACHE_KEY=${{ runner.os }}-build-new-binary-${{ hashFiles('**/go.mod', '**/*.go') }}
echo "CACHE_KEY=$CACHE_KEY" >> $GITHUB_ENV
echo "CACHE_KEY=$CACHE_KEY" >> $GITHUB_OUTPUT
- name: Cache new binary
uses: actions/cache@v4
id: cache-new-binary
with:
path: |
${{ env.NEW_BINARY_PATH }}
${{ env.NEW_UPGRADE_ASSURE_BINARY_PATH}}
${{ env.UPLOAD_SNAPSHOT_BINARY_PATH }}
key: ${{ env.CACHE_KEY }}
lookup-only: true
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
if: steps.cache-new-binary.outputs.cache-hit != 'true'
- name: Create git tag
run: git tag v999.999.999
if: steps.cache-new-binary.outputs.cache-hit != 'true'
- name: Build new binaries
id: build-new-binaries
run: |
# build new elys binary
make build
# build new upgrade assure binary
make build-upgrade-assure
mv ./build/upgrade-assure $NEW_UPGRADE_ASSURE_BINARY_PATH
# build upload snapshot binary
make build-upload-snapshot
if: steps.cache-new-binary.outputs.cache-hit != 'true'
build-old-binary:
runs-on: elys-runner
needs: retrieve-latest-tag
outputs:
OLD_UPGRADE_ASSURE_BINARY_PATH: ${{ steps.set-old-binary-path.outputs.OLD_UPGRADE_ASSURE_BINARY_PATH }}
steps:
- name: Set old binary path
id: set-old-binary-path
run: |
OLD_UPGRADE_ASSURE_BINARY_PATH=./build/old-upgrade-assure
echo "OLD_UPGRADE_ASSURE_BINARY_PATH=$OLD_UPGRADE_ASSURE_BINARY_PATH" >> $GITHUB_ENV
echo "OLD_UPGRADE_ASSURE_BINARY_PATH=$OLD_UPGRADE_ASSURE_BINARY_PATH" >> $GITHUB_OUTPUT
- name: Cache old binaries
uses: actions/cache@v4
id: cache-old-binaries
with:
path: |
${{ env.OLD_UPGRADE_ASSURE_BINARY_PATH }}
key: ${{ runner.os }}-build-old-binary-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
lookup-only: true
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
if: steps.cache-old-binaries.outputs.cache-hit != 'true'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
if: steps.cache-old-binaries.outputs.cache-hit != 'true'
# TODO: to remove when upgrade-assure binary is available in previous release
- name: Copy upgrade assure folder
run: |
cp -a ./cmd/upgrade-assure ./cmd/upgrade-assure-skip
if: steps.cache-old-binaries.outputs.cache-hit != 'true'
- name: Check out latest tag
run: git checkout ${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-old-binaries.outputs.cache-hit != 'true'
# TODO: to remove when upgrade-assure binary is available in previous release
- name: Copy old upgrade assure types.go file
run: |
cp -a ./scripts/upgrade-assure/types.go ./cmd/upgrade-assure-skip/types.go
if: steps.cache-old-binaries.outputs.cache-hit != 'true'
# TODO: to remove when upgrade-assure binary is available in previous release
- name: Build old binaries
id: build-old-binaries
run: |
# build old upgrade assure binary
mkdir -p build
go build -o build ./cmd/upgrade-assure-skip
mv ./build/upgrade-assure-skip $OLD_UPGRADE_ASSURE_BINARY_PATH
if: steps.cache-old-binaries.outputs.cache-hit != 'true'
chain-snapshot-and-export:
runs-on: elys-runner
needs:
[
retrieve-latest-tag,
retrieve-snapshot,
retrieve-old-binary,
build-new-binary,
build-old-binary,
]
steps:
- name: Cache Directories
uses: actions/cache@v4
id: cache-chain-snapshot-and-export
with:
path: |
/home/runner/.elys
/home/runner/.elys2
/tmp/genesis.json
key: ${{ runner.os }}-chain-snapshot-and-export-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
lookup-only: true
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
if: steps.cache-chain-snapshot-and-export.outputs.cache-hit != 'true'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
if: steps.cache-chain-snapshot-and-export.outputs.cache-hit != 'true'
- name: Check out latest tag
run: git checkout ${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-chain-snapshot-and-export.outputs.cache-hit != 'true'
- name: Restore snapshot from cache
uses: actions/cache/restore@v4
with:
path: |
${{ needs.retrieve-snapshot.outputs.SNAPSHOT_FILE_PATH }}
key: ${{ runner.os }}-snapshot-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-chain-snapshot-and-export.outputs.cache-hit != 'true'
- name: Restore new binary from cache
uses: actions/cache@v4
with:
path: |
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }}
${{ needs.build-new-binary.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH}}
${{ needs.build-new-binary.outputs.UPLOAD_SNAPSHOT_BINARY_PATH }}
key: ${{ needs.build-new-binary.outputs.CACHE_KEY }}
if: steps.cache-chain-snapshot-and-export.outputs.cache-hit != 'true'
- name: Restore old binaries from cache
uses: actions/cache@v4
with:
path: |
${{ needs.build-old-binary.outputs.OLD_UPGRADE_ASSURE_BINARY_PATH }}
key: ${{ runner.os }}-build-old-binary-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-chain-snapshot-and-export.outputs.cache-hit != 'true'
- name: Restore old binary from cache
uses: actions/cache@v4
with:
path: |
${{ needs.retrieve-old-binary.outputs.OLD_BINARY_PATH }}
key: ${{ runner.os }}-retrieve-old-binary-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-chain-snapshot-and-export.outputs.cache-hit != 'true'
- name: Chain snapshot and export
run: |
GOMEMLIMIT=32GiB \
${{ needs.build-old-binary.outputs.OLD_UPGRADE_ASSURE_BINARY_PATH }} \
${{ needs.retrieve-snapshot.outputs.SNAPSHOT_FILE_PATH }} \
${{ needs.retrieve-old-binary.outputs.OLD_BINARY_PATH }} \
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }} \
--skip-chain-init \
--skip-node-start \
--timeout-next-block 100000 \
--timeout-wait-for-node 100000
if: steps.cache-chain-snapshot-and-export.outputs.cache-hit != 'true'
chain-init:
runs-on: elys-runner
needs:
[
retrieve-latest-tag,
retrieve-snapshot,
retrieve-old-binary,
build-new-binary,
build-old-binary,
chain-snapshot-and-export,
]
steps:
- name: Cache Directories
uses: actions/cache@v4
id: cache-chain-init
with:
path: |
/home/runner/.elys
/home/runner/.elys2
key: ${{ runner.os }}-chain-init-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
lookup-only: true
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
if: steps.cache-chain-init.outputs.cache-hit != 'true'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
if: steps.cache-chain-init.outputs.cache-hit != 'true'
- name: Check out latest tag
run: git checkout ${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-chain-init.outputs.cache-hit != 'true'
- name: Restore chain snapshot and export from cache
uses: actions/cache/restore@v4
with:
path: |
/home/runner/.elys
/home/runner/.elys2
/tmp/genesis.json
key: ${{ runner.os }}-chain-snapshot-and-export-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-chain-init.outputs.cache-hit != 'true'
- name: Restore new binary from cache
uses: actions/cache@v4
with:
path: |
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }}
${{ needs.build-new-binary.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH}}
${{ needs.build-new-binary.outputs.UPLOAD_SNAPSHOT_BINARY_PATH }}
key: ${{ needs.build-new-binary.outputs.CACHE_KEY }}
if: steps.cache-chain-init.outputs.cache-hit != 'true'
- name: Restore old binaries from cache
uses: actions/cache@v4
with:
path: |
${{ needs.build-old-binary.outputs.OLD_UPGRADE_ASSURE_BINARY_PATH }}
key: ${{ runner.os }}-build-old-binary-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-chain-init.outputs.cache-hit != 'true'
- name: Restore old binary from cache
uses: actions/cache@v4
with:
path: |
${{ needs.retrieve-old-binary.outputs.OLD_BINARY_PATH }}
key: ${{ runner.os }}-retrieve-old-binary-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-chain-init.outputs.cache-hit != 'true'
- name: Chain initialization
run: |
GOMEMLIMIT=32GiB \
${{ needs.build-old-binary.outputs.OLD_UPGRADE_ASSURE_BINARY_PATH }} \
${{ needs.retrieve-snapshot.outputs.SNAPSHOT_FILE_PATH }} \
${{ needs.retrieve-old-binary.outputs.OLD_BINARY_PATH }} \
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }} \
--skip-snapshot \
--skip-node-start \
--timeout-next-block 100000 \
--timeout-wait-for-node 100000
if: steps.cache-chain-init.outputs.cache-hit != 'true'
create-second-validator:
runs-on: elys-runner
needs:
[
retrieve-latest-tag,
retrieve-snapshot,
retrieve-old-binary,
build-new-binary,
chain-init,
]
steps:
- name: Cache Directories
uses: actions/cache@v4
id: cache-create-second-validator
with:
path: |
/home/runner/.elys
/home/runner/.elys2
key: ${{ runner.os }}-create-second-validator-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
lookup-only: true
- name: Restore chain snapshot and export from cache
uses: actions/cache/restore@v4
with:
path: |
/home/runner/.elys
/home/runner/.elys2
key: ${{ runner.os }}-chain-init-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-create-second-validator.outputs.cache-hit != 'true'
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
if: steps.cache-create-second-validator.outputs.cache-hit != 'true'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
if: steps.cache-create-second-validator.outputs.cache-hit != 'true'
- name: Restore new binary from cache
uses: actions/cache@v4
with:
path: |
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }}
${{ needs.build-new-binary.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH}}
${{ needs.build-new-binary.outputs.UPLOAD_SNAPSHOT_BINARY_PATH }}
key: ${{ needs.build-new-binary.outputs.CACHE_KEY }}
if: steps.cache-create-second-validator.outputs.cache-hit != 'true'
- name: Restore old binary from cache
uses: actions/cache@v4
with:
path: |
${{ needs.retrieve-old-binary.outputs.OLD_BINARY_PATH }}
key: ${{ runner.os }}-retrieve-old-binary-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-create-second-validator.outputs.cache-hit != 'true'
- name: Create second validator
run: |
GOMEMLIMIT=32GiB \
${{ needs.build-new-binary.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH }} \
${{ needs.retrieve-snapshot.outputs.SNAPSHOT_FILE_PATH }} \
${{ needs.retrieve-old-binary.outputs.OLD_BINARY_PATH }} \
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }} \
--skip-snapshot \
--skip-chain-init \
--skip-prepare-validator-data \
--skip-submit-proposal \
--skip-upgrade-to-new-binary \
--timeout-next-block 100000 \
--timeout-wait-for-node 100000
if: steps.cache-create-second-validator.outputs.cache-hit != 'true'
prepare-validator-data:
runs-on: elys-runner
needs:
[
retrieve-latest-tag,
retrieve-snapshot,
retrieve-old-binary,
build-new-binary,
create-second-validator,
]
steps:
- name: Cache Directories
uses: actions/cache@v4
id: cache-prepare-validator-data
with:
path: |
/home/runner/.elys
/home/runner/.elys2
key: ${{ runner.os }}-prepare-validator-data-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
lookup-only: true
- name: Restore create second validator from cache
uses: actions/cache/restore@v4
with:
path: |
/home/runner/.elys
/home/runner/.elys2
key: ${{ runner.os }}-create-second-validator-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-prepare-validator-data.outputs.cache-hit != 'true'
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
if: steps.cache-prepare-validator-data.outputs.cache-hit != 'true'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
if: steps.cache-prepare-validator-data.outputs.cache-hit != 'true'
- name: Restore new binary from cache
uses: actions/cache@v4
with:
path: |
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }}
${{ needs.build-new-binary.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH}}
${{ needs.build-new-binary.outputs.UPLOAD_SNAPSHOT_BINARY_PATH }}
key: ${{ needs.build-new-binary.outputs.CACHE_KEY }}
if: steps.cache-prepare-validator-data.outputs.cache-hit != 'true'
- name: Restore old binary from cache
uses: actions/cache@v4
with:
path: |
${{ needs.retrieve-old-binary.outputs.OLD_BINARY_PATH }}
key: ${{ runner.os }}-retrieve-old-binary-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-prepare-validator-data.outputs.cache-hit != 'true'
- name: Prepare validator data
run: |
GOMEMLIMIT=32GiB \
${{ needs.build-new-binary.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH }} \
${{ needs.retrieve-snapshot.outputs.SNAPSHOT_FILE_PATH }} \
${{ needs.retrieve-old-binary.outputs.OLD_BINARY_PATH }} \
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }} \
--skip-snapshot \
--skip-chain-init \
--skip-create-validator \
--skip-submit-proposal \
--skip-upgrade-to-new-binary \
--timeout-next-block 100000 \
--timeout-wait-for-node 100000
if: steps.cache-prepare-validator-data.outputs.cache-hit != 'true'
submit-new-proposal:
runs-on: elys-runner
needs:
[
retrieve-latest-tag,
retrieve-snapshot,
retrieve-old-binary,
build-new-binary,
prepare-validator-data,
]
steps:
- name: Cache Directories
uses: actions/cache@v4
id: cache-submit-new-proposal
with:
path: |
/home/runner/.elys
/home/runner/.elys2
key: ${{ runner.os }}-submit-new-proposal-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
lookup-only: true
- name: Restore prepare validator data from cache
uses: actions/cache/restore@v4
with:
path: |
/home/runner/.elys
/home/runner/.elys2
key: ${{ runner.os }}-prepare-validator-data-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-submit-new-proposal.outputs.cache-hit != 'true'
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
if: steps.cache-submit-new-proposal.outputs.cache-hit != 'true'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
if: steps.cache-submit-new-proposal.outputs.cache-hit != 'true'
- name: Restore new binary from cache
uses: actions/cache@v4
with:
path: |
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }}
${{ needs.build-new-binary.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH}}
${{ needs.build-new-binary.outputs.UPLOAD_SNAPSHOT_BINARY_PATH }}
key: ${{ needs.build-new-binary.outputs.CACHE_KEY }}
if: steps.cache-submit-new-proposal.outputs.cache-hit != 'true'
- name: Restore old binary from cache
uses: actions/cache@v4
with:
path: |
${{ needs.retrieve-old-binary.outputs.OLD_BINARY_PATH }}
key: ${{ runner.os }}-retrieve-old-binary-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-submit-new-proposal.outputs.cache-hit != 'true'
- name: Submit new proposal
run: |
GOMEMLIMIT=32GiB \
${{ needs.build-new-binary.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH }} \
${{ needs.retrieve-snapshot.outputs.SNAPSHOT_FILE_PATH }} \
${{ needs.retrieve-old-binary.outputs.OLD_BINARY_PATH }} \
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }} \
--skip-snapshot \
--skip-chain-init \
--skip-create-validator \
--skip-prepare-validator-data \
--skip-upgrade-to-new-binary \
--timeout-next-block 100000 \
--timeout-wait-for-node 100000
if: steps.cache-submit-new-proposal.outputs.cache-hit != 'true'
upgrade-to-new-binary:
runs-on: elys-runner
needs:
[
retrieve-latest-tag,
retrieve-snapshot,
build-new-binary,
submit-new-proposal,
]
steps:
- name: Cache Directories
uses: actions/cache@v4
id: cache-upgrade-to-new-binary
with:
path: |
/home/runner/.elys
/home/runner/.elys2
key: ${{ needs.build-new-binary.outputs.CACHE_KEY }}-upgrade-to-new-binary
lookup-only: true
- name: Restore submit new proposal from cache
uses: actions/cache/restore@v4
with:
path: |
/home/runner/.elys
/home/runner/.elys2
key: ${{ runner.os }}-submit-new-proposal-${{ needs.retrieve-latest-tag.outputs.LATEST_TAG }}
if: steps.cache-upgrade-to-new-binary.outputs.cache-hit != 'true'
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
if: steps.cache-upgrade-to-new-binary.outputs.cache-hit != 'true'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
if: steps.cache-upgrade-to-new-binary.outputs.cache-hit != 'true'
- name: Restore new binary from cache
uses: actions/cache@v4
with:
path: |
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }}
${{ needs.build-new-binary.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH}}
${{ needs.build-new-binary.outputs.UPLOAD_SNAPSHOT_BINARY_PATH }}
key: ${{ needs.build-new-binary.outputs.CACHE_KEY }}
if: steps.cache-upgrade-to-new-binary.outputs.cache-hit != 'true'
- name: Upgrade to new binary
run: |
GOMEMLIMIT=32GiB \
${{ needs.build-new-binary.outputs.NEW_UPGRADE_ASSURE_BINARY_PATH }} \
${{ needs.retrieve-snapshot.outputs.SNAPSHOT_FILE_PATH }} \
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }} \
${{ needs.build-new-binary.outputs.NEW_BINARY_PATH }} \
--skip-snapshot \
--skip-chain-init \
--skip-create-validator \
--skip-prepare-validator-data \
--skip-submit-proposal \
--timeout-next-block 100000 \
--timeout-wait-for-node 100000
if: steps.cache-upgrade-to-new-binary.outputs.cache-hit != 'true'
create-new-snapshot-file:
runs-on: elys-runner
needs: [retrieve-latest-tag, build-new-binary, upgrade-to-new-binary]
steps:
- name: Restore upgrade to new binary from cache
uses: actions/cache/restore@v4
with:
path: |
/home/runner/.elys
/home/runner/.elys2
key: ${{ needs.build-new-binary.outputs.CACHE_KEY }}-upgrade-to-new-binary
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Create new snapshot file
run: |
SANITIZED_HEAD_REF=${{ github.head_ref || github.ref }}
SANITIZED_HEAD_REF=$(echo "$SANITIZED_HEAD_REF" | sed 's|refs/heads/||; s|/|_|g')
NEW_SNAPSHOT_FILENAME="elys-snapshot-${SANITIZED_HEAD_REF}.tar.lz4"
NEW_SNAPSHOT_PATH="/tmp/${NEW_SNAPSHOT_FILENAME}"
echo "NEW_SNAPSHOT_FILENAME=$NEW_SNAPSHOT_FILENAME" >> $GITHUB_ENV
echo "NEW_SNAPSHOT_PATH=$NEW_SNAPSHOT_PATH" >> $GITHUB_ENV
cd $HOME
tar -cf - .elys | lz4 -z - > "$NEW_SNAPSHOT_PATH"
- name: Upload snapshot
run: |
export R2_ACCESS_KEY=${{ secrets.R2_ACCESS_KEY }}
export R2_SECRET_KEY=${{ secrets.R2_SECRET_KEY }}
export R2_ENDPOINT=${{ secrets.R2_ENDPOINT }}
export R2_BUCKET_NAME=${{ secrets.R2_BUCKET_NAME }}
$UPLOAD_SNAPSHOT_BINARY_PATH $NEW_SNAPSHOT_PATH
- name: Remove snapshot file
run: |
rm -f $NEW_SNAPSHOT_PATH
- name: Info about the snapshot
run: |
echo "Snapshot URL: https://snapshots.elys.network/$NEW_SNAPSHOT_FILENAME"