From 27f3c37ca2cb862d245c3efb6e31207ae23139f1 Mon Sep 17 00:00:00 2001 From: John Cairns Date: Fri, 18 Oct 2024 11:36:00 -0500 Subject: [PATCH] chore: use anagram risczero docker --- .devcontainer/devcontainer.json | 12 +++--- Dockerfile | 75 ++++++--------------------------- setup.sh | 5 ++- 3 files changed, 23 insertions(+), 69 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a93a058..c8fe761 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -14,20 +14,20 @@ "1YiB.rust-bundle" ] } + }, + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "version": "latest" + } } - // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], - // Uncomment the next line to run commands after the container is created. // "postCreateCommand": "cat /etc/os-release", - // Configure tool-specific properties. // "customizations": {}, - // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "devcontainer" -} +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6949866..f91d91f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,62 +1,15 @@ -# Development Container -# Stage 1: Build yamlfmt -FROM golang:1 AS go-builder -# defined from build kit -# DOCKER_BUILDKIT=1 docker build . -t ... -ARG TARGETARCH +# Bonsol Development Container +FROM ghcr.io/anagrambuild/risczero:latest -# Install yamlfmt -WORKDIR /yamlfmt -RUN go install github.com/google/yamlfmt/cmd/yamlfmt@latest && \ - strip $(which yamlfmt) && \ - yamlfmt --version - -# Stage 2: Rust Development Container -FROM rust:1-slim -ARG TARGETARCH - -# Install packages -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - binutils \ - ca-certificates \ - clang \ - cmake \ - curl \ - git \ - gnupg2 \ - libssl-dev \ - make \ - ninja-build \ - perl \ - pkg-config \ - protobuf-c-compiler \ - python3 \ - python3-pip \ - ripgrep \ - sudo \ - valgrind \ - && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -RUN echo "building platform $(uname -m)" - -# create dev user -RUN useradd --create-home --shell /bin/bash bonsol -RUN usermod -a -G sudo bonsol -RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -## Rust -ENV USER=bonsol -COPY --chown=${USER}:${USER} --from=go-builder /go/bin/yamlfmt /go/bin/yamlfmt -USER bonsol -ENV PATH=${PATH}:/go/bin +ENV USER=solana +ARG SOLANA=1.18.22 +ENV CARGO_HOME=/usr/local/cargo +ENV RUSTUP_HOME=/usr/local/rustup +ENV PATH=${PATH}:/usr/local/cargo/bin:/go/bin:/home/solana/.local/share/solana/install/releases/${SOLANA}/bin +USER solana # Set user and working directory ARG PACKAGE=bonsol -USER bonsol WORKDIR /workspaces/${PACKAGE} # Install Rust components @@ -65,14 +18,12 @@ RUN rustup component add \ clippy \ rust-analyzer -RUN cargo install cargo-binstall -RUN yes | cargo binstall cargo-risczero -RUN cargo risczero build-toolchain - -# Clean up -RUN rm -rf /home/bonsol/.cargo/registry /home/bonsol/.cargo/git -ENV PATH=${PATH}:/home/bonsol/.cargo/bin +# Risk0 Groth16 Prover +COPY --from=risczero/risc0-groth16-prover:v2024-05-17.1 /app/stark_verify /stark/stark_verify +COPY --from=risczero/risc0-groth16-prover:v2024-05-17.1 /app/stark_verify.dat /stark/stark_verify.dat +COPY --from=risczero/risc0-groth16-prover:v2024-05-17.1 /app/stark_verify_final.zkey /stark/stark_verify_final.zkey +COPY --from=risczero/risc0-groth16-prover:v2024-05-17.1 /usr/local/sbin/rapidsnark /stark/rapidsnark LABEL \ org.label-schema.name="bonsol" \ diff --git a/setup.sh b/setup.sh index 8327bbb..96239a3 100755 --- a/setup.sh +++ b/setup.sh @@ -1,6 +1,9 @@ #!/bin/zsh set -e -docker build -f setup.dockerfile -o node . +if [ ! -d "/stark/stark_verify" ]; then + docker build -f setup.dockerfile -o node . +fi + pnpx snarkjs zkey export verificationkey node/stark/stark_verify_final.zkey verification_key.json cd vkey pnpm i && pnpm run parse-vk ../verification_key.json ../onchain/channel/src/ && \