Skip to content

Commit

Permalink
check-size.sh: Revert extra arg; rearrange build-bpf.sh instead
Browse files Browse the repository at this point in the history
  • Loading branch information
drozdziak1 committed Oct 3, 2023
1 parent 22ee470 commit e8dcaf3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
8 changes: 4 additions & 4 deletions scripts/build-bpf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ cargo test --locked --features pythnet

cargo-build-bpf -- --locked -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort
sha256sum ./target/**/*.so
echo "Checking size of pyth_oracle.so for mainnet"
./scripts/check-size.sh 81760
mkdir -p target/pyth/solana/
mv target/deploy/pyth_oracle.so target/pyth/solana/pyth_oracle_solana.so
echo "Checking size of pyth_oracle.so for mainnet"
./scripts/check-size.sh 81760 target/pyth/solana/pyth_oracle_solana.so

cargo-build-bpf -- --locked -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --features pythnet
sha256sum ./target/**/*.so
echo "Checking size of pyth_oracle.so for pythnet"
./scripts/check-size.sh 88429
mkdir -p target/pyth/pythnet/
mv target/deploy/pyth_oracle.so target/pyth/pythnet/pyth_oracle_pythnet.so
echo "Checking size of pyth_oracle.so for pythnet"
./scripts/check-size.sh 88429 target/pyth/pythnet/pyth_oracle_pythnet.so
14 changes: 5 additions & 9 deletions scripts/check-size.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#!/usr/bin/env bash
#
set -e

max_size=$1
filename=${2:-./target/deploy/pyth_oracle.so}

# While Solana doesn't support resizing programs, the oracle binary needs to be smaller than 81760 bytes
# (The available space for the oracle program on pythnet is 88429 and mainnet is 81760)
ORACLE_SIZE=$(wc -c $filename | awk '{print $1}')
if [ $ORACLE_SIZE -lt ${max_size} ]
ORACLE_SIZE=$(wc -c ./target/deploy/pyth_oracle.so | awk '{print $1}')
if [ $ORACLE_SIZE -lt ${1} ]
then
echo "Size of ${filename} is small enough to be deployed, since ${ORACLE_SIZE} is less than ${max_size}"
echo "Size of pyth_oracle.so is small enough to be deployed, since ${ORACLE_SIZE} is less than ${1}"
else
echo "Size of ${filename} is too big to be deployed, since ${ORACLE_SIZE} is greater than ${max_size}"
echo "Size of pyth_oracle.so is too big to be deployed, since ${ORACLE_SIZE} is greater than ${1}"
exit 1
fi
fi

0 comments on commit e8dcaf3

Please sign in to comment.