forked from anton-rs/kona
-
Notifications
You must be signed in to change notification settings - Fork 0
/
asterisc-repro.dockerfile
132 lines (103 loc) · 4.14 KB
/
asterisc-repro.dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
################################################################
# Build Asterisc @ `ASTERISC_TAG` #
################################################################
FROM ubuntu:22.04 AS asterisc-build
SHELL ["/bin/bash", "-c"]
ARG ASTERISC_TAG
# Install deps
RUN apt-get update && apt-get install -y --no-install-recommends git curl ca-certificates make
ENV GO_VERSION=1.21.1
# Fetch go manually, rather than using a Go base image, so we can copy the installation into the final stage
RUN curl -sL https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz -o go$GO_VERSION.linux-amd64.tar.gz && \
tar -C /usr/local/ -xzf go$GO_VERSION.linux-amd64.tar.gz
ENV GOPATH=/go
ENV PATH=/usr/local/go/bin:$GOPATH/bin:$PATH
# Clone and build Asterisc @ `ASTERISC_TAG`
RUN git clone https://github.com/ethereum-optimism/asterisc && \
cd asterisc && \
git checkout $ASTERISC_TAG && \
make && \
cp rvgo/bin/asterisc /asterisc-bin
################################################################
# Build kona-client @ `CLIENT_TAG` #
################################################################
FROM ghcr.io/anton-rs/kona/asterisc-builder@sha256:523f0455b25b28917a8e7d02cd3ecb8c8af93e5e5b85ec7d7bcf2df4458e65a5 AS client-build
SHELL ["/bin/bash", "-c"]
ARG CLIENT_TAG
# Copy the Rust workspace from the host
COPY ./.git ./.git
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
COPY ./crates ./crates
COPY ./bin ./bin
# Install deps
RUN apt-get update && apt-get install -y --no-install-recommends git
# Build kona-client on the selected tag
RUN git checkout $CLIENT_TAG && \
cargo build -Zbuild-std=core,alloc --workspace --bin kona --locked --profile release-client-lto --exclude kona-host --exclude kona-derive-alloy && \
mv ./target/riscv64gc-unknown-none-elf/release-client-lto/kona /kona-client-elf
################################################################
# Build kona-host @ `CLIENT_TAG` #
################################################################
FROM ubuntu:22.04 AS host-build
SHELL ["/bin/bash", "-c"]
ARG CLIENT_TAG
# Copy the Rust workspace from the host
COPY ./.git ./.git
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
COPY ./crates ./crates
COPY ./bin ./bin
# Install deps
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
curl \
ca-certificates \
libssl-dev \
clang \
pkg-config
# Install rust
ENV RUST_VERSION=1.81.0
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain ${RUST_VERSION} --component rust-src
ENV PATH="/root/.cargo/bin:${PATH}"
# Build kona-host on the selected tag
RUN git checkout $CLIENT_TAG && \
cargo build --workspace --bin kona-host --release && \
mv ./target/release/kona-host /kona-host
################################################################
# Create `prestate.bin.gz` + `prestate-proof.json` #
################################################################
FROM ubuntu:22.04 AS prestate-build
SHELL ["/bin/bash", "-c"]
# Set env
ENV ASTERISC_BIN_PATH="/asterisc"
ENV CLIENT_BIN_PATH="/kona-client-elf"
ENV PRESTATE_OUT_PATH="/prestate.bin.gz"
ENV PROOF_OUT_PATH="/prestate-proof.json"
# Copy asterisc binary
COPY --from=asterisc-build /asterisc-bin $ASTERISC_BIN_PATH
# Copy kona-client binary
COPY --from=client-build /kona-client-elf $CLIENT_BIN_PATH
# Create `prestate.bin.gz`
RUN $ASTERISC_BIN_PATH load-elf \
--path=$CLIENT_BIN_PATH \
--out=$PRESTATE_OUT_PATH
# Create `prestate-proof.json`
RUN $ASTERISC_BIN_PATH run \
--proof-at "=0" \
--stop-at "=1" \
--input $PRESTATE_OUT_PATH \
--meta ./meta.json \
--proof-fmt "./%d.json" \
--output "" && \
mv 0.json $PROOF_OUT_PATH
################################################################
# Export Artifacts #
################################################################
FROM ubuntu:22.04 AS export-stage
COPY --from=prestate-build /asterisc .
COPY --from=prestate-build /kona-client-elf .
COPY --from=prestate-build /prestate.bin.gz .
COPY --from=prestate-build /prestate-proof.json .
COPY --from=host-build /kona-host .