-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathlocalnet.sh
executable file
·62 lines (51 loc) · 1.63 KB
/
localnet.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
#!/usr/bin/env bash
set -euo pipefail
cpu_struct="linux";
# Clean up first
bash "$(dirname -- "$0";)/localnet.down.sh"
container_version=v2.0.20
container_name="chainlink-solana.test-validator"
echo "Starting $container_name@$container_version"
# NOTE: anzaxyz/agave docker image only supports linux/amd64
# https://hub.docker.com/r/anzaxyz/agave/tags
# If you are running on an ARM machine, Following error will be thrown:
# "Incompatible CPU detected: missing AVX support. Please build from source on the target "
docker run -d \
--platform linux/amd64 \
-p 127.0.0.1:8899:8899 \
-p 127.0.0.1:8900:8900 \
-p 127.0.0.1:9900:9900 \
--name "${container_name}" \
--entrypoint /bin/sh \
"anzaxyz/agave:${container_version}" \
-c "solana-test-validator && echo 'Validator started successfully'"
# --network-alias "${container_name}" \
# --network chainlink \
echo "Waiting for test validator to become ready.."
start_time=$(date +%s)
prev_output=""
while true
do
output=$(docker logs chainlink-solana.test-validator 2>&1)
if [[ "${output}" != "${prev_output}" ]]; then
echo -n "${output#$prev_output}"
prev_output="${output}"
fi
if [[ $output == *"Finalized Slot"* ]]; then
echo ""
echo "solana-test-validator is ready."
exit 0
fi
if [[ $output == *"Incompatible CPU detected"* || $output == *"Aborted"* ]]; then
echo ""
echo "anzaxyz/agave docker image only supports linux/amd64"
exit 1
fi
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if (( elapsed_time > 10 )); then
echo "Error: Command did not become ready within 10 seconds"
exit 1
fi
sleep 3
done