Skip to content
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

feat: split the coordinator cron to single process #995

Merged
merged 19 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 7 additions & 32 deletions build/dockerfiles/coordinator-cron.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
# Build libzkp dependency
FROM scrolltech/go-rust-builder:go-1.19-rust-nightly-2022-12-10 as chef
WORKDIR app

FROM chef as planner
COPY ./common/libzkp/impl/ .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef as zkp-builder
COPY ./common/libzkp/impl/rust-toolchain ./
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json

COPY ./common/libzkp/impl .
RUN cargo build --release
RUN find ./ | grep libzktrie.so | xargs -I{} cp {} /app/target/release/


# Download Go dependencies
FROM scrolltech/go-rust-builder:go-1.19-rust-nightly-2022-12-10 as base
FROM scrolltech/go-alpine-builder:1.19 as base

WORKDIR /src
COPY go.work* ./
COPY ./rollup/go.* ./rollup/
Expand All @@ -29,22 +12,14 @@ COPY ./tests/integration-test/go.* ./tests/integration-test/
COPY ./bridge-history-api/go.* ./bridge-history-api/
RUN go mod download -x


# Build coordinator
FROM base as builder
COPY . .
RUN cp -r ./common/libzkp/interface ./coordinator/internal/logic/verifier/lib
COPY --from=zkp-builder /app/target/release/libzkp.so ./coordinator/internal/logic/verifier/lib/
COPY --from=zkp-builder /app/target/release/libzktrie.so ./coordinator/internal/logic/verifier/lib/
RUN cd ./coordinator && make coordinator_cron_skip_libzkp && mv ./build/bin/coordinator_cron /bin/coordinator_cron && mv internal/logic/verifier/lib /bin/
RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
cd /src/coordinator/cmd/cron/ && go build -v -p 4 -o /bin/coordinator_cron

# Pull coordinator into a second stage deploy alpine container
FROM ubuntu:20.04
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/src/coordinator/internal/logic/verifier/lib
# ENV CHAIN_ID=534353
RUN mkdir -p /src/coordinator/internal/logic/verifier/lib
COPY --from=builder /bin/lib /src/coordinator/internal/logic/verifier/lib
FROM alpine:latest
COPY --from=builder /bin/coordinator_cron /bin/
RUN /bin/coordinator_cron --version

ENTRYPOINT ["/bin/coordinator_cron"]
ENTRYPOINT ["coordinator_cron"]
7 changes: 2 additions & 5 deletions coordinator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ libzkp:
coordinator_api: libzkp ## Builds the Coordinator api instance.
go build -ldflags "-X scroll-tech/common/version.ZkVersion=${ZK_VERSION}" -o $(PWD)/build/bin/coordinator_api ./cmd/api

coordinator_cron: libzkp ## Builds the Coordinator cron instance.
coordinator_cron:
go build -ldflags "-X scroll-tech/common/version.ZkVersion=${ZK_VERSION}" -o $(PWD)/build/bin/coordinator_cron ./cmd/cron

coordinator_api_skip_libzkp:
go build -ldflags "-X scroll-tech/common/version.ZkVersion=${ZK_VERSION}" -o $(PWD)/build/bin/coordinator_api ./cmd/api

coordinator_cron_skip_libzkp:
go build -ldflags "-X scroll-tech/common/version.ZkVersion=${ZK_VERSION}" -o $(PWD)/build/bin/coordinator_cron ./cmd/cron

mock_coordinator_api: ## Builds the mocked Coordinator instance.
go build -tags="mock_prover mock_verifier" -o $(PWD)/build/bin/coordinator_api ./cmd/api

Expand All @@ -53,7 +50,7 @@ clean: ## Empty out the bin folder
@rm -rf build/bin

docker:
DOCKER_BUILDKIT=1 docker build -t scrolltech/coordinator-api:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/coordinator-api.Dockerfile
#DOCKER_BUILDKIT=1 docker build -t scrolltech/coordinator-api:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/coordinator-api.Dockerfile
georgehao marked this conversation as resolved.
Show resolved Hide resolved
DOCKER_BUILDKIT=1 docker build -t scrolltech/coordinator-cron:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/coordinator-cron.Dockerfile

docker_push:
Expand Down
2 changes: 1 addition & 1 deletion coordinator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ The coordinator behavior can be configured using [`config.json`](config.json). C
./build/bin/coordinator_cron --config ./config.json
```

* For other flcvgh bv cvbv ags, refer to [`cmd/api/app/flags.go`](cmd/api/app/flags.go).
* For other flags, refer to [`cmd/api/app/flags.go`](cmd/api/app/flags.go).

Loading