Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put SRS file into docker image #1366

Merged
merged 11 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ services:
healthcheck:
# Postgres can be falsely "ready" once before running init scripts.
# See https://github.com/docker-library/postgres/issues/146 for discussion.
test: "pg_isready && sleep 1 && pg_isready"
test: "pg_isready -U root && sleep 1 && pg_isready -U root"
interval: 5s
timeout: 4s
retries: 20
4 changes: 4 additions & 0 deletions docker/permissionless-builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["tini", "--"]

# Download an SRS file to avoid download at runtime
ENV AZTEC_SRS_PATH=/kzg10-aztec20-srs-1048584.bin
RUN curl -LO https://github.com/EspressoSystems/ark-srs/releases/download/v0.2.0/$AZTEC_SRS_PATH

COPY target/$TARGETARCH/release/permissionless-builder /bin/permissionless-builder
RUN chmod +x /bin/permissionless-builder

Expand Down
6 changes: 5 additions & 1 deletion docker/prover-service.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ FROM ubuntu:jammy
ARG TARGETARCH

RUN apt-get update \
&& apt-get install -y curl git libcurl4 wait-for-it tini jq \
&& apt-get install -y curl libcurl4 wait-for-it tini jq \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["tini", "--"]

# Download an SRS file to avoid download at runtime
ENV AZTEC_SRS_PATH=/kzg10-aztec20-srs-1048584.bin
RUN curl -LO https://github.com/EspressoSystems/ark-srs/releases/download/v0.2.0/$AZTEC_SRS_PATH

# copy the binaries
COPY target/$TARGETARCH/release/state-prover /usr/local/bin/state-prover
RUN chmod +x /usr/local/bin/state-prover
Expand Down
4 changes: 4 additions & 0 deletions docker/sequencer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["tini", "--"]

# Download an SRS file to avoid download at runtime
ENV AZTEC_SRS_PATH=/kzg10-aztec20-srs-1048584.bin
RUN curl -LO https://github.com/EspressoSystems/ark-srs/releases/download/v0.2.0/$AZTEC_SRS_PATH

COPY target/$TARGETARCH/release/sequencer /bin/sequencer
RUN chmod +x /bin/sequencer

Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.76.0"
channel = "stable"
components = ["rustfmt", "llvm-tools-preview", "rust-src", "clippy"]
profile = "minimal"
27 changes: 18 additions & 9 deletions scripts/build-docker-images-native
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,41 @@ case $KERNEL in
cargo build --release
;;
darwin)
# Build in docker container
# Use a different target directory for docker builds to avoid conflicts with
# native builds.
CARGO_TARGET_DIR=target/docker

# Build in docker container:
# - RUSTFLAGS is needed for compilation.
# - CARGO_TARGET_DIR is set to point to the location where
# the hosts CARGO_TARGET_DIR is mounted.
# - PWD is mounted to /work.
# - Cargo registry is mounted to avoid re-downloading dependencies.
docker run \
-e RUST_LOG -e RUST_BACKTRACE -e RUSTFLAGS -e CARGO_TARGET_DIR \
-v $(pwd):/work \
-v $HOME/.cargo/registry:/root/.cargo/registry \
-e RUSTFLAGS \
-e CARGO_TARGET_DIR=/work/target/docker \
-v "$(pwd):/work" \
-v "$HOME/.cargo/registry:/usr/local/cargo/registry" \
-it ghcr.io/espressosystems/devops-rust:stable \
bash -c "cd /work && cargo build --release"
;;
esac

# Copy binaries to a temporary directory.
WORKDIR=$(mktemp -d -t espresso-docker-build-XXXXXXXX)
CONTRACTS_DIR="./contracts"

trap "exit" INT TERM
trap cleanup EXIT
cleanup(){
rm -rfv ${WORKDIR}
rm -rfv "${WORKDIR}"
}

mkdir -p ${WORKDIR}/target/$ARCH/release
mkdir -p "${WORKDIR}/target/$ARCH/release"
for binary in "orchestrator" "cdn-broker" "cdn-marshal" "sequencer" "commitment-task" "submit-transactions" "reset-storage" "state-relay-server" "state-prover" "deploy" "keygen" "permissionless-builder" "nasty-client"; do
cp -v "${CARGO_TARGET_DIR}/release/$binary" ${WORKDIR}/target/$ARCH/release
cp -v "${CARGO_TARGET_DIR}/release/$binary" "${WORKDIR}/target/$ARCH/release"
# Patch the interpreter for running without nix inside the ubuntu based docker image.
if [ $KERNEL == "linux" ]; then
patchelf --set-interpreter $INTERPRETER ${WORKDIR}/target/$ARCH/release/$binary
patchelf --set-interpreter "$INTERPRETER" "${WORKDIR}/target/$ARCH/release/$binary"
fi
done

Expand Down
6 changes: 5 additions & 1 deletion sequencer/src/bin/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ async fn main() -> anyhow::Result<()> {
}

if let Some(out) = &opt.out {
let file = File::options().create(true).write(true).open(out)?;
let file = File::options()
.create(true)
.truncate(true)
.write(true)
.open(out)?;
contracts.write(file)?;
} else {
contracts.write(stdout())?;
Expand Down
6 changes: 5 additions & 1 deletion sequencer/src/bin/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ fn main() -> anyhow::Result<()> {
tracing::info!("generating new key set");

let path = opts.out.join(format!("{index}.env"));
let mut file = File::options().write(true).create(true).open(&path)?;
let mut file = File::options()
.write(true)
.create(true)
.truncate(true)
.open(&path)?;
opts.scheme.gen(seed, index as u64, &mut file)?;

tracing::info!("private keys written to {}", path.display());
Expand Down
2 changes: 1 addition & 1 deletion sequencer/src/block/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ mod test {

fn check_basic_correctness<TableWord: TableWordTraits>() {
// play with this
let test_cases = vec![
let test_cases = [
// 1 namespace only
vec![vec![5, 8, 8]], // 3 non-empty txs
vec![vec![0, 8, 8]], // 1 empty tx at the beginning
Expand Down
Loading