forked from matter-labs/zksync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exit-tool.sh
executable file
·69 lines (57 loc) · 1.86 KB
/
exit-tool.sh
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
#!/bin/bash
USAGE='Usage: exit-tool.sh [-h|--help|init|run|continue]
where
-h | --help show this message
init prepare the database for data restore
run start the data restoring process
continue continue the interrupted data restoring process
If command is "run" or "continue", the following additional arguments are required:
network Ethereum network (rinkeby / ropsten / mainnet)
account address Address of the account to generate exit proof for
token Token for which proof will be generated (may be numeric token ID, address or symbol, e.g. ETH)
web3 url Address of the HTTP Web3 API, which will be used to gather data from Ethereum.
Example workflow:
./exit-tool.sh init
./exit-tool.sh run rinkeby 12 ETH http://127.0.0.1:8545
'
# Function to stop PostgreSQL container on exit
function docker_down() {
exitcode=$?
docker-compose -f ./docker-compose.yml stop data-restore-postgres
exit $exitcode
}
COMMAND=$1
# Directories for universal setup
CURRENT_DIR=`pwd`
mkdir -p "$CURRENT_DIR/setup"
KEYS_FOLDER_LOCAL="$CURRENT_DIR/setup"
KEYS_FOLDER_CONTAINER="/usr/src/zksync/keys/setup"
# Run PostgresSQL
docker-compose -f ./docker-compose.yml up -d data-restore-postgres
trap docker_down EXIT
# Decide which command has to be run
case $COMMAND in
init)
SUBCOMMAND="init"
;;
run | continue)
NETWORK=$2
ADDRESS=$3
TOKEN=$4
WEB3_URL=$5
SUBCOMMAND="$COMMAND $NETWORK $ADDRESS $TOKEN $WEB3_URL"
;;
-h | --help)
echo "$USAGE"
exit 0
;;
*)
echo "Unknown Data Restore command"
echo "$USAGE"
exit 1
;;
esac
DOCKER_ARGS="--net=host -v $KEYS_FOLDER_LOCAL:$KEYS_FOLDER_CONTAINER"
DOCKER_IMAGE="matterlabs/exit-tool:latest"
DOCKER_COMMAND="exit-tool-entry.sh $SUBCOMMAND"
docker run $DOCKER_ARGS $DOCKER_IMAGE $DOCKER_COMMAND