From 22ee4704d4e59d92d3225d333ef53661700c58e4 Mon Sep 17 00:00:00 2001 From: Stan Drozd Date: Tue, 3 Oct 2023 16:06:04 +0200 Subject: [PATCH 1/2] scripts: Move contract binaries to target/pyth/{solana|pythnet} This change attempts to provide both contract flavors as a result of the Docker build. Making both available will help with completing deployment to both environments. --- scripts/build-bpf.sh | 8 ++++++-- scripts/check-size.sh | 14 +++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/build-bpf.sh b/scripts/build-bpf.sh index 3fb2ea543..619534e04 100755 --- a/scripts/build-bpf.sh +++ b/scripts/build-bpf.sh @@ -26,10 +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 +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 +./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 +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 +./scripts/check-size.sh 88429 target/pyth/pythnet/pyth_oracle_pythnet.so diff --git a/scripts/check-size.sh b/scripts/check-size.sh index bf3fe541b..7a7b0aad8 100755 --- a/scripts/check-size.sh +++ b/scripts/check-size.sh @@ -1,13 +1,17 @@ #!/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 ./target/deploy/pyth_oracle.so | awk '{print $1}') -if [ $ORACLE_SIZE -lt ${1} ] +ORACLE_SIZE=$(wc -c $filename | awk '{print $1}') +if [ $ORACLE_SIZE -lt ${max_size} ] then - echo "Size of pyth_oracle.so is small enough to be deployed, since ${ORACLE_SIZE} is less than ${1}" + echo "Size of ${filename} is small enough to be deployed, since ${ORACLE_SIZE} is less than ${max_size}" else - echo "Size of pyth_oracle.so is too big to be deployed, since ${ORACLE_SIZE} is greater than ${1}" + echo "Size of ${filename} is too big to be deployed, since ${ORACLE_SIZE} is greater than ${max_size}" exit 1 -fi \ No newline at end of file +fi From e8dcaf3bae119e627379e019f469190392fb1752 Mon Sep 17 00:00:00 2001 From: Stan Drozd Date: Tue, 3 Oct 2023 16:17:40 +0200 Subject: [PATCH 2/2] check-size.sh: Revert extra arg; rearrange build-bpf.sh instead --- scripts/build-bpf.sh | 8 ++++---- scripts/check-size.sh | 14 +++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/scripts/build-bpf.sh b/scripts/build-bpf.sh index 619534e04..41fc82739 100755 --- a/scripts/build-bpf.sh +++ b/scripts/build-bpf.sh @@ -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 diff --git a/scripts/check-size.sh b/scripts/check-size.sh index 7a7b0aad8..bf3fe541b 100755 --- a/scripts/check-size.sh +++ b/scripts/check-size.sh @@ -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 \ No newline at end of file