Skip to content

Commit 247ba6b

Browse files
committed
Merge branch 'develop' into feat/cancun
2 parents f9212b5 + 43a984d commit 247ba6b

File tree

30 files changed

+356
-293
lines changed

30 files changed

+356
-293
lines changed

.cargo/config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[build]
2+
# https://github.com/rust-lang/rust/pull/124129
3+
# https://github.com/dtolnay/linkme/pull/88
4+
rustflags = ["-Z", "linker-features=-lld"]

.dockerignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# this is loosely based on `docker init`'s rust template.
2+
3+
**/.DS_Store
4+
**/.classpath
5+
**/.dockerignore
6+
# **/.env
7+
**/.git
8+
**/.gitignore
9+
**/.project
10+
**/.settings
11+
**/.toolstarget
12+
**/.vs
13+
**/.vscode
14+
**/*.*proj.user
15+
**/*.dbmdl
16+
**/*.jfm
17+
**/charts
18+
**/docker-compose*
19+
**/compose*
20+
**/Dockerfile*
21+
**/node_modules
22+
**/npm-debug.log
23+
**/secrets.dev.yaml
24+
**/values.dev.yaml
25+
/bin
26+
/target
27+
LICENSE
28+
README.md

.github/workflows/docker_build.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,15 @@ on:
1212

1313
jobs:
1414
docker:
15-
name: Build and run leader and worker docker images for regression check
15+
name: Regression test docker images
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout
1919
uses: actions/checkout@v4
2020

21-
- name: Build leader docker container
22-
run: |
23-
docker build --progress plain -t leader:${{ github.ref_name }} -f leader.Dockerfile .
24-
25-
- name: Run leader docker container
26-
run: |
27-
docker run --rm leader:${{ github.ref_name }} --help
28-
29-
- name: Build worker docker container
30-
run: |
31-
docker build --progress plain -t worker:${{ github.ref_name }} -f worker.Dockerfile .
32-
33-
- name: Run worker docker container
34-
run: |
35-
docker run --rm worker:${{ github.ref_name }} --help
21+
- run: |
22+
docker build --progress=plain --build-arg=PROFILE=dev --tag scratch .
23+
docker run --rm --init --entrypoint leader scratch --help
24+
docker run --rm --init --entrypoint worker scratch --help
25+
docker run --rm --init --entrypoint rpc scratch --help
26+
docker run --rm --init --entrypoint verifier scratch --help

.github/workflows/docker_build_push.yml

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ on:
88

99
env:
1010
REGISTRY: ghcr.io
11-
IMAGE_NAME_LEADER: ${{ github.repository }}-leader
12-
IMAGE_NAME_WORKER: ${{ github.repository }}-worker
1311

1412
jobs:
1513
docker:
@@ -34,50 +32,24 @@ jobs:
3432
username: ${{ github.actor }}
3533
password: ${{ secrets.GITHUB_TOKEN }}
3634

37-
- name: Extract metadata (tags, labels) for Leader Docker
38-
id: meta_leader
39-
uses: docker/metadata-action@v5
40-
with:
41-
images: |
42-
name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LEADER }}
43-
tags: |
44-
type=ref,event=branch
45-
type=ref,event=pr
46-
type=semver,pattern={{version}}
47-
type=semver,pattern={{major}}.{{minor}}
48-
49-
- name: Push to GitHub Container Registry - Leader
50-
uses: docker/build-push-action@v3
51-
with:
52-
context: .
53-
file: ./leader.Dockerfile
54-
push: true
55-
# platforms: linux/amd64,linux/arm64
56-
tags: ${{ steps.meta_leader.outputs.tags }}
57-
labels: ${{ steps.meta_leader.outputs.labels }}
58-
cache-from: type=gha
59-
cache-to: type=gha,mode=max
60-
61-
- name: Extract metadata (tags, labels) for Worker Docker
62-
id: meta_worker
35+
- name: Extract metadata (tags, labels)
36+
id: meta
6337
uses: docker/metadata-action@v5
6438
with:
6539
images: |
66-
name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME_WORKER }}
40+
name=${{ env.REGISTRY }}/${{ github.repository }}
6741
tags: |
6842
type=ref,event=branch
6943
type=ref,event=pr
7044
type=semver,pattern={{version}}
7145
type=semver,pattern={{major}}.{{minor}}
7246
73-
- name: Push to GitHub Container Registry - Worker
47+
- name: Push to GitHub Container Registry
7448
uses: docker/build-push-action@v3
7549
with:
76-
context: .
77-
file: ./worker.Dockerfile
7850
push: true
7951
# platforms: linux/amd64,linux/arm64
80-
tags: ${{ steps.meta_worker.outputs.tags }}
81-
labels: ${{ steps.meta_worker.outputs.labels }}
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
8254
cache-from: type=gha
8355
cache-to: type=gha,mode=max

Cargo.lock

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
[workspace]
2-
members = ["mpt_trie",
3-
"smt_trie",
4-
"proof_gen",
5-
"trace_decoder",
2+
members = [
3+
"compat",
64
"evm_arithmetization",
5+
"mpt_trie",
76
"proc_macro",
8-
"zero_bin/leader",
9-
"zero_bin/worker",
7+
"proof_gen",
8+
"smt_trie",
9+
"trace_decoder",
1010
"zero_bin/common",
11+
"zero_bin/leader",
1112
"zero_bin/ops",
12-
"zero_bin/verifier",
13+
"zero_bin/prover",
1314
"zero_bin/rpc",
14-
"zero_bin/prover",
15-
"compat"]
15+
"zero_bin/verifier",
16+
"zero_bin/worker",
17+
]
1618
resolver = "2"
1719

1820
[workspace.package]
@@ -24,7 +26,7 @@ keywords = ["cryptography", "STARK", "plonky2", "ethereum", "zk"]
2426
categories = ["cryptography::cryptocurrencies"]
2527

2628
[workspace.dependencies]
27-
alloy = { git = "https://github.com/alloy-rs/alloy", tag='v0.1.1', default-features = false, features = [
29+
alloy = { git = "https://github.com/alloy-rs/alloy", tag = 'v0.1.1', default-features = false, features = [
2830
"consensus",
2931
"reqwest",
3032
"json-rpc",
@@ -36,7 +38,7 @@ alloy = { git = "https://github.com/alloy-rs/alloy", tag='v0.1.1', default-featu
3638
"providers",
3739
"transports",
3840
"transport-http",
39-
"rpc-types-debug"
41+
"rpc-types-debug",
4042
] }
4143
anyhow = "1.0.86"
4244
async-stream = "0.3.5"

Dockerfile

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# syntax=docker/dockerfile:1
2+
# This is loosely based on `docker init`'s rust template.
3+
# For a completely clean build, run something like this:
4+
# ```
5+
# docker build --build-arg=PROFILE=dev --no-cache
6+
# ```
7+
8+
#############
9+
# Build stage
10+
#############
11+
# - `/src` is the repo directory.
12+
# - `/artifacts` is $CARGO_TARGET_DIR.
13+
# - `/output` is where the binaries go.
14+
15+
ARG BUILD_BASE=rustlang/rust:nightly-bullseye-slim
16+
FROM ${BUILD_BASE} AS build
17+
18+
# Install build dependencies.
19+
RUN apt-get update && apt-get install -y \
20+
# for jemalloc
21+
libjemalloc-dev \
22+
libjemalloc2 \
23+
make \
24+
# for openssl
25+
libssl-dev \
26+
pkg-config \
27+
# clean the image
28+
&& rm -rf /var/lib/apt/lists/*
29+
30+
ARG PROFILE=release
31+
# forward the docker argument so that the script below can read it
32+
ENV PROFILE=${PROFILE}
33+
34+
# Build the application.
35+
RUN \
36+
# mount the repository so we don't have to COPY it in
37+
--mount=type=bind,source=.,target=/src \
38+
# cache artifacts and the cargo registry to speed up subsequent builds
39+
--mount=type=cache,target=/artifacts \
40+
--mount=type=cache,target=/usr/local/cargo/registry/ \
41+
# run the build
42+
<<EOF
43+
set -eux
44+
45+
# need to change workdir instead of using --manifest-path because we need
46+
# .cargo/config.toml
47+
cd /src
48+
49+
# use the cache mount
50+
# (we will not be able to to write to e.g `/src/target` because it is bind-mounted)
51+
CARGO_TARGET_DIR=/artifacts cargo build --locked "--profile=${PROFILE}" --all
52+
53+
# narrow the find call to SUBDIR because if we just copy out all executables
54+
# we will break the cache invariant
55+
if [ "$PROFILE" = "dev" ]; then
56+
SUBDIR=debug # edge case
57+
else
58+
SUBDIR=$PROFILE
59+
fi
60+
61+
# maxdepth because binaries are in the root
62+
# - other folders contain build scripts etc.
63+
mkdir /output
64+
find "/artifacts/$SUBDIR" \
65+
-maxdepth 1 \
66+
-type f \
67+
-executable \
68+
-not -name '*.so' \
69+
-exec cp '{}' /output \; \
70+
-print
71+
72+
EOF
73+
74+
##################
75+
# Final executable
76+
##################
77+
FROM debian:bullseye-slim AS final
78+
79+
# Install runtime dependencies.
80+
RUN apt-get update && apt-get install -y \
81+
ca-certificates \
82+
libjemalloc2 \
83+
&& rm -rf /var/lib/apt/lists/*
84+
85+
# this keeps this build target agnostic to the build profile
86+
COPY --from=build ["/output/rpc", "/output/leader", "/output/worker", "/output/verifier", "/usr/local/bin/"]
87+
88+
# Create a non-privileged user that the app will run under.
89+
# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
90+
ARG UID=10001
91+
RUN adduser \
92+
--disabled-password \
93+
--gecos "" \
94+
--home "/nonexistent" \
95+
--shell "/sbin/nologin" \
96+
--no-create-home \
97+
--uid "${UID}" \
98+
user
99+
USER user
100+

docs/arithmetization/framework.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ \subsection{Range-checks}
8282
\subsubsection{What to range-check?}
8383
One can note that every element that ever appears on the stack has been pushed. Therefore, enforcing a range-check on pushed elements is enough to range-check all elements on the stack. Similarly, all elements in memory must have been written prior, and therefore it is enough to range-check memory writes. However, range-checking the PUSH and MSTORE opcodes is not sufficient.
8484
\begin{enumerate}
85-
\item Pushes and memory writes for ``MSTORE\_32BYTES'' are range-checked in ``BytePackingStark''.
85+
\item Pushes and memory writes for ``MSTORE\_32BYTES'' are range-checked in ``BytePackingStark'', except PUSH operations happening in privileged mode. See \ref{push_general_view}.
8686
\item Syscalls, exceptions and prover inputs are range-checked in ``ArithmeticStark''.
8787
\item The inputs and outputs of binary and ternary arithmetic operations are range-checked in ``ArithmeticStark''.
8888
\item The inputs' bits of logic operations are checked to be either 1 or 0 in ``LogicStark''. Since ``LogicStark'' only deals with bitwise operations, this is enough to have range-checked outputs as well.

docs/arithmetization/tables/cpu.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,6 @@ \subsubsection{CPU columns}
7070
\item \texttt{Stack}: \texttt{stack\_inv}, \texttt{stack\_inv\_aux} and \texttt{stack\_inv\_aux\_2} are used by popping-only (resp. pushing-only) instructions to check if the stack is empty after (resp. was empty
7171
before) the instruction. \texttt{stack\_len\_bounds\_ aux} is used to check that the stack doesn't overflow in user mode. We use the last four columns to prevent conflicts with the other general columns.
7272
See \ref{stackhandling} for more details.
73+
\label{push_general_view}
74+
\item \texttt{Push}: \texttt{is\_not\_kernel} is used to skip range-checking the output of a PUSH operation when we are in privileged mode, as the kernel code is known and trusted.
7375
\end{itemize}

docs/arithmetization/zkevm.pdf

18.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)