-
Notifications
You must be signed in to change notification settings - Fork 193
171 lines (144 loc) · 5.4 KB
/
test_firedancer_localnet.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
name: Firedancer
on:
workflow_call:
inputs:
machine:
type: string
default: linux_gcc_zen2
workflow_dispatch:
jobs:
firedancer-localnet:
timeout-minutes: 30
runs-on: [self-hosted, 512G]
env:
CC: gcc
MACHINE: ${{ inputs.machine }}
EXTRAS: no-agave
AGAVE_VERSION: v2.0.3
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: ./.github/actions/deps
- uses: ./.github/actions/hugepages
with:
count_gigantic: 200
count_huge: 1000 # TODO: this is required until we can handle anonymouse workspaces and loose huge pages in fddev
- name: build
run: |
make -j fddev
- name: find OBJDIR
run: |
echo OBJDIR=$(make help | grep OBJDIR | awk '{print $4}') >> $GITHUB_ENV
- name: agave repo setup
run: |
cd ..
if [ ! -d "agave" ]; then
git clone https://github.com/anza-xyz/agave.git
fi
cd agave
git fetch
git checkout ${{ env.AGAVE_VERSION }}
source ~/.cargo/env
./cargo build --release
echo "AGAVE_PATH=$(pwd)/target/release" >> $GITHUB_ENV
- name: stop any dead runs - local cluster
run: |
sudo killall -9 -q solana-validator || true
sudo killall -9 -q agave-validator || true
sudo killall -9 -q fddev || true
- name: remove ledger and cluster artifacts if they exist
run: |
sudo rm -rf ../*.so
sudo rm -rf ../test-ledger
- name: start agave cluster
run: |
sudo prlimit --nofile=1048576 --memlock=unlimited --pid $$
nohup contrib/test/setup_fd_cluster.sh > setup_fd_cluster.log 2>&1 &
echo $! > ${{ github.workspace }}/setup_fd_cluster.pid
sleep 30
- name: start firedancer node
run: |
sudo prlimit --nofile=1048576 --memlock=unlimited --pid $$
contrib/test/setup_fd_cluster_stakes.sh
nohup bash -c "CC=gcc ./contrib/test/test_firedancer_leader.sh" > test_firedancer_leader.log 2>&1 &
echo $! > ${{ github.workspace }}/test_firedancer_leader.pid
- name: check if all validators have been leader
timeout-minutes: 5
run: |
RPC_URL="http://localhost:8123/"
for attempt in {1..30}; do
if curl -s --fail "$RPC_URL" -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0", "id": 1,
"method": "getSlot"
}' --max-time 2 > /dev/null; then
break
fi
sleep 10
if [ "$attempt" -eq 30 ]; then
exit 1
fi
done
declare -A leader_map
declare -A has_been_leader
while true; do
response=$(curl -s "$RPC_URL" -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0", "id": 1,
"method": "getLeaderSchedule"
}')
if [ -z "$response" ] || ! echo "$response" | jq -e '.result' > /dev/null; then
exit 1
fi
while IFS="=" read -r key value; do
leader_map["$key"]=$value
has_been_leader["$key"]=0
done < <(echo "$response" | jq -r '.result | to_entries[] | "\(.key)=\(.value[0])"')
response=$(curl -s "$RPC_URL" -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0", "id": 1,
"method": "getEpochInfo"
}')
if [ -z "$response" ] || ! echo "$response" | jq -e '.result' > /dev/null; then
exit 1
fi
slot_index=$(echo "$response" | jq -r '.result.slotIndex // empty')
if [ -z "$slot_index" ]; then
exit 1
fi
all_keys_done=1
leaders_count=0
for key in "${!leader_map[@]}"; do
first_slot=${leader_map[$key]}
if (( slot_index > first_slot )); then
if [ "${has_been_leader[$key]}" -eq 0 ]; then
leaders_count=$((leaders_count + 1))
fi
has_been_leader["$key"]=1
fi
if [ "${has_been_leader[$key]}" -eq 0 ]; then
all_keys_done=0
fi
done
if [ "$all_keys_done" -eq 1 ] && (( leaders_count == 2 )); then
echo "All validators have been leaders. Exiting..."
break
fi
sleep 10
done
- name: clean up validators, ledger, and cluster artifacts
if: always()
run: |
if [ -f ${{ github.workspace }}/setup_fd_cluster.pid ]; then
kill $(cat ${{ github.workspace }}/setup_fd_cluster.pid) || true
sudo rm -rf ${{ github.workspace }}/setup_fd_cluster.pid
fi
if [ -f ${{ github.workspace }}/test_firedancer_leader.pid ]; then
kill $(cat ${{ github.workspace }}/test_firedancer_leader.pid) || true
sudo rm -rf ${{ github.workspace }}/test_firedancer_leader.pid
fi
sudo killall -9 -q solana-validator || true
sudo killall -9 -q agave-validator || true
sudo killall -9 -q fddev || true
sudo rm -rf ../*.so
sudo rm -rf ../test-ledger
sudo rm -rf setup_fd_cluster.log
sudo rm -rf test_firedancer_leader.log