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 all 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
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ services:
ports:
- "$ESPRESSO_PROVER_SERVICE_PORT:$ESPRESSO_PROVER_SERVICE_PORT"
environment:
- ESPRESSO_PROVER_SERVICE_PORT
- ESPRESSO_STATE_RELAY_SERVER_URL
- ESPRESSO_SEQUENCER_ORCHESTRATOR_URL
- ESPRESSO_STATE_PROVER_UPDATE_INTERVAL
Expand Down Expand Up @@ -440,7 +441,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 \
&& 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.

13 changes: 8 additions & 5 deletions hotshot-state-prover/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,20 +385,23 @@ pub async fn run_prover_service<Ver: StaticVersionType + 'static>(
init_stake_table_from_orchestrator(&config.orchestrator_url, config.stake_table_capacity)
.await,
);
let proving_key = Arc::new(load_proving_key(config.stake_table_capacity));
let relay_server_client =
Arc::new(Client::<ServerError, Ver>::new(config.relay_server.clone()));
let config = Arc::new(config);
let update_interval = config.update_interval;

tracing::info!("Light client address: {:?}", config.light_client_address);
let relay_server_client =
Arc::new(Client::<ServerError, Ver>::new(config.relay_server.clone()));

// Start the HTTP server to get a functioning healthcheck before any heavy computations.
if let Some(port) = config.port {
if let Err(err) = start_http_server(port, config.light_client_address, bind_version) {
tracing::error!("Error starting http server: {}", err);
}
}

let proving_key = async_std::task::block_on(async move {
Arc::new(load_proving_key(config.stake_table_capacity))
});

let update_interval = config.update_interval;
loop {
let st = st.clone();
let proving_key = proving_key.clone();
Expand Down
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"
2 changes: 1 addition & 1 deletion scripts/build-docker-images
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ docker build -t ghcr.io/espressosystems/espresso-sequencer/sequencer:main -f doc
docker build -t ghcr.io/espressosystems/espresso-sequencer/commitment-task:main -f docker/commitment-task.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/submit-transactions:main -f docker/submit-transactions.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/deploy:main -f docker/deploy.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/permissionless-builder:main -f docker/permissionless-builder.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/builder:main -f docker/permissionless-builder.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/nasty-client:main -f docker/nasty-client.Dockerfile ${WORKDIR}
31 changes: 21 additions & 10 deletions scripts/build-docker-images-native
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,43 @@ 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 and git directory are 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 "$CARGO_HOME/registry:/usr/local/cargo/registry" \
-v "$CARGO_HOME/git:/usr/local/cargo/git" \
-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 All @@ -90,5 +101,5 @@ docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/commitment-task:main -f docker/commitment-task.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/submit-transactions:main -f docker/submit-transactions.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/deploy:main -f docker/deploy.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/permissionless-builder:main -f docker/permissionless-builder.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/builder:main -f docker/permissionless-builder.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/nasty-client:main -f docker/nasty-client.Dockerfile ${WORKDIR}
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