Skip to content

Commit

Permalink
Start solana by downloading from the solanalabs repo rather than usin…
Browse files Browse the repository at this point in the history
…g the base docker image

This is to perhaps in preparation of supporting an arm64 build where this shape is much better. I think this might be much slower, so the attempt might have to just be reverted, but lets see.
  • Loading branch information
ml-james committed Oct 8, 2024
1 parent 11ad1d7 commit 8329766
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.testcontainers.utility.MountableFile;

import java.nio.file.Path;
import java.time.Duration;

public abstract class IntegrationTestBase
{
Expand All @@ -24,12 +25,14 @@ public abstract class IntegrationTestBase
{
SOLANA_VALIDATOR = new GenericContainer<>(new ImageFromDockerfile().withDockerfile(Path.of(MountableFile.forClasspathResource("Dockerfile").getFilesystemPath())))
.withCopyFileToContainer(MountableFile.forClasspathResource("solana-run.sh"), "/solana-run.sh")
.withCopyFileToContainer(MountableFile.forClasspathResource("fetch-spl.sh"), "/fetch-spl.sh")
.withCopyFileToContainer(MountableFile.forClasspathResource("lmax_multisig.so"), "/lmax_multisig.so")
.withCopyFileToContainer(MountableFile.forClasspathResource("upgrade_authority.json"), "/upgrade_authority.json")
.withCopyFileToContainer(MountableFile.forClasspathResource("bpf_program.json"), "/bpf_program.json")
.withExposedPorts(SOLANA_HTTP_PORT, SOLANA_WS_PORT)
.withEnv("SOLANA_RUN_SH_VALIDATOR_ARGS", "--ticks-per-slot=8")
.withNetwork(NETWORK);
.withNetwork(NETWORK)
.withStartupTimeout(Duration.ofMinutes(2));

SOLANA_VALIDATOR.start();
}
Expand Down
19 changes: 17 additions & 2 deletions src/integration-test/resources/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
FROM solanalabs/solana:v1.17.34
FROM ubuntu:20.04

USER root

COPY solana-run.sh /usr/bin/solana-run.sh
RUN apt-get update && apt-get install -y wget curl

ENV SOLANA_VERSION v1.18.25
ENV SOLANA_TAR solana-release-x86_64-unknown-linux-gnu.tar.bz2
ENV SOLANA_URL https://github.com/solana-labs/solana/releases/download/$SOLANA_VERSION/$SOLANA_TAR

RUN wget $SOLANA_URL

RUN tar -xvjf $SOLANA_TAR
RUN rm -f $SOLANA_TAR

RUN mv solana-release/bin/* /usr/local/bin/

COPY solana-run.sh /usr/bin/solana-run.sh
RUN chmod +x /usr/bin/solana-run.sh

COPY fetch-spl.sh /usr/bin/fetch-spl.sh
RUN chmod +x /usr/bin/fetch-spl.sh

ENTRYPOINT ["/usr/bin/solana-run.sh"]
62 changes: 62 additions & 0 deletions src/integration-test/resources/fetch-spl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
#
# Fetches the latest SPL programs and produces the solana-genesis command-line
# arguments needed to install them
#

set -e

upgradeableLoader=BPFLoaderUpgradeab1e11111111111111111111111

fetch_program() {
declare name=$1
declare version=$2
declare address=$3
declare loader=$4

declare so=spl_$name-$version.so

if [[ $loader == "$upgradeableLoader" ]]; then
genesis_args+=(--upgradeable-program "$address" "$loader" "$so" none)
else
genesis_args+=(--bpf-program "$address" "$loader" "$so")
fi

if [[ -r $so ]]; then
return
fi

if [[ -r ~/.cache/solana-spl/$so ]]; then
cp ~/.cache/solana-spl/"$so" "$so"
else
echo "Downloading $name $version"
so_name="spl_${name//-/_}.so"
(
set -x
curl -L --retry 5 --retry-delay 2 --retry-connrefused \
-o "$so" \
"https://github.com/solana-labs/solana-program-library/releases/download/$name-v$version/$so_name"
)

mkdir -p ~/.cache/solana-spl
cp "$so" ~/.cache/solana-spl/"$so"
fi

}

fetch_program token 3.5.0 TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA BPFLoader2111111111111111111111111111111111
fetch_program token-2022 0.9.0 TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb BPFLoaderUpgradeab1e11111111111111111111111
fetch_program memo 1.0.0 Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo BPFLoader1111111111111111111111111111111111
fetch_program memo 3.0.0 MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr BPFLoader2111111111111111111111111111111111
fetch_program associated-token-account 1.1.2 ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL BPFLoader2111111111111111111111111111111111
fetch_program feature-proposal 1.0.0 Feat1YXHhH6t1juaWF74WLcfv4XoNocjXA6sPWHNgAse BPFLoader2111111111111111111111111111111111

echo "${genesis_args[@]}" > spl-genesis-args.sh

echo
echo "Available SPL programs:"
ls -l spl_*.so

echo
echo "solana-genesis command-line arguments (spl-genesis-args.sh):"
cat spl-genesis-args.sh

0 comments on commit 8329766

Please sign in to comment.