Skip to content

Commit

Permalink
Update docker prep script to download from mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Oct 15, 2023
1 parent 4dfb710 commit e1274f8
Showing 1 changed file with 71 additions and 47 deletions.
118 changes: 71 additions & 47 deletions prepare-local-docker-env.sh
Original file line number Diff line number Diff line change
@@ -1,47 +1,71 @@
#!/usr/bin/env bash

CWD=$(pwd)
mkdir programs
mkdir metaplex_program_library || true
curl -LkSs https://api.github.com/repos/metaplex-foundation/metaplex-program-library/tarball/update-deps | tar -xz --strip-components=1 -C ./metaplex_program_library

pushd metaplex_program_library/token-metadata/program
cargo build-bpf --bpf-out-dir ./here
mv ./here/mpl_token_metadata.so $CWD/programs/metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s.so
popd

pushd metaplex_program_library/bubblegum/program
cargo build-bpf --bpf-out-dir ./here
mv ./here/mpl_bubblegum.so $CWD/programs/BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY.so
popd

mkdir solana_program_library || true
curl -LkSs https://api.github.com/repos/solana-labs/solana-program-library/tarball/token-swap-js-v0.4.0 | tar -xz --strip-components=1 -C ./solana_program_library
tar -zxf -C /solana_program_library solana-program-library.tar.gz
pushd solana_program_library/account-compression/programs/account-compression
cargo build-bpf --bpf-out-dir ./here
mv ./here/spl_account_compression.so $CWD/programs/cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK.so
popd

pushd solana_program_library/account-compression/programs/noop
cargo build-bpf --bpf-out-dir ./here
mv ./here/spl_noop.so $CWD/programs/noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV.so
popd

pushd solana_program_library/associated-token-account/program
cargo build-bpf --bpf-out-dir ./here
mv ./here/spl_associated_token_account.so $CWD/programs/ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL.so
popd

pushd solana_program_library/token/program
cargo build-bpf --bpf-out-dir ./here
mv ./here/spl_token.so $CWD/programs/TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA.so
popd

pushd solana_program_library/token/program-2022
cargo build-bpf --bpf-out-dir ./here
mv ./here/spl_token_2022.so $CWD/programs/TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb.so
popd

rm -rf solana_program_library
rm -rf metaplex_program_library
#!/bin/bash

# output colours
RED() { echo $'\e[1;31m'$1$'\e[0m'; }
GRN() { echo $'\e[1;32m'$1$'\e[0m'; }

CURRENT_DIR=$(pwd)
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
# go to parent folder
cd $(dirname $(dirname $SCRIPT_DIR))

EXTERNAL_ID=("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" \
"BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY" \
"cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK" \
"noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV" \
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" \
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" \
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" \
)
EXTERNAL_SO=("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s.so" \
"BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY.so" \
"cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK.so" \
"noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV.so"
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL.so" \
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA.so" \
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb.so" \
)

if [ -z ${RPC+x} ]; then
RPC="https://api.mainnet-beta.solana.com"
fi

if [ -z "$OUTPUT" ]; then
OUTPUT=$CURRENT_DIR/programs
fi

# creates the output directory if it doesn't exist
if [ ! -d ${OUTPUT} ]; then
mkdir ${OUTPUT}
fi

# only prints this if we have external programs
if [ ${#EXTERNAL_ID[@]} -gt 0 ]; then
echo "Dumping external programs to: '${OUTPUT}'"
fi

# dump external programs binaries if needed
for i in ${!EXTERNAL_ID[@]}; do
if [ ! -f "${OUTPUT}/${EXTERNAL_SO[$i]}" ]; then
solana program dump -u $RPC ${EXTERNAL_ID[$i]} ${OUTPUT}/${EXTERNAL_SO[$i]}
else
solana program dump -u $RPC ${EXTERNAL_ID[$i]} ${OUTPUT}/onchain-${EXTERNAL_SO[$i]} > /dev/null
ON_CHAIN=`sha256sum -b ${OUTPUT}/onchain-${EXTERNAL_SO[$i]} | cut -d ' ' -f 1`
LOCAL=`sha256sum -b ${OUTPUT}/${EXTERNAL_SO[$i]} | cut -d ' ' -f 1`

if [ "$ON_CHAIN" != "$LOCAL" ]; then
echo $(RED "[ WARNING ] on-chain and local binaries are different for '${EXTERNAL_SO[$i]}'")
else
echo "$(GRN "[ SKIPPED ]") on-chain and local binaries are the same for '${EXTERNAL_SO[$i]}'"
fi

rm ${OUTPUT}/onchain-${EXTERNAL_SO[$i]}
fi
done

# only prints this if we have external programs
if [ ${#EXTERNAL_ID[@]} -gt 0 ]; then
echo ""
fi

cd ${CURRENT_DIR}

0 comments on commit e1274f8

Please sign in to comment.