Skip to content

Commit

Permalink
chore(target_chains/solana): add verifiable build script
Browse files Browse the repository at this point in the history
This change adds a Dockerfile based on Anchor's default verifiable
build dockerfile and a script to build the program using that
Dockerfile. The script also prints the sha256sum of the program which
can be used to verify on-chain deployments.
  • Loading branch information
ali-bahjati committed Mar 21, 2024
1 parent 4ffeb9f commit 8be4413
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions target_chains/solana/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.anchor
.DS_Store
target
artifacts
**/*.rs.bk
node_modules
lib
Expand Down
17 changes: 17 additions & 0 deletions target_chains/solana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Docker image to generate a deterministic build of the Pyth Solana Receiver
# program. This image extends backpackapp/build to support local dependencies
# outside the Cargo workspace of the program.
#

FROM backpackapp/build:v0.29.0@sha256:9aee169b2d8b89b4a4243419ae35c176773136e78d751b3e439eff692c9c1293

WORKDIR /workspace

COPY pythnet/pythnet_sdk pythnet/pythnet_sdk
COPY target_chains/solana target_chains/solana

WORKDIR /workspace/target_chains/solana

CMD ["bash", "-c", \
"anchor build -p pyth_solana_receiver --arch sbf && cp target/sbf-solana-solana/release/pyth_solana_receiver.so /artifacts/pyth_solana_receiver.so"]
19 changes: 19 additions & 0 deletions target_chains/solana/scripts/build_verifiable_program.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#/bin/bash

set -euo pipefail

# Root of the repository
REPO_ROOT=$(git rev-parse --show-toplevel)


echo "Building the image for the receiver program"
docker build --platform linux/x86_64 -t solana-receiver-builder -f $REPO_ROOT/target_chains/solana/Dockerfile $REPO_ROOT

echo "Building the receiver program"
docker run --platform linux/x86_64 --rm -v $REPO_ROOT/target_chains/solana/artifacts:/artifacts solana-receiver-builder

echo "Successfully built the receiver program."
echo "The artifacts are available at $REPO_ROOT/target_chains/solana/artifacts"

CHECKSUM=$(sha256sum $REPO_ROOT/target_chains/solana/artifacts/pyth_solana_receiver.so | awk '{print $1}')
echo "sha256sum of the pyth_solana_receiver program: $CHECKSUM"

0 comments on commit 8be4413

Please sign in to comment.