forked from godwokenrises/godwoken-kicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kicker
executable file
·624 lines (550 loc) · 21.6 KB
/
kicker
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
#!/bin/bash
set -o errexit
EXECUTABLE=$0
WORKSPACE="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
# TODO ENABLE_MULTI_CKB_NODES
# TODO WATCH_CKB_REORG
# TODO INSTALL_JS_NODE_MODULE_NOT_COPY
# TODO BUILD_WEB3_INDEXER_ON_LOCAL_OVER_DOCKER
# TODO cargo fetch via proxy
function usage() {
echo "Usage: $EXECUTABLE [OPTIONS] <SUBCOMMAND>"
echo
echo "OPTIONS:"
echo " --help Print usage information"
echo " -- <args>... Execute docker-compose command"
echo
echo "SUBCOMMANDS:"
echo " init Init running environment"
echo " start Start services and deploy local network"
echo " stop Stop services"
echo " info Print some useful info about the network and running services, such as Web3 RPC URL"
echo " clean Clean containers volumed data"
echo " ps [service] List services"
echo " logs [service] Tail target service's logs"
echo " enter <service> Enter target service's container"
echo " manual-build Manually build services artifacts"
echo " deposit <eth-address> <amount> Deposit CKB to layer2"
echo " get-balance <eth-address> Get layer2 balance"
echo " transfer <eth-address> <amount> <fee> <sudt-id> Transfer sudt token"
echo
echo "EXAMPLES:"
echo " * Deploy the local network and print service info"
echo
echo " $ $EXECUTABLE start"
echo " $ $EXECUTABLE info"
echo
echo " * Deposit 1000CKB from layer1 to layer2"
echo
echo " $ $EXECUTABLE deposit 0x618cc3C660cEBFDbA8570CA739b1744AE3E2553a 1000"
echo " $ $EXECUTABLE get-balance 0x618cc3C660cEBFDbA8570CA739b1744AE3E2553a"
echo
echo " * Redeploy the local network"
echo
echo " $ $EXECUTABLE -- kill"
echo " $ $EXECUTABLE stop"
echo " $ sudo $EXECUTABLE clean"
echo " $ $EXECUTABLE start"
echo
echo " * Execute docker-compose commands"
echo
echo " $ $EXECUTABLE -- exec ckb ls -l"
echo " $ $EXECUTABLE -- top godwoken"
echo " $ $EXECUTABLE -- kill godwoken"
echo " $ $EXECUTABLE -- --help"
}
function info() {
echo -e "\033[0;32m[${FUNCNAME[1]}] $1\033[0m"
}
function error() {
echo -e "\033[0;31m[${FUNCNAME[1]}] ERROR: $1\033[0m">&2
}
function erun() {
echo -e "\033[0;32m:> $*\033[0m">&2
echo
eval "$*"
}
function compose() {
override=""
if [ "$ENABLE_MULTI_CKB_NODES" = "true" ]; then
override="$override -f docker/chaos.compose.yml"
fi
if [ "$MANUAL_BUILD_GODWOKEN" = "true" ]; then
override="$override -f docker/manual-godwoken.compose.yml"
fi
if [ "$MANUAL_BUILD_WEB3" = "true" ]; then
override="$override -f docker/manual-web3.compose.yml"
fi
if [ "$MANUAL_BUILD_WEB3_INDEXER" = "true" ]; then
override="$override -f docker/manual-web3-indexer.compose.yml"
fi
if [ "$MANUAL_BUILD_POLYJUICE" = "true" ]; then
override="$override -f docker/manual-polyjuice.compose.yml"
fi
if [ "$MANUAL_BUILD_SCRIPTS" = "true" ]; then
override="$override -f docker/manual-scripts.compose.yml"
fi
if [ "$START_GODWOKEN_V0" = "true" ]; then
override="$override -f docker/manual-godwoken-v0.compose.yml"
fi
erun docker-compose -f docker/docker-compose.yml $override "$@"
}
function gw_tools_compose_override() {
override=""
if [ "$MANUAL_BUILD_GODWOKEN" = "true" ]; then
if [ ! -f "$WORKSPACE/docker/manual-artifacts/gw-tools" ]; then
error "\"MANUAL_BUILD_GODWOKEN = true\" but \"docker/manual-artifacts/gw-tools\" not found"
exit 1
fi
override="$override -f docker/manual-godwoken.compose.yml"
fi
echo $override
}
function init() {
echo -e "\033[0;33mNOTE: The docker-compose version should be newer than 1.29.0\033[0m"
echo
erun docker-compose -f docker/docker-compose.yml build --no-rm
# In order to compat with old-version kicker, we execute manual-build at init
manual_build
}
function start() {
echo -e "\033[0;33mNOTE: The docker-compose version should be newer than 1.29.0\033[0m"
echo -e "\033[0;33mNOTE: This might take several minutes on the first run\033[0m"
echo
if [ "$MANUAL_BUILD_GODWOKEN" = "true" ]; then
if [ ! -f "$WORKSPACE/docker/manual-artifacts/godwoken" ]; then
error "\"MANUAL_BUILD_GODWOKEN = true\" but \"docker/manual-artifacts/godwoken\" not found"
exit 1
fi
if [ ! -f "$WORKSPACE/docker/manual-artifacts/gw-tools" ]; then
error "\"MANUAL_BUILD_GODWOKEN = true\" but \"docker/manual-artifacts/gw-tools\" not found"
exit 1
fi
fi
if [ "$MANUAL_BUILD_WEB3" = "true" ]; then
if [ ! -d "$WORKSPACE/docker/manual-artifacts/godwoken-web3/" ]; then
error "\"MANUAL_BUILD_WEB3 = true\" but \"docker/manual-artifacts/godwoken-web3\" not found"
erun ls -l -a $WORKSPACE/docker/manual-artifacts/godwoken-web3/
exit 1
fi
fi
if [ "$MANUAL_BUILD_WEB3_INDEXER" = "true" ]; then
if [ ! -f "$WORKSPACE/docker/manual-artifacts/gw-web3-indexer" ]; then
error "\"MANUAL_BUILD_WEB3_INDEXER = true\" but \"docker/manual-artifacts/gw-web3-indexer\" not found"
exit 1
fi
fi
compose up -d --build
if [ "$?" = "0" ]; then
info "Services started successfully"
fi
}
function stop() {
compose down --remove-orphans
}
function info_() {
echo "Web3 RPC URL: http://127.0.0.1:8024"
}
function clean() {
n_alive=$(compose ps --quiet | grep -oE '[0-9a-z]{64}' | wc -l | tr -d " ")
if [ $n_alive != 0 ]; then
error "Ensure container services are down"
compose ps
exit 1
fi
set -x
rm -rf docker/layer2-v0/data/
rm -f docker/layer2-v0/config/scripts-deployment.json
rm -f docker/layer2-v0/config/rollup-genesis-deployment.json
rm -f docker/layer2-v0/config/godwoken-config.toml
rm -rf docker/layer2/data/
rm -rf docker/layer2/data-readonly/
rm -f docker/layer2/config/scripts-deployment.json
rm -f docker/layer2/config/rollup-genesis-deployment.json
rm -f docker/layer2/config/godwoken-config.toml
rm -f docker/layer2/config/godwoken-config-readonly.toml
rm -f docker/layer2/config/polyjuice-root-account-id
rm -f docker/layer2/config/web3-indexer-config.toml
rm -rf docker/ckb-indexer/
rm -rf docker/layer1/ckb/data/
rm -rf docker/layer1/ckb2/data/
rm -rf docker/layer1/ckb3/data/
rm -rf docker/postgres/data
rm -rf docker/redis/data
rm -rf docker/manual-artifacts
}
function ps() {
compose ps "$@"
}
function logs() {
compose logs "$@"
}
function enter() {
service="${1:?"\"$EXECUTABLE enter\" requires 1 arguments"}"
compose exec "$service" /bin/bash
}
# @example deposit "0x0C1EfCCa2Bcb65A532274f3eF24c044EF4ab6D73" 1000
function deposit() {
ethaddr=${1:?"\"$EXECUTABLE deposit\" requires eth address as 1st argument"}
amount=${2:?"\"$EXECUTABLE deposit\" requires amount as 2nd argument"}
pkpath=${PRIVATE_KEY_PATH:-"$WORKSPACE/accounts/ckb-miner-and-faucet.key"}
if [ ! -f $pkpath ]; then
error "$pkpath: No such file or directory"
exit 1
fi
abspkpath="$( cd -- "$(dirname "$pkpath")" >/dev/null 2>&1 ; pwd -P )/$(basename $pkpath)"
docker-compose -f docker/docker-compose.yml $(gw_tools_compose_override) run \
--no-deps \
--use-aliases \
--volume=$WORKSPACE/docker/layer2/config:/config \
--volume=$abspkpath:/privkey-path \
--entrypoint "gw-tools deposit-ckb \
--godwoken-rpc-url http://godwoken:8119 \
--ckb-rpc http://ckb:8114 \
--scripts-deployment-path /config/scripts-deployment.json \
--config-path /config/godwoken-config.toml \
--privkey-path /privkey-path \
--eth-address $ethaddr \
--capacity $amount" \
godwoken
}
function transfer() {
toEthAddress=${1:?"\"$EXECUTABLE transfer\" requires toEthAddress as 1st argument"}
amount=${2:?"\"$EXECUTABLE transfer\" requires amount as 2nd argument"}
fee=${3:?"\"$EXECUTABLE transfer\" requires fee as 3nd argument"}
sudtId=${4:?"\"$EXECUTABLE transfer\" requires sudtId as 4nd argument"}
pkpath=${PRIVATE_KEY_PATH:-"$WORKSPACE/accounts/ckb-miner-and-faucet.key"}
if [ ! -f $pkpath ]; then
error "$pkpath: No such file or directory"
exit 1
fi
abspkpath="$( cd -- "$(dirname "$pkpath")" >/dev/null 2>&1 ; pwd -P )/$(basename $pkpath)"
docker-compose -f docker/docker-compose.yml run \
--no-deps \
--use-aliases \
--volume=$WORKSPACE/docker/layer2/config:/config \
--volume=$abspkpath:/privkey-path \
--entrypoint "gw-tools transfer \
--godwoken-rpc-url http://godwoken:8119 \
--scripts-deployment-path /config/scripts-deployment.json \
--config-path /config/godwoken-config.toml \
--privkey-path /privkey-path \
--sudt-id $sudtId \
--to $toEthAddress \
--fee $fee \
--amount $amount" \
godwoken
}
# Note that this function MUST be in tty mode.
# @example get-balance "0x0C1EfCCa2Bcb65A532274f3eF24c044EF4ab6D73"
function get_balance() {
ethaddr=${1:?"\"$EXECUTABLE get-balance\" requires eth address as 1st argument"}
script_hash=$(to_script_hash "$ethaddr")
echo "script hash: ${script_hash}"
docker-compose -f docker/docker-compose.yml $(gw_tools_compose_override) run \
--no-deps \
--use-aliases \
--entrypoint "gw-tools get-balance \
--godwoken-rpc-url http://godwoken:8119 \
--account $script_hash" \
godwoken 2>&1
}
# @to-script-hash "0x0C1EfCCa2Bcb65A532274f3eF24c044EF4ab6D73"
function to_script_hash() {
ethaddr=${1:?"\"$EXECUTABLE to-script-hash\" requires eth address as 1st argument"}
compose_override=$(gw_tools_compose_override)
output=$(docker-compose -f docker/docker-compose.yml $compose_override run \
--no-deps \
--use-aliases \
--volume=$WORKSPACE/docker/layer2/config:/config \
--entrypoint "gw-tools to-script-hash \
--config-path /config/godwoken-config.toml \
--scripts-deployment-path /config/scripts-deployment.json \
--eth-address $ethaddr" \
godwoken 2>&1)
echo "$output" | grep -oE '0x.*'
}
# TODO: Test deposit v0, remove after abandon v0
# @example deposit-v0 1000
function deposit_v0() {
amount=${1:?"\"$EXECUTABLE deposit\" requires amount as 1nd argument"}
pkpath=${PRIVATE_KEY_PATH:-"$WORKSPACE/accounts/ckb-miner-and-faucet.key"}
if [ ! -f $pkpath ]; then
error "$pkpath: No such file or directory"
exit 1
fi
abspkpath="$( cd -- "$(dirname "$pkpath")" >/dev/null 2>&1 ; pwd -P )/$(basename $pkpath)"
docker-compose -f docker/docker-compose.yml -f docker/manual-godwoken-v0.compose.yml run \
--no-deps \
--use-aliases \
--volume=$WORKSPACE/docker/layer2-v0/config:/config \
--volume=$abspkpath:/privkey-path \
--entrypoint "gw-tools deposit-ckb \
--godwoken-rpc-url http://godwoken-v0:8119 \
--ckb-rpc http://ckb:8114 \
--scripts-deployment-path /config/scripts-deployment.json \
--config-path /config/godwoken-config.toml \
--privkey-path /privkey-path \
--capacity $amount" \
godwoken-v0
}
# TODO: Test withdraw v0 to v1, remove after abandon v0
# @example withdraw-v0-to-v1 "0x0C1EfCCa2Bcb65A532274f3eF24c044EF4ab6d77" 500
function withdraw_v0_to_v1() {
ethaddr=${1:?"\"$EXECUTABLE withdraw-v0-to-v1\" requires eth address as 1st argument"}
amount=${2:?"\"$EXECUTABLE withdraw-v0-to-v1\" requires amount as 2nd argument"}
pkpath=${PRIVATE_KEY_PATH:-"$WORKSPACE/accounts/ckb-miner-and-faucet.key"}
if [ ! -f $pkpath ]; then
error "$pkpath: No such file or directory"
exit 1
fi
abspkpath="$( cd -- "$(dirname "$pkpath")" >/dev/null 2>&1 ; pwd -P )/$(basename $pkpath)"
docker-compose -f docker/docker-compose.yml -f docker/manual-godwoken-v0.compose.yml run \
--no-deps \
--use-aliases \
--volume=$WORKSPACE/docker/layer2-v0/config:/config \
--volume=$abspkpath:/privkey-path \
--entrypoint "gw-tools withdraw-to-v1 \
--godwoken-rpc-url http://godwoken-v0:8119 \
--scripts-deployment-path /config/scripts-deployment.json \
--config-path /config/godwoken-config.toml \
--privkey-path /privkey-path \
--eth-address $ethaddr \
--capacity $amount" \
godwoken-v0
}
# @example MANUAL_BUILD_WEB3=true \
# WEB3_GIT_URL=ssh://[email protected]/godwokenrises/godwoken-web3 \
# WEB3_GIT_CHECKOUT=compatibility-breaking-changes \
# ./kicker manual-build
function manual_build() {
DOCKER_MANUAL_BUILD_IMAGE_NAME=${DOCKER_MANUAL_BUILD_IMAGE_NAME:-"retricsu/godwoken-manual-build"}
DOCKER_MANUAL_BUILD_IMAGE_TAG=${DOCKER_MANUAL_BUILD_IMAGE_TAG:-"ckb2021"}
DOCKER_MANUAL_BUILD_IMAGE="${DOCKER_MANUAL_BUILD_IMAGE:-"$DOCKER_MANUAL_BUILD_IMAGE_NAME:$DOCKER_MANUAL_BUILD_IMAGE_TAG"}"
echo "MANUAL_BUILD_WEB3 = \"$MANUAL_BUILD_WEB3\""
echo "WEB3_GIT_URL = \"$WEB3_GIT_URL\""
echo "WEB3_GIT_CHECKOUT = \"$WEB3_GIT_CHECKOUT\""
echo "MANUAL_BUILD_WEB3_INDEXER = \"$MANUAL_BUILD_WEB3_INDEXER\""
echo "MANUAL_BUILD_GODWOKEN = \"$MANUAL_BUILD_GODWOKEN\""
echo "GODWOKEN_GIT_URL = \"$GODWOKEN_GIT_URL\""
echo "GODWOKEN_GIT_CHECKOUT = \"$GODWOKEN_GIT_CHECKOUT\""
echo "MANUAL_BUILD_SCRIPTS = \"$MANUAL_BUILD_SCRIPTS\""
echo "SCRIPTS_GIT_URL = \"$SCRIPTS_GIT_URL\""
echo "SCRIPTS_GIT_CHECKOUT = \"$SCRIPTS_GIT_CHECKOUT\""
echo "OMNI_LOCK_GIT_URL = \"$OMNI_LOCK_GIT_URL\""
echo "OMNI_LOCK_GIT_CHECKOUT = \"$OMNI_LOCK_GIT_CHECKOUT\""
echo "MANUAL_BUILD_POLYJUICE = \"$MANUAL_BUILD_POLYJUICE\""
echo "POLYJUICE_GIT_URL = \"$POLYJUICE_GIT_URL\""
echo "POLYJUICE_GIT_CHECKOUT = \"$POLYJUICE_GIT_CHECKOUT\""
echo "DOCKER_MANUAL_BUILD_IMAGE = \"$DOCKER_MANUAL_BUILD_IMAGE\""
echo
if [ "$MANUAL_BUILD_WEB3" = "true" ]; then
info "Start building godwoken-web3"
srcdir=$WORKSPACE/packages/godwoken-web3
dstdir=$WORKSPACE/docker/manual-artifacts/godwoken-web3
# Download repo
prepare_repo godwoken-web3 "$WEB3_GIT_URL" "$WEB3_GIT_CHECKOUT"
# Yarn install via docker (assumes the "web3" docker-compose service installed yarn)
# ATTENTION: Do not use `compose run ...`. `compose run` will add
# `-f docker/manual-web3.compose.yml`, and it will volume
# the `docker/manual-artifacts` directory, it is not what we expect.
erun docker-compose -f docker/docker-compose.yml run \
--rm \
--no-deps \
--volume=$WORKSPACE/packages/godwoken-web3:/app \
--workdir=/app \
--entrypoint "\"bash -c 'yarn install && yarn run build'\"" \
web3
# Copy the built artifacts to `docker/manual-artifacts/godwoken-web3`.
#
# More: ./docker/manual-web3.compose.yml
erun rm -rf $dstdir
erun mkdir -p $dstdir
erun cp -r $srcdir/packages \
$srcdir/package.json \
$srcdir/node_modules \
$srcdir/yarn.lock \
$dstdir
else
info "skip building godwoken-web3"
fi
if [ "$MANUAL_BUILD_WEB3_INDEXER" = "true" ]; then
info "Start building godwoken-web3-indexer"
srcdir=$WORKSPACE/packages/godwoken-web3
dstdir=$WORKSPACE/docker/manual-artifacts
# Download repo
prepare_repo godwoken-web3 "$WEB3_GIT_URL" "$WEB3_GIT_CHECKOUT"
# Cargo fetch Rust dependencies (in order to access network via
# host network). The docker image must have installed cargo, molecule
# and rustfmt.
erun "cd $srcdir && CARGO_HOME=$srcdir/.cargo cargo fetch --locked && cd -"
erun docker run \
--rm \
--env CARGO_HOME=/app/.cargo \
--volume $srcdir:/app \
--volume $WORKSPACE/packages/.rustup:/root/.rustup \
--workdir /app \
retricsu/godwoken-manual-build:ckb2021 cargo build --locked --release
# Copy the built artifacts to `docker/manual-artifacts/gw-web3-indexer`
#
# More: ./docker/manual-web3-indexer.compose.yml
erun mkdir -p $dstdir
erun cp $srcdir/target/release/gw-web3-indexer $dstdir
else
info "skip building godwoken-web3-indexer(gw-web3-indexer)"
fi
if [ "$MANUAL_BUILD_GODWOKEN" = "true" ]; then
info "Start building godwoken"
srcdir=$WORKSPACE/packages/godwoken
dstdir=$WORKSPACE/docker/manual-artifacts
# Download repo
prepare_repo godwoken "$GODWOKEN_GIT_URL" "$GODWOKEN_GIT_CHECKOUT"
# Cargo fetch Rust dependencies (in order to access network via
# host network). The docker image must have installed cargo and molecule
erun docker run \
--rm \
--env CARGO_HOME=/app/.cargo \
--volume $srcdir:/app \
--volume $WORKSPACE/packages/.rustup:/root/.rustup \
--workdir /app \
retricsu/godwoken-manual-build:ckb2021 cargo build --locked --release
# Copy the built artifacts to `docker/manual-artifacts/`
#
# More: ./docker/manual-godwoken.compose.yml
erun mkdir -p $dstdir
erun cp $srcdir/target/release/godwoken $dstdir
erun cp $srcdir/target/release/gw-tools $dstdir
else
info "skip building Godwoken"
fi
if [ "$MANUAL_BUILD_POLYJUICE" = "true" ]; then
srcdir=$WORKSPACE/packages/godwoken/gwos-evm
dstdir=$WORKSPACE/docker/manual-artifacts/polyjuice/
# Download repo
prepare_repo godwoken-polyjuice "$POLYJUICE_GIT_URL" "$POLYJUICE_GIT_CHECKOUT"
cd $srcdir
erun make all-via-docker
# Copy the built artifacts to `docker/manual-artifacts/`
mkdir -p $dstdir
erun cp -r build/* $dstdir
else
info "skip building Polyjuice"
fi
if [ "$MANUAL_BUILD_SCRIPTS" = "true" ]; then
srcdir=$WORKSPACE/packages/godwoken/gwos
dstdir=$WORKSPACE/docker/manual-artifacts/scripts/
# Download repo
prepare_repo godwoken-scripts "$SCRIPTS_GIT_URL" "$SCRIPTS_GIT_CHECKOUT"
# Install capsule
# TODO: use cpasule from godwoken-manual-build image
if [ -z "$(command -v capsule)" ]; then
erun cargo install ckb-capsule
fi
erun cd $srcdir/c \&\& erun make all-via-docker
erun cd $srcdir \&\& capsule build --release --debug-output
# Copy the built artifacts to `docker/manual-artifacts/`
mkdir -p $dstdir
erun cp -r $srcdir/build/release/* $dstdir
erun cp $srcdir/c/build/*-generator $dstdir
erun cp $srcdir/c/build/*-validator $dstdir
# Copy the prebuild omni-lock to `docker/manual-artifacts/`
erun docker-compose -f $WORKSPACE/docker/docker-compose.yml run \
--rm \
--no-deps \
--volume=$dstdir:/godwoken-scripts \
--entrypoint "\"bash -c 'cp /scripts/godwoken-scripts/omni_lock /godwoken-scripts/omni_lock'\"" \
godwoken
else
info "skip building Scripts"
fi
}
function prepare_repo() {
name=$1
url=$2
checkout=$3
dir="$WORKSPACE/packages/$name"
mkdir -p $WORKSPACE/packages
if [[ -d "$dir" ]]; then
remote_url=$(git -C $dir remote get-url origin)
if [ "$url" != "$remote_url" ]; then
error "$dir already exists and the remote url is not \"$url\""
exit 1
fi
if [ "$ALWAYS_FETCH_NEW_PACKAGE" != "false" ]; then
erun git -C $dir fetch origin $checkout
erun git -C $dir checkout FETCH_HEAD
erun git -C $dir submodule update --init --recursive --depth=1
fi
else
erun git clone --depth=1 $url $dir
erun git -C $dir fetch origin $checkout
erun git -C $dir checkout FETCH_HEAD
erun git -C $dir submodule update --init --recursive --depth=1
fi
}
function main() {
if [ "$#" = "0" ]; then
usage
exit 0
fi
command="$1"
shift 1
case $command in
"--help")
usage
;;
"init")
init
;;
"start")
start
;;
"stop")
stop
;;
"info")
info_
;;
"clean")
clean
;;
"ps")
ps "$@"
;;
"logs")
logs "$@"
;;
"enter")
enter "$@"
;;
"deposit")
deposit "$@"
;;
"deposit-v0")
deposit_v0 "$@"
;;
"transfer")
transfer "$@"
;;
"withdraw-v0-to-v1")
withdraw_v0_to_v1 "$@"
;;
"get-balance")
get_balance "$@"
;;
"manual-build")
manual_build
;;
"--")
compose "${@:?"\"$EXECUTABLE --\" requires at least one argument"}"
;;
*)
error "unknown subcommand: \"$command\""
echo
usage
exit 1
;;
esac
}
cd $WORKSPACE
main "$@"