-
Notifications
You must be signed in to change notification settings - Fork 3
feat(asm-runner): docker image #115
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
Draft
prajwolrg
wants to merge
2
commits into
main
Choose a base branch
from
feat-asm-runner-dockerfile
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| .git | ||
| .gitignore | ||
|
|
||
| .github/ | ||
|
|
||
| target/ | ||
|
|
||
| *.log* | ||
| *.tmp | ||
| *.temp | ||
| *.swp | ||
| *.swo | ||
|
|
||
| *.env | ||
| *.local | ||
|
|
||
| *.idea/ | ||
| *.vscode/ | ||
| *.DS_Store | ||
|
|
||
| .codex/ | ||
| .claude/ | ||
|
|
||
| docker/vol/*/data/ | ||
| docker/vol/*/proof_db/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # ASM Docker Setup | ||
|
|
||
| A single Dockerfile produces two image variants via `--target`: | ||
|
|
||
| - `native` (default): runner built without SP1. | ||
| - `sp1`: runner built with `--features sp1`, with the SP1 guest ELFs baked in at `/app/elfs/`. | ||
|
|
||
| Both variants are two-stage builds: Ubuntu 24.04 with the project's pinned Rust toolchain (from `rust-toolchain.toml`) compiles `strata-asm-runner`, and the binary ships on a slim Ubuntu 24.04 runtime. | ||
|
|
||
| ## Prover modes | ||
|
|
||
| The runner has three prover modes, selected by the config file at runtime: | ||
|
|
||
| | Mode | Config | `native` image | `sp1` image | | ||
| | ------ | --------------------------------------------------- | -------------- | ----------- | | ||
| | none | omit `[orchestrator]` | yes | yes | | ||
| | native | `orchestrator.backend.kind = "native"` | yes | yes | | ||
| | sp1 | `orchestrator.backend.kind = "sp1"` | no | yes | | ||
|
|
||
| ## Building the native image | ||
|
|
||
| From the repository root: | ||
|
|
||
| ```sh | ||
| docker build -f docker/asm-runner/Dockerfile -t strata-asm-runner:native . | ||
| ``` | ||
|
|
||
| ## Building the SP1 image | ||
|
|
||
| The SP1 guest ELFs are compiled **outside** the docker build (host or CI runner with the SP1 toolchain installed via `sp1up`) and staged into the build context. The image build itself does not install the SP1 toolchain — this matches the pattern alpen uses for its strata image. | ||
|
|
||
| ```sh | ||
| # 1. Build the guest ELFs locally (requires the SP1 toolchain). | ||
| cargo b -r -p strata-asm-sp1-guest-builder | ||
|
|
||
| # 2. Stage them into the build context. | ||
| mkdir -p docker/asm-runner/artifacts/elfs | ||
| cp guest-builder/sp1/elfs/asm.elf docker/asm-runner/artifacts/elfs/ | ||
| cp guest-builder/sp1/elfs/moho.elf docker/asm-runner/artifacts/elfs/ | ||
|
|
||
| # 3. Build the image targeting the sp1 stage. | ||
| docker build -f docker/asm-runner/Dockerfile \ | ||
| --target sp1 --build-arg CARGO_FEATURES=sp1 \ | ||
| -t strata-asm-runner:sp1 . | ||
| ``` | ||
|
|
||
| In `config.toml`, point the SP1 backend at the baked-in ELFs: | ||
|
|
||
| ```toml | ||
| [orchestrator.backend] | ||
| kind = "sp1" | ||
| asm_elf_path = "/app/elfs/asm.elf" | ||
| moho_elf_path = "/app/elfs/moho.elf" | ||
| ``` | ||
|
|
||
| ## Running | ||
|
|
||
| The default `CMD` points at `/app/config.toml` and `/app/asm-params.json`. The runner doesn't validate the params up front — any misconfiguration surfaces as a runtime failure from the binary itself. | ||
|
|
||
| Mount the config and params from the host: | ||
|
|
||
| ```sh | ||
| docker run --rm \ | ||
| -v "$PWD/config.toml:/app/config.toml:ro" \ | ||
| -v "$PWD/asm-params.json:/app/asm-params.json:ro" \ | ||
| -v "$PWD/data:/app/data" \ | ||
| -p 9010:9010 \ | ||
| strata-asm-runner:native | ||
| ``` | ||
|
|
||
| Override the paths by passing flags directly: | ||
|
|
||
| ```sh | ||
| docker run --rm \ | ||
| -v "$PWD/conf:/conf:ro" \ | ||
| strata-asm-runner:native --config /conf/my.toml --params /conf/my.json | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| # warning: run from repo root, NOT inside this dir | ||
| # | ||
| # Builds strata-asm-runner. The runner supports three prover modes selected by | ||
| # config (see docker/README.md): | ||
| # - none: `[orchestrator]` omitted entirely | ||
| # - native: `orchestrator.backend.kind = "native"` | ||
| # - sp1: `orchestrator.backend.kind = "sp1"` | ||
| # | ||
| # Two image variants are produced from a single Dockerfile via `--target`: | ||
| # - `native` (default): runner built without SP1; only the `none` and | ||
| # `native` prover modes work. | ||
| # - `sp1`: runner built with `--features sp1`; the SP1 guest ELFs | ||
| # (`asm.elf`, `moho.elf`) must be staged at | ||
| # `docker/asm-runner/artifacts/elfs/` in the build context — they are | ||
| # compiled outside docker (host or CI runner with `sp1up`), matching the | ||
| # pattern alpen uses for its strata image. The image build itself does | ||
| # NOT install the SP1 toolchain. | ||
| # | ||
| # Examples: | ||
| # docker build -f docker/asm-runner/Dockerfile -t strata-asm-runner:native . | ||
| # | ||
| # cargo b -r -p strata-asm-sp1-guest-builder | ||
| # mkdir -p docker/asm-runner/artifacts/elfs | ||
| # cp guest-builder/sp1/elfs/{asm,moho}.elf docker/asm-runner/artifacts/elfs/ | ||
| # docker build -f docker/asm-runner/Dockerfile \ | ||
| # --target sp1 --build-arg CARGO_FEATURES=sp1 \ | ||
| # -t strata-asm-runner:sp1 . | ||
| FROM --platform=linux/amd64 ubuntu:24.04 AS builder | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Optional comma-separated cargo features (e.g. "sp1"). Applied to the runner | ||
| # build below. | ||
| ARG CARGO_FEATURES="" | ||
|
|
||
| ENV CARGO_INCREMENTAL=0 | ||
| ENV CARGO_TERM_COLOR=always | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| ENV PATH=/root/.cargo/bin:$PATH | ||
| # The guest-builder crate's build.rs gets compiled as part of the workspace | ||
| # metadata pass even when building `-p strata-asm-runner`. Guest ELFs are | ||
| # always supplied externally (see sp1 target below), so skip the in-build | ||
| # guest compilation — otherwise the build would need the SP1 toolchain. | ||
| ENV SP1_SKIP_PROGRAM_BUILD=true | ||
|
|
||
| RUN apt-get update && \ | ||
| apt-get -y upgrade && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| pkg-config \ | ||
| build-essential \ | ||
| protobuf-compiler \ | ||
| git \ | ||
| curl \ | ||
| ca-certificates && \ | ||
| apt-get clean && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install rustup with no default toolchain; `rust-toolchain.toml` pins the | ||
| # exact version and `rustup show` materializes it. | ||
| RUN curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs \ | ||
| | sh -s -- -y --default-toolchain none --profile minimal | ||
|
|
||
| COPY rust-toolchain.toml rust-toolchain.toml | ||
| RUN rustup show && cargo --version | ||
|
|
||
| COPY . . | ||
|
|
||
| # Build the binary and lift it out of the cache-mounted target dir so it | ||
| # persists into the layer. | ||
| RUN --mount=type=cache,target=/root/.cargo/registry \ | ||
| --mount=type=cache,target=/root/.cargo/git \ | ||
| --mount=type=cache,target=/app/target \ | ||
| cargo b -r -p strata-asm-runner \ | ||
| ${CARGO_FEATURES:+--features "$CARGO_FEATURES"} && \ | ||
| cp /app/target/release/strata-asm-runner /usr/local/bin/strata-asm-runner | ||
|
|
||
| FROM --platform=linux/amd64 ubuntu:24.04 AS runtime-base | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| RUN apt-get update && \ | ||
| apt-get upgrade -y && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| ca-certificates && \ | ||
| apt-get clean && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY --from=builder /usr/local/bin/strata-asm-runner /usr/local/bin/strata-asm-runner | ||
|
|
||
| ENTRYPOINT ["/usr/local/bin/strata-asm-runner"] | ||
| CMD ["--config", "/app/config.toml", "--params", "/app/asm-params.json"] | ||
|
|
||
| # SP1 variant: adds the pre-built guest ELFs. Point | ||
| # `orchestrator.backend.sp1.{asm,moho}_elf_path` at /app/elfs/{asm,moho}.elf | ||
| # from config.toml. | ||
| FROM runtime-base AS sp1 | ||
| COPY docker/asm-runner/artifacts/elfs/asm.elf /app/elfs/asm.elf | ||
| COPY docker/asm-runner/artifacts/elfs/moho.elf /app/elfs/moho.elf | ||
|
|
||
| # Default target: native-only runtime. Listed last so plain `docker build` | ||
| # (without `--target`) produces the non-SP1 image. | ||
| FROM runtime-base AS native |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This table says a
sp1image can runorchestrator.backend.kind = "native", but the runner code does not support that combination: inbin/asm-runner/src/prover/backend.rs, enabling thesp1feature makesProofHost = SP1Host, and the#[cfg(feature = "sp1")]build_native_hostspath immediately bails withnative backend requested but binary was built with thesp1feature. Users following this matrix will build the SP1 image and then get a startup failure for native configs, so the documented support matrix should be corrected or the image should actually include native support.Useful? React with 👍 / 👎.