forked from AztecProtocol/Setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·63 lines (52 loc) · 1.79 KB
/
run
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
#!/bin/bash
set -e
# Wait for other docker-composed stuff to startup. Ugh.
until curl --output /dev/null --silent --head --fail http://$JOB_SERVER_HOST; do
echo "Waiting for job server to start..."
sleep 1
done
until curl --output /dev/null --silent --head --fail http://$MPC_SERVER_HOST/api; do
echo "Waiting for mpc server to start..."
sleep 1
done
mkdir -p /usr/src/setup_db
cd /usr/src/setup_db
EC2_AVAIL_ZONE=$(curl --connect-timeout 5 -s http://169.254.169.254/latest/meta-data/placement/availability-zone || true)
EC2_REGION=$(echo -n $EC2_AVAIL_ZONE | sed 's/[a-z]$//')
EC2_REGION=${EC2_REGION:-'us-east-2'}
echo Region: $EC2_REGION
function run_job {
while : ; do
taskset -c $1 ./run-job && break
sleep 1
done
}
while true; do
cd /usr/src/setup_db
rm -f *
# Get server state. Wait until state is RANGE_PROOFS.
echo "Waiting until ceremony is computing range proofs..."
while : ; do
STATE=$(curl -f -L -s http://$MPC_SERVER_HOST/api/state)
CEREMONYSTATE=$(echo $STATE | jq -j .ceremonyState)
[ "$CEREMONYSTATE" != "RANGE_PROOFS" ] || break
sleep 10
done
echo "Ceremony state is RANGE_PROOFS."
# Extract variables from state.
export CEREMONYNAME=$(echo $STATE | jq -j .name)
export KMAX=$(echo $STATE | jq -j .rangeProofKmax)
STARTTIME=$(echo $STATE | jq -j .startTime)
echo Downloading generator coefficients...
aws --region $EC2_REGION s3 cp s3://aztec-post-process/generator$KMAX.dat generator_prep.dat --quiet
echo Downloading g1x points...
aws --region $EC2_REGION s3 cp "s3://aztec-post-process/$CEREMONYNAME/g1x_prep.dat" g1x_prep.dat --quiet
[ -z "$NUMJOBS" ] && NUMJOBS=$(nproc)
cd /usr/src/setup-post-process
echo "Running $NUMJOBS job processors."
for CPU in $(seq 0 $[NUMJOBS - 1])
do
run_job $CPU &
done
wait
done