Skip to content

Commit

Permalink
ci: firedancer full client integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
kbhargava-jump committed Nov 20, 2024
1 parent 58b2d52 commit 70a0f7b
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 52 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ jobs:
uses: ./.github/workflows/codeql.yml
permissions:
security-events: write
firedancer:
# if: github.event.pull_request.draft == false
uses: ./.github/workflows/test_firedancer_localnet.yml
secrets: inherit
41 changes: 0 additions & 41 deletions .github/workflows/test_firedancer.yml

This file was deleted.

171 changes: 171 additions & 0 deletions .github/workflows/test_firedancer_localnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
2 changes: 1 addition & 1 deletion contrib/test/setup_fd_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euxo pipefail
IFS=$'\n\t'

PRIMARY_IP=$(ip -o -4 addr show scope global | awk '{ print $4 }' | cut -d/ -f1)
PRIMARY_IP=$(ip -o -4 addr show scope global | awk '{ print $4 }' | cut -d/ -f1 | head -n 1)
RPC_URL="http://$PRIMARY_IP:8899/"
AGAVE_PATH=${AGAVE_PATH:='./agave/target/release'}

Expand Down
4 changes: 2 additions & 2 deletions contrib/test/setup_fd_cluster_stakes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ IFS=$'\n\t'

cd ../test-ledger

PRIMARY_IP=$(ip -o -4 addr show scope global | awk '{ print $4 }' | cut -d/ -f1)
PRIMARY_IP=$(ip -o -4 addr show scope global | awk '{ print $4 }' | cut -d/ -f1 | head -n1)
# RPC_URL="http:/n/$PRIMARY_IP:8899/"
RPC_URL="http://localhost:8899/"
AGAVE_PATH=${AGAVE_PATH:='./agave/target/release'}
Expand All @@ -22,7 +22,7 @@ solana -u $RPC_URL --keypair fd-identity-keypair.json delegate-stake fd-stake-ke
solana -u $RPC_URL --keypair fd-identity-keypair.json vote-account fd-vote-keypair.json
solana -u $RPC_URL --keypair fd-identity-keypair.json stake-account fd-stake-keypair.json

exit 1
exit 0
solana-keygen new --no-bip39-passphrase --silent --outfile fd-identity-keypair-2.json
solana-keygen new --no-bip39-passphrase --silent --outfile fd-stake-keypair-2.json
solana-keygen new --no-bip39-passphrase --silent --outfile fd-vote-keypair-2.json
Expand Down
18 changes: 10 additions & 8 deletions contrib/test/test_firedancer_leader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ cd ../test-ledger/

FD_DIR="$SCRIPT_DIR/../.."

OBJDIR=${OBJDIR:-build/native/${CC}}

cleanup() {
sudo killall -9 -q fddev || true
$FD_DIR/build/native/$CC/bin/fddev configure fini all
$FD_DIR/$OBJDIR/bin/fddev configure fini all
}
trap cleanup EXIT SIGINT SIGTERM

sudo killall -9 -q fddev || true

# if fd_frank_ledger is not on path then use the one in the home directory
if ! command -v fddev > /dev/null; then
PATH="$FD_DIR/build/native/$CC/bin":$PATH
PATH="$FD_DIR/$OBJDIR/bin":$PATH
fi

_PRIMARY_INTERFACE=$(ip route show default | awk '/default/ {print $5}')
Expand Down Expand Up @@ -82,10 +84,10 @@ name = \"fd1\"
vote_account_path = \"fd-vote-keypair.json\"
" > fddev.toml

sudo $FD_DIR/build/native/$CC/bin/fddev configure init kill --config $(readlink -f fddev.toml)
sudo $FD_DIR/build/native/$CC/bin/fddev configure init hugetlbfs --config $(readlink -f fddev.toml)
sudo $FD_DIR/build/native/$CC/bin/fddev configure init ethtool-channels --config $(readlink -f fddev.toml)
sudo $FD_DIR/build/native/$CC/bin/fddev configure init ethtool-gro --config $(readlink -f fddev.toml)
sudo $FD_DIR/build/native/$CC/bin/fddev configure init keys --config $(readlink -f fddev.toml)
sudo $FD_DIR/$OBJDIR/bin/fddev configure init kill --config $(readlink -f fddev.toml)
sudo $FD_DIR/$OBJDIR/bin/fddev configure init hugetlbfs --config $(readlink -f fddev.toml)
sudo $FD_DIR/$OBJDIR/bin/fddev configure init ethtool-channels --config $(readlink -f fddev.toml)
sudo $FD_DIR/$OBJDIR/bin/fddev configure init ethtool-gro --config $(readlink -f fddev.toml)
sudo $FD_DIR/$OBJDIR/bin/fddev configure init keys --config $(readlink -f fddev.toml)

sudo gdb -iex="set debuginfod enabled on" -ex=r --args $FD_DIR/build/native/$CC/bin/fddev dev --no-configure --log-path $(readlink -f fddev.log) --config $(readlink -f fddev.toml) --no-solana --no-sandbox --no-clone
sudo gdb -iex="set debuginfod enabled on" -ex=r --args $FD_DIR/$OBJDIR/bin/fddev dev --no-configure --log-path $(readlink -f fddev.log) --config $(readlink -f fddev.toml) --no-solana --no-sandbox --no-clone

0 comments on commit 70a0f7b

Please sign in to comment.