Skip to content

Commit 8e6b796

Browse files
deployment: prewarm Cairo 1 compile cache in node_setup image (#14221)
sequencer_node_setup compiles its feature contracts on demand (the committed Cairo 1 artifacts were removed), but the slim runtime image had neither the compiler inputs nor a compiler, so it panicked on a missing allowed_libfuncs.json. Pre-warm the compilation cache in the builder stage (where the full source tree and toolchain exist) and copy target/blockifier_test_artifacts plus allowed_libfuncs.json into the final image, so the runtime hits the cache and needs no compiler. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2a24e6b commit 8e6b796

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

deployments/images/sequencer/node_setup.Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,30 @@ RUN cargo chef cook --recipe-path recipe.json --bin sequencer_node_setup
2020
COPY . .
2121
RUN cargo build --bin sequencer_node_setup
2222

23+
# Pre-warm the Cairo 1 compilation cache: sequencer_node_setup compiles its
24+
# feature contracts on demand, so run it here (full source tree + toolchain
25+
# present) to populate target/blockifier_test_artifacts, which the final stage
26+
# copies so the slim runtime image needs no compiler. The args mirror the
27+
# runtime invocation so the same cache keys are produced; the db/config output
28+
# is discarded.
29+
# PATH includes /app so the bootstrap step finds the anvil binary fetched above.
30+
RUN PATH="/app:$PATH" ./target/debug/sequencer_node_setup \
31+
--output-base-dir /tmp/cache_warmup_output \
32+
--data-prefix-path /tmp/cache_warmup_data \
33+
--n-distributed 0 --n-hybrid 0 --n-consolidated 1 \
34+
&& rm -rf /tmp/cache_warmup_output /tmp/cache_warmup_data
35+
2336
FROM ubuntu:24.04 AS final_stage
2437

2538
ENV ID=1001
2639
WORKDIR /app
2740
# Required crate for sequencer_node_setup to work
2841
COPY --from=builder /app/crates/blockifier_test_utils/resources ./crates/blockifier_test_utils/resources
42+
# Libfuncs allow-list read during Cairo 1 cache lookups; lives outside
43+
# blockifier_test_utils/resources, so copy it explicitly.
44+
COPY --from=builder /app/crates/apollo_compile_to_casm/src/allowed_libfuncs.json ./crates/apollo_compile_to_casm/src/allowed_libfuncs.json
45+
# Pre-warmed Cairo 1 compilation cache (see builder stage).
46+
COPY --from=builder /app/target/blockifier_test_artifacts ./target/blockifier_test_artifacts
2947
COPY --from=builder /app/target/debug/sequencer_node_setup ./target/debug/sequencer_node_setup
3048
COPY --from=builder /usr/bin/tini /usr/bin/tini
3149
COPY --from=builder /app/anvil /usr/bin/anvil

0 commit comments

Comments
 (0)