From 1957d151e4c3513fe82947f3ba3a6adaaba9fa2e Mon Sep 17 00:00:00 2001 From: 0xaatif Date: Tue, 2 Jul 2024 11:35:19 +0100 Subject: [PATCH 01/12] mark: 0xaatif/docker From d5ed23b51b26c8a80129856ede6f7df071c03189 Mon Sep 17 00:00:00 2001 From: 0xaatif Date: Tue, 2 Jul 2024 11:38:59 +0100 Subject: [PATCH 02/12] run: docker init --- .dockerignore | 32 ++++++++++++++++++++++++ Dockerfile | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ compose.yaml | 50 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 compose.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..3dfba3823 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,32 @@ +# Include any files or directories that you don't want to be copied to your +# container here (e.g., local build artifacts, temporary files, etc.). +# +# For more help, visit the .dockerignore file reference guide at +# https://docs.docker.com/engine/reference/builder/#dockerignore-file + +**/.DS_Store +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/secrets.dev.yaml +**/values.dev.yaml +/bin +/target +LICENSE +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..25b437a8a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,67 @@ +# syntax=docker/dockerfile:1 + +# Comments are provided throughout this file to help you get started. +# If you need more help, visit the Dockerfile reference guide at +# https://docs.docker.com/engine/reference/builder/ + +################################################################################ +# Create a stage for building the application. + +ARG RUST_VERSION=1.81.0-nightly +ARG APP_NAME= +FROM rust:${RUST_VERSION}-slim-bullseye AS build +ARG APP_NAME +WORKDIR /app + +# Build the application. +# Leverage a cache mount to /usr/local/cargo/registry/ +# for downloaded dependencies and a cache mount to /app/target/ for +# compiled dependencies which will speed up subsequent builds. +# Leverage a bind mount to the src directory to avoid having to copy the +# source code into the container. Once built, copy the executable to an +# output directory before the cache mounted /app/target is unmounted. +RUN --mount=type=bind,source=src,target=src \ + --mount=type=bind,source=Cargo.toml,target=Cargo.toml \ + --mount=type=bind,source=Cargo.lock,target=Cargo.lock \ + --mount=type=cache,target=/app/target/ \ + --mount=type=cache,target=/usr/local/cargo/registry/ \ + < Date: Tue, 2 Jul 2024 11:39:08 +0100 Subject: [PATCH 03/12] run: rm compose.yaml --- compose.yaml | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 compose.yaml diff --git a/compose.yaml b/compose.yaml deleted file mode 100644 index 1f54069e1..000000000 --- a/compose.yaml +++ /dev/null @@ -1,50 +0,0 @@ -# Comments are provided throughout this file to help you get started. -# If you need more help, visit the Docker compose reference guide at -# https://docs.docker.com/compose/compose-file/ - -# Here the instructions define your application as a service called "server". -# This service is built from the Dockerfile in the current directory. -# You can add other services your application may depend on here, such as a -# database or a cache. For examples, see the Awesome Compose repository: -# https://github.com/docker/awesome-compose -services: - server: - build: - context: . - target: final - ports: - - 1000:1000 - -# The commented out section below is an example of how to define a PostgreSQL -# database that your application can use. `depends_on` tells Docker Compose to -# start the database before your application. The `db-data` volume persists the -# database data between container restarts. The `db-password` secret is used -# to set the database password. You must create `db/password.txt` and add -# a password of your choosing to it before running `docker compose up`. -# depends_on: -# db: -# condition: service_healthy -# db: -# image: postgres -# restart: always -# user: postgres -# secrets: -# - db-password -# volumes: -# - db-data:/var/lib/postgresql/data -# environment: -# - POSTGRES_DB=example -# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password -# expose: -# - 5432 -# healthcheck: -# test: [ "CMD", "pg_isready" ] -# interval: 10s -# timeout: 5s -# retries: 5 -# volumes: -# db-data: -# secrets: -# db-password: -# file: db/password.txt - From 281d481d659b87ba053b76e06c6e1ca324d06e5a Mon Sep 17 00:00:00 2001 From: 0xaatif Date: Tue, 2 Jul 2024 18:57:19 +0100 Subject: [PATCH 04/12] refactor: docker builds --- .cargo/config.toml | 4 ++ .dockerignore | 8 +-- Cargo.lock | 36 ++++++++++ Cargo.toml | 24 ++++--- Dockerfile | 125 ++++++++++++++++++++++------------ leader.Dockerfile | 60 ---------------- worker.Dockerfile | 40 ----------- zero_bin/.cargo/config.toml | 8 +-- zero_bin/leader/Cargo.toml | 6 +- zero_bin/leader/build.rs | 17 +++++ zero_bin/leader/src/main.rs | 31 ++++----- zero_bin/leader/src/utils.rs | 72 -------------------- zero_bin/tools/prove_rpc.sh | 4 -- zero_bin/tools/prove_stdio.sh | 4 -- 14 files changed, 172 insertions(+), 267 deletions(-) create mode 100644 .cargo/config.toml delete mode 100644 leader.Dockerfile delete mode 100644 worker.Dockerfile create mode 100644 zero_bin/leader/build.rs delete mode 100644 zero_bin/leader/src/utils.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 000000000..6340ce34a --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,4 @@ +[build] +# https://github.com/rust-lang/rust/pull/124129 +# https://github.com/dtolnay/linkme/pull/88 +rustflags = ["-Z", "linker-features=-lld"] diff --git a/.dockerignore b/.dockerignore index 3dfba3823..1562ab5b3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,13 +1,9 @@ -# Include any files or directories that you don't want to be copied to your -# container here (e.g., local build artifacts, temporary files, etc.). -# -# For more help, visit the .dockerignore file reference guide at -# https://docs.docker.com/engine/reference/builder/#dockerignore-file +# this is loosely based on `docker init`'s rust template. **/.DS_Store **/.classpath **/.dockerignore -**/.env +# **/.env **/.git **/.gitignore **/.project diff --git a/Cargo.lock b/Cargo.lock index dd96f5146..34ffcc40b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1161,6 +1161,38 @@ dependencies = [ "serde", ] +[[package]] +name = "camino" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.23", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cast" version = "0.3.0" @@ -2814,6 +2846,7 @@ dependencies = [ "alloy", "anyhow", "axum", + "cargo_metadata", "clap", "dotenvy", "futures", @@ -4372,6 +4405,9 @@ name = "semver" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +dependencies = [ + "serde", +] [[package]] name = "semver-parser" diff --git a/Cargo.toml b/Cargo.toml index aff00a946..07a478c5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,18 +1,20 @@ [workspace] -members = ["mpt_trie", - "smt_trie", - "proof_gen", - "trace_decoder", +members = [ + "compat", "evm_arithmetization", + "mpt_trie", "proc_macro", - "zero_bin/leader", - "zero_bin/worker", + "proof_gen", + "smt_trie", + "trace_decoder", "zero_bin/common", + "zero_bin/leader", "zero_bin/ops", - "zero_bin/verifier", + "zero_bin/prover", "zero_bin/rpc", - "zero_bin/prover", - "compat"] + "zero_bin/verifier", + "zero_bin/worker", +] resolver = "2" [workspace.package] @@ -24,7 +26,7 @@ keywords = ["cryptography", "STARK", "plonky2", "ethereum", "zk"] categories = ["cryptography::cryptocurrencies"] [workspace.dependencies] -alloy = { git = "https://github.com/alloy-rs/alloy", tag='v0.1.1', default-features = false, features = [ +alloy = { git = "https://github.com/alloy-rs/alloy", tag = 'v0.1.1', default-features = false, features = [ "consensus", "reqwest", "json-rpc", @@ -36,7 +38,7 @@ alloy = { git = "https://github.com/alloy-rs/alloy", tag='v0.1.1', default-featu "providers", "transports", "transport-http", - "rpc-types-debug" + "rpc-types-debug", ] } anyhow = "1.0.86" async-stream = "0.3.5" diff --git a/Dockerfile b/Dockerfile index 25b437a8a..50fecead2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,49 +1,94 @@ # syntax=docker/dockerfile:1 +# This is loosely based on `docker init`'s rust template. +# For a completely clean build, run something like this: +# ``` +# docker build --build-arg=PROFILE=dev --build-arg=ENTRYPOINT=leader --no-cache +# ``` -# Comments are provided throughout this file to help you get started. -# If you need more help, visit the Dockerfile reference guide at -# https://docs.docker.com/engine/reference/builder/ +############# +# Build stage +############# +# - `/src` is the repo directory. +# - `/artifacts` is $CARGO_TARGET_DIR. +# - `/output` is where the binaries go. -################################################################################ -# Create a stage for building the application. +ARG BUILD_BASE=rustlang/rust:nightly-bullseye-slim +FROM ${BUILD_BASE} AS build -ARG RUST_VERSION=1.81.0-nightly -ARG APP_NAME= -FROM rust:${RUST_VERSION}-slim-bullseye AS build -ARG APP_NAME -WORKDIR /app +# Install build dependencies. +RUN apt-get update && apt-get install -y \ + # for jemalloc + libjemalloc-dev \ + libjemalloc2 \ + make \ + # for openssl + libssl-dev \ + pkg-config \ + # clean the image + && rm -rf /var/lib/apt/lists/* + +ARG PROFILE=release +# forward the docker argument so that the script below can read it +ENV PROFILE=${PROFILE} # Build the application. -# Leverage a cache mount to /usr/local/cargo/registry/ -# for downloaded dependencies and a cache mount to /app/target/ for -# compiled dependencies which will speed up subsequent builds. -# Leverage a bind mount to the src directory to avoid having to copy the -# source code into the container. Once built, copy the executable to an -# output directory before the cache mounted /app/target is unmounted. -RUN --mount=type=bind,source=src,target=src \ - --mount=type=bind,source=Cargo.toml,target=Cargo.toml \ - --mount=type=bind,source=Cargo.lock,target=Cargo.lock \ - --mount=type=cache,target=/app/target/ \ +RUN \ + # mount the repository so we don't have to COPY it in + --mount=type=bind,source=.,target=/src \ + # cache artifacts and the cargo registry to speed up subsequent builds + --mount=type=cache,target=/artifacts \ --mount=type=cache,target=/usr/local/cargo/registry/ \ + # run the build < anyhow::Result<()> { + let meta = cargo_metadata::MetadataCommand::new() + .exec() + .context("failed to probe cargo-metadata")?; + let version = &meta + .packages + .iter() + .find(|it| it.name == "evm_arithmetization") + .context("couldn't find evm_arithmetization package")? + .version; + println!( + "cargo::rustc-env=EVM_ARITHMETIZATION_PACKAGE_VERSION={}", + version + ); + Ok(()) +} diff --git a/zero_bin/leader/src/main.rs b/zero_bin/leader/src/main.rs index a2c7020f1..94b2abb94 100644 --- a/zero_bin/leader/src/main.rs +++ b/zero_bin/leader/src/main.rs @@ -13,14 +13,14 @@ use tracing::{info, warn}; use zero_bin_common::block_interval::BlockInterval; use crate::client::{client_main, ProofParams}; -use crate::utils::get_package_version; mod cli; mod client; mod http; mod init; mod stdio; -mod utils; + +const EVM_ARITH_VER_KEY: &str = "EVM_ARITHMETIZATION_PKG_VER"; fn get_previous_proof(path: Option) -> Result> { if path.is_none() { @@ -39,24 +39,17 @@ async fn main() -> Result<()> { load_dotenvy_vars_if_present(); init::tracing(); - if env::var("EVM_ARITHMETIZATION_PKG_VER").is_err() { - let pkg_ver = get_package_version("evm_arithmetization")?; - // Extract the major and minor version parts and append 'x' as the patch version - if let Some((major_minor, _)) = pkg_ver.as_ref().and_then(|s| s.rsplit_once('.')) { - let circuits_version = format!("{}.x", major_minor); - // Set the environment variable for the evm_arithmetization package version - #[allow(unused_unsafe)] - unsafe { - env::set_var("EVM_ARITHMETIZATION_PKG_VER", circuits_version); - } - } else { - // Set to "NA" if version extraction fails - #[allow(unused_unsafe)] - unsafe { - env::set_var("EVM_ARITHMETIZATION_PKG_VER", "NA"); - } + if env::var_os(EVM_ARITH_VER_KEY).is_none() { + // Safety: + // - we're early enough in main that nothing else should race + unsafe { + env::set_var( + EVM_ARITH_VER_KEY, + // see build.rs + env!("EVM_ARITHMETIZATION_PACKAGE_VERSION"), + ); } - } + }; let args = cli::Cli::parse(); if let paladin::config::Runtime::InMemory = args.paladin.runtime { diff --git a/zero_bin/leader/src/utils.rs b/zero_bin/leader/src/utils.rs deleted file mode 100644 index e2c7d5f10..000000000 --- a/zero_bin/leader/src/utils.rs +++ /dev/null @@ -1,72 +0,0 @@ -use std::fs::File; -use std::io::{BufReader, Read}; -use std::path::Path; - -use anyhow::Result; - -/// Retrieves the version of a specified package from the `Cargo.lock` file. -/// -/// This function attempts to find the version of a package specified by -/// `package_name` by reading and parsing the `Cargo.lock` file. The -/// `Cargo.lock` file is expected to be located one directory level up from the -/// directory specified by the `CARGO_MANIFEST_DIR` environment variable. The -/// path may need adjustment depending on the structure of the project. -/// -/// # Parameters -/// - `package_name`: The name of the package for which the version is being -/// retrieved. -/// -/// # Returns -/// - `Ok(Some(String))`: If the package is found in the `Cargo.lock` file, -/// returns the version of the package. -/// - `Ok(None)`: If the package is not found in the `Cargo.lock` file, or if -/// the `Cargo.lock` file does not exist. -/// - `Err(_)`: If any error occurs during the execution, such as issues with -/// file paths, file access, reading, or parsing the `Cargo.lock` file. -/// -/// # Examples -/// ```no_run -/// let version = get_package_version("my_package"); -/// match version { -/// Ok(Some(ver)) => println!("Found version: {}", ver), -/// Ok(None) => println!("Package not found."), -/// Err(e) => println!("Error occurred: {}", e), -/// } -/// ``` -/// -/// # Errors -/// This function can return an `Err` result if: -/// - There is a problem finding, opening, or reading the `Cargo.lock` file. -/// - There is a failure in parsing the `Cargo.lock` file as TOML. -/// -/// The function uses `?` to propagate errors upwards, so the exact nature of -/// the error will be indicated by the error value returned in the `Err` variant -/// of the `Result`. -pub(crate) fn get_package_version(package_name: &str) -> Result> { - let manifest_dir = env!("CARGO_MANIFEST_DIR"); - let zero_bin_path = Path::new(manifest_dir) - .join("../") // Adjust the path according to your workspace structure - .canonicalize()?; - - let cargo_lock_path = zero_bin_path.join("Cargo.lock"); - let cargo_lock_file = File::open(cargo_lock_path); - if cargo_lock_file.is_err() { - return Ok(None); - } - - let mut cargo_lock_contents = String::new(); - BufReader::new(cargo_lock_file?).read_to_string(&mut cargo_lock_contents)?; - - let lockfile: toml::Value = toml::from_str(&cargo_lock_contents)?; - if let Some(package) = lockfile["package"] - .as_array() - .unwrap() - .iter() - .find(|&p| p["name"].as_str() == Some(package_name)) - { - let version = package["version"].as_str().unwrap(); - return Ok(Some(version.to_string())); - } - - Ok(None) -} diff --git a/zero_bin/tools/prove_rpc.sh b/zero_bin/tools/prove_rpc.sh index 9a0700f22..c02be1ea8 100755 --- a/zero_bin/tools/prove_rpc.sh +++ b/zero_bin/tools/prove_rpc.sh @@ -13,10 +13,6 @@ export RUST_MIN_STACK=33554432 export RUST_BACKTRACE=1 export RUST_LOG=info -# Disable the lld linker for now, as it's causing issues with the linkme package. -# https://github.com/rust-lang/rust/pull/124129 -# https://github.com/dtolnay/linkme/pull/88 -export RUSTFLAGS='-C target-cpu=native -Zlinker-features=-lld' if [[ $8 == "test_only" ]]; then # Circuit sizes don't matter in test_only mode, so we keep them minimal. diff --git a/zero_bin/tools/prove_stdio.sh b/zero_bin/tools/prove_stdio.sh index 43f62dd59..5a0f374d8 100755 --- a/zero_bin/tools/prove_stdio.sh +++ b/zero_bin/tools/prove_stdio.sh @@ -29,10 +29,6 @@ export TOKIO_WORKER_THREADS=$num_procs export RUST_MIN_STACK=33554432 export RUST_BACKTRACE=full export RUST_LOG=info -# Disable the lld linker for now, as it's causing issues with the linkme package. -# https://github.com/rust-lang/rust/pull/124129 -# https://github.com/dtolnay/linkme/pull/88 -export RUSTFLAGS='-C target-cpu=native -Zlinker-features=-lld' INPUT_FILE=$1 TEST_ONLY=$2 From 3b785087b4132de1cea2e4556235b607c2eb3772 Mon Sep 17 00:00:00 2001 From: 0xaatif Date: Tue, 2 Jul 2024 19:15:29 +0100 Subject: [PATCH 05/12] feat: smoke test executables --- Dockerfile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 50fecead2..8c4f5e7c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,7 +61,13 @@ fi # maxdepth because binaries are in the root # - other folders contain build scripts etc. mkdir /output -find "/artifacts/$SUBDIR" -maxdepth 1 -type f -executable -exec cp '{}' /output \; -print +find "/artifacts/$SUBDIR" \ + -maxdepth 1 \ + -type f \ + -executable \ + -not -name '*.so' \ + -exec cp '{}' /output \; \ + -print EOF @@ -79,6 +85,12 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* COPY --from=build /output/* /usr/local/bin/ +RUN < Date: Tue, 2 Jul 2024 19:19:12 +0100 Subject: [PATCH 06/12] refactor(ci): use new docker file --- .github/workflows/docker_build.yml | 21 ++++++--------------- .github/workflows/docker_build_push.yml | 8 +++----- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index 8d74a2fa4..41bdbbbf7 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -12,24 +12,15 @@ on: jobs: docker: - name: Build and run leader and worker docker images for regression check + name: Regression test docker images runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - - name: Build leader docker container - run: | - docker build --progress plain -t leader:${{ github.ref_name }} -f leader.Dockerfile . + - run: | + docker build --progress=plain --build-arg=PROFILE=dev --build-arg=ENTRYPOINT=leader --tag scratch . + docker run --rm scratch --help - - name: Run leader docker container - run: | - docker run --rm leader:${{ github.ref_name }} --help - - - name: Build worker docker container - run: | - docker build --progress plain -t worker:${{ github.ref_name }} -f worker.Dockerfile . - - - name: Run worker docker container - run: | - docker run --rm worker:${{ github.ref_name }} --help + docker build --progress=plain --build-arg=PROFILE=dev --build-arg=ENTRYPOINT=worker --tag scratch . + docker run --rm scratch --help diff --git a/.github/workflows/docker_build_push.yml b/.github/workflows/docker_build_push.yml index 112ea158e..1727bd682 100644 --- a/.github/workflows/docker_build_push.yml +++ b/.github/workflows/docker_build_push.yml @@ -38,7 +38,7 @@ jobs: id: meta_leader uses: docker/metadata-action@v5 with: - images: | + images: | name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LEADER }} tags: | type=ref,event=branch @@ -49,8 +49,7 @@ jobs: - name: Push to GitHub Container Registry - Leader uses: docker/build-push-action@v3 with: - context: . - file: ./leader.Dockerfile + build-args: ["ENTRYPOINT=leader"] push: true # platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta_leader.outputs.tags }} @@ -73,8 +72,7 @@ jobs: - name: Push to GitHub Container Registry - Worker uses: docker/build-push-action@v3 with: - context: . - file: ./worker.Dockerfile + build-args: ["ENTRYPOINT=worker"] push: true # platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta_worker.outputs.tags }} From e365faf8bd8727fe1ef15403908f2409cd642ee4 Mon Sep 17 00:00:00 2001 From: 0xaatif Date: Tue, 2 Jul 2024 19:27:24 +0100 Subject: [PATCH 07/12] feat: xargs --verbose --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8c4f5e7c1..c05e80c53 100644 --- a/Dockerfile +++ b/Dockerfile @@ -89,7 +89,7 @@ RUN < Date: Thu, 4 Jul 2024 10:40:19 +0100 Subject: [PATCH 08/12] refactor: one image --- .github/workflows/docker_build.yml | 10 +++++----- .github/workflows/docker_build_push.yml | 14 +------------- Dockerfile | 22 +++------------------- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index 41bdbbbf7..c907bbf39 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -19,8 +19,8 @@ jobs: uses: actions/checkout@v4 - run: | - docker build --progress=plain --build-arg=PROFILE=dev --build-arg=ENTRYPOINT=leader --tag scratch . - docker run --rm scratch --help - - docker build --progress=plain --build-arg=PROFILE=dev --build-arg=ENTRYPOINT=worker --tag scratch . - docker run --rm scratch --help + docker build --progress=plain --build-arg=PROFILE=dev --tag scratch . + docker run --rm --init --entrypoint leader scratch --help + docker run --rm --init --entrypoint worker scratch --help + docker run --rm --init --entrypoint rpc scratch --help + docker run --rm --init --entrypoint verifier scratch --help diff --git a/.github/workflows/docker_build_push.yml b/.github/workflows/docker_build_push.yml index 1727bd682..ff37de6be 100644 --- a/.github/workflows/docker_build_push.yml +++ b/.github/workflows/docker_build_push.yml @@ -46,10 +46,9 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - - name: Push to GitHub Container Registry - Leader + - name: Push to GitHub Container Registry uses: docker/build-push-action@v3 with: - build-args: ["ENTRYPOINT=leader"] push: true # platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta_leader.outputs.tags }} @@ -68,14 +67,3 @@ jobs: type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - - - name: Push to GitHub Container Registry - Worker - uses: docker/build-push-action@v3 - with: - build-args: ["ENTRYPOINT=worker"] - push: true - # platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta_worker.outputs.tags }} - labels: ${{ steps.meta_worker.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index c05e80c53..18158356f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # This is loosely based on `docker init`'s rust template. # For a completely clean build, run something like this: # ``` -# docker build --build-arg=PROFILE=dev --build-arg=ENTRYPOINT=leader --no-cache +# docker build --build-arg=PROFILE=dev --no-cache # ``` ############# @@ -80,26 +80,10 @@ FROM debian:bullseye-slim AS final RUN apt-get update && apt-get install -y \ ca-certificates \ libjemalloc2 \ - libssl-dev \ - tini \ && rm -rf /var/lib/apt/lists/* -COPY --from=build /output/* /usr/local/bin/ -RUN < Date: Thu, 4 Jul 2024 10:49:28 +0100 Subject: [PATCH 09/12] fix: one image --- .github/workflows/docker_build_push.yml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.github/workflows/docker_build_push.yml b/.github/workflows/docker_build_push.yml index ff37de6be..405127be2 100644 --- a/.github/workflows/docker_build_push.yml +++ b/.github/workflows/docker_build_push.yml @@ -8,8 +8,6 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME_LEADER: ${{ github.repository }}-leader - IMAGE_NAME_WORKER: ${{ github.repository }}-worker jobs: docker: @@ -34,12 +32,12 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Leader Docker + - name: Extract metadata (tags, labels) id: meta_leader uses: docker/metadata-action@v5 with: images: | - name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LEADER }} + name=${{ env.REGISTRY }}/${{ github.repository }} tags: | type=ref,event=branch type=ref,event=pr @@ -55,15 +53,3 @@ jobs: labels: ${{ steps.meta_leader.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - - - name: Extract metadata (tags, labels) for Worker Docker - id: meta_worker - uses: docker/metadata-action@v5 - with: - images: | - name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME_WORKER }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} From ac2ce6635d1779f8d3cb16798c30226a43c4830a Mon Sep 17 00:00:00 2001 From: 0xaatif Date: Fri, 5 Jul 2024 15:22:14 +0100 Subject: [PATCH 10/12] wibble: change id meta_leader -> meta --- .github/workflows/docker_build_push.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker_build_push.yml b/.github/workflows/docker_build_push.yml index 405127be2..0c64efecd 100644 --- a/.github/workflows/docker_build_push.yml +++ b/.github/workflows/docker_build_push.yml @@ -33,7 +33,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) - id: meta_leader + id: meta uses: docker/metadata-action@v5 with: images: | @@ -49,7 +49,7 @@ jobs: with: push: true # platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta_leader.outputs.tags }} - labels: ${{ steps.meta_leader.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max From 477437589cd0359cf49dbf3f219e98813373f272 Mon Sep 17 00:00:00 2001 From: 0xaatif Date: Mon, 8 Jul 2024 17:12:16 +0200 Subject: [PATCH 11/12] fix: censor minor version --- zero_bin/leader/build.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zero_bin/leader/build.rs b/zero_bin/leader/build.rs index 410a1d2c3..0adcbb347 100644 --- a/zero_bin/leader/build.rs +++ b/zero_bin/leader/build.rs @@ -10,8 +10,10 @@ fn main() -> anyhow::Result<()> { .context("couldn't find evm_arithmetization package")? .version; println!( - "cargo::rustc-env=EVM_ARITHMETIZATION_PACKAGE_VERSION={}", - version + "cargo::rustc-env=EVM_ARITHMETIZATION_PACKAGE_VERSION={}.{}.x", + // patch version change should not prompt circuits regeneration + version.major, + version.minor ); Ok(()) } From f1ac34c4fb102954b0b45f9de3bbf5c256c27a18 Mon Sep 17 00:00:00 2001 From: 0xaatif Date: Mon, 8 Jul 2024 17:16:32 +0200 Subject: [PATCH 12/12] fix: restore target-cpu=native --- zero_bin/tools/prove_rpc.sh | 3 +++ zero_bin/tools/prove_stdio.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/zero_bin/tools/prove_rpc.sh b/zero_bin/tools/prove_rpc.sh index c02be1ea8..363e3dfd4 100755 --- a/zero_bin/tools/prove_rpc.sh +++ b/zero_bin/tools/prove_rpc.sh @@ -13,6 +13,9 @@ export RUST_MIN_STACK=33554432 export RUST_BACKTRACE=1 export RUST_LOG=info +# Script users are running locally, and might benefit from extra perf. +# See also .cargo/config.toml. +export RUSTFLAGS='-C target-cpu=native -Zlinker-features=-lld' if [[ $8 == "test_only" ]]; then # Circuit sizes don't matter in test_only mode, so we keep them minimal. diff --git a/zero_bin/tools/prove_stdio.sh b/zero_bin/tools/prove_stdio.sh index 5a0f374d8..23b4b5948 100755 --- a/zero_bin/tools/prove_stdio.sh +++ b/zero_bin/tools/prove_stdio.sh @@ -29,6 +29,9 @@ export TOKIO_WORKER_THREADS=$num_procs export RUST_MIN_STACK=33554432 export RUST_BACKTRACE=full export RUST_LOG=info +# Script users are running locally, and might benefit from extra perf. +# See also .cargo/config.toml. +export RUSTFLAGS='-C target-cpu=native -Zlinker-features=-lld' INPUT_FILE=$1 TEST_ONLY=$2