Skip to content

Commit

Permalink
tilt: m1 flag
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-gray committed Nov 29, 2024
1 parent 02cdf9e commit c018ec6
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 3 deletions.
15 changes: 14 additions & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ update_settings(max_parallel_updates = 10)
# Runtime configuration
config.define_bool("ci", False, "We are running in CI")
config.define_bool("manual", False, "Set TRIGGER_MODE_MANUAL by default")
config.define_bool("m1", False, "Build Solana from source for m1 arm64")

config.define_string("num", False, "Number of guardian nodes to run")

Expand Down Expand Up @@ -100,6 +101,7 @@ btc = cfg.get("btc", False)
redis = cfg.get('redis', ci)
generic_relayer = cfg.get("generic_relayer", ci)
query_server = cfg.get("query_server", ci)
m1 = cfg.get("m1", False)

if ci:
guardiand_loglevel = cfg.get("guardiand_loglevel", "warn")
Expand Down Expand Up @@ -463,12 +465,13 @@ k8s_resource(

if solana or pythnet:
# solana client cli (used for devnet setup)
dockerfile = "solana/Dockerfile.client"

docker_build(
ref = "bridge-client",
context = ".",
only = ["./proto", "./solana", "./clients"],
dockerfile = "solana/Dockerfile.client",
dockerfile = dockerfile,
# Ignore target folders from local (non-container) development.
ignore = ["./solana/*/target"],
)
Expand All @@ -485,6 +488,16 @@ if solana or pythnet:

# solana local devnet

dockerfile = "solana/Dockerfile.test-validator"
if m1:
dockerfile = "solana/Dockerfile.test-validator.m1"

docker_build(
ref = "solana-test-validator",
context = "solana",
dockerfile = dockerfile
)

k8s_yaml_with_ns("devnet/solana-devnet.yaml")

k8s_resource(
Expand Down
4 changes: 2 additions & 2 deletions devnet/solana-devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ spec:
terminationGracePeriodSeconds: 1
containers:
- name: devnet
image: solana-contract
image: solana-test-validator
command:
- /root/.local/share/solana/install/active_release/bin/solana-test-validator
- solana-test-validator
- --bpf-program
- Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o
- /opt/solana/deps/bridge.so
Expand Down
1 change: 1 addition & 0 deletions solana/Dockerfile.test-validator
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM solana-contract
36 changes: 36 additions & 0 deletions solana/Dockerfile.test-validator.m1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM solana-contract
FROM --platform=linux/arm64/v8 ubuntu:20.04@sha256:4489868cec4ea83f1e2c8e9f493ac957ec1451a63428dbec12af2894e6da4429

RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y curl wget libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev protobuf-compiler

# --default-toolchain must match https://github.com/anza-xyz/agave/blob/v2.0.17/rust-toolchain.toml
# alternatively, this could do something like the following
# RUN source solana/ci/rust-version.sh && \
# curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain "$rust_stable"
# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "1.78.0" && . $HOME/.cargo/env && rustup component add rustfmt
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "1.73.0" && . $HOME/.cargo/env && rustup component add rustfmt

ENV PATH=/root/.cargo/bin:$PATH

WORKDIR /build

# version 2.0.17 is incompatible with the existing devnet_setup.sh
# ENV solana_version=2.0.17
ENV solana_version=1.17.29

RUN wget https://github.com/anza-xyz/agave/archive/refs/tags/v${solana_version}.tar.gz

RUN tar -xf v${solana_version}.tar.gz

WORKDIR /build/agave-${solana_version}

# the full build OOMed with 24GB RAM allocated to Docker, so use --validator-only to slim it down and speed it up
# except that the following command apparently didn't build solana-test-validator
# RUN ./scripts/cargo-install-all.sh . --validator-only
# so just explicitly build solana-test-validator
RUN ./cargo build --profile release --bin solana-test-validator
RUN mkdir bin && cp target/release/solana-test-validator bin/solana-test-validator

ENV PATH=/build/agave-${solana_version}/bin:$PATH

COPY --from=solana-contract /opt/solana/deps/ /opt/solana/deps/
64 changes: 64 additions & 0 deletions solana/install_arm64_bpf_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash
set -ex

main() {
local out="$1"

# Copy rust build products
mkdir -p "${out}"/rust
cp -R "build/aarch64-unknown-linux-gnu/stage1/bin" "${out}"/rust/
mkdir -p "${out}"/rust/lib/rustlib/
cp -R "build/aarch64-unknown-linux-gnu/stage1/lib/rustlib/aarch64-unknown-linux-gnu" "${out}"/rust/lib/rustlib/
cp -R "build/aarch64-unknown-linux-gnu/stage1/lib/rustlib/bpfel-unknown-unknown" "${out}"/rust/lib/rustlib/
find . -maxdepth 6 -type f -path "./build/aarch64-unknown-linux-gnu/stage1/lib/*" -exec cp {} "${out}"/rust/lib \;

"${out}/rust/bin/rustc" --version
"${out}/rust/bin/rustdoc" --version

# Copy llvm build products
mkdir -p "${out}"/llvm/{bin,lib}
local binaries=(
clang
clang++
clang-cl
clang-cpp
clang-13
ld.lld
ld64.lld
llc
lld
lld-link
llvm-ar
llvm-objcopy
llvm-objdump
llvm-readelf
llvm-readobj
)
local bin
for bin in "${binaries[@]}"; do
local bin_file="build/aarch64-unknown-linux-gnu/llvm/build/bin/${bin}"
cp "${bin_file}" "${out}/llvm/bin"
done

cp -R "build/aarch64-unknown-linux-gnu/llvm/build/lib/clang" "${out}"/llvm/lib/

binaries=(
clang
clang++
clang-cl
clang-cpp
ld.lld
llc
lld-link
llvm-ar
llvm-objcopy
llvm-objdump
llvm-readelf
llvm-readobj
)
for bin in "${binaries[@]}"; do
"${out}/llvm/bin/${bin}" --version
done
}

main "$@"

0 comments on commit c018ec6

Please sign in to comment.