Skip to content

Commit

Permalink
solana/tilt: run registrations in parallel (#1826)
Browse files Browse the repository at this point in the history
Doing so reduces the time it takes to do the registrations from ~90s to
~9s, a 10x improvement.
  • Loading branch information
Csongor Kiss committed Oct 29, 2022
1 parent 0e643cd commit e3b3118
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
7 changes: 6 additions & 1 deletion solana/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ RUN if [ -e /certs/cert.pem ]; then cp /certs/cert.pem /etc/ssl/certs/ca-certifi
# Add bridge contract sources
WORKDIR /usr/src/bridge

COPY . .
COPY bridge bridge
COPY modules modules
COPY migration migration
COPY Cargo.toml Cargo.toml
COPY Cargo.lock Cargo.lock
COPY solitaire solitaire

ENV RUST_LOG="solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=trace,solana_bpf_loader=debug,solana_rbpf=debug"
ENV RUST_BACKTRACE=1
Expand Down
31 changes: 24 additions & 7 deletions solana/devnet_setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/usr/bin/env bash
# This script configures the devnet for test transfers with hardcoded addresses.
set -xu
set -eu

# kick off building worm in the background, and remember the process PID so we
# can wait on it later
make -C /usr/src/clients/js install &
worm_build_pid=$!

# Configure CLI (works the same as upstream Solana CLI)
mkdir -p ~/.config/solana/cli
Expand Down Expand Up @@ -92,22 +97,34 @@ retry token-bridge-client create-bridge "$token_bridge_address" "$bridge_address
# Initialize the NFT bridge
retry token-bridge-client create-bridge "$nft_bridge_address" "$bridge_address"

# pass the chain registration VAAs sourced from .env to the client's execute-governance command:
pushd /usr/src/clients/js
make install
echo "Waiting for worm to finish building"
wait $worm_build_pid

# next we get all the registration VAAs from the environment
# if a new VAA is added, this will automatically pick it up
VAAS=$(set | grep "REGISTER_.*_VAA" | grep -v SOL | cut -d '=' -f1)

# reset the builtin SECONDS timer (it's incremented once a second).
SECONDS=0

# use 'worm' to submit each registration VAA
echo "Running chain registrations in parallel"
# we'll send the registration calls in parallel, but we want to wait on them at
# the end, so we collect the PIDs
registration_pids=()
for VAA in $VAAS
do
VAA=${!VAA}
worm submit $VAA --chain solana --network devnet
worm submit $VAA --chain solana --network devnet &
registration_pids+=( $! )
done
echo "Registrations successful."
popd

# wait on registration calls
for pid in "${registration_pids[@]}"; do
wait $pid
done

echo "Registrations successfully completed in $SECONDS seconds."

# Let k8s startup probe succeed
nc -k -l -p 2000

0 comments on commit e3b3118

Please sign in to comment.