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: turn libscroll_zstd dynamic lib into static #794

Merged
merged 11 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
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
9 changes: 2 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""
ARG LIBSCROLL_ZSTD_VERSION=v0.1.0-rc0-ubuntu20.04
ARG SCROLL_LIB_PATH=/scroll/lib

# Build libzkp dependency
Expand All @@ -28,14 +27,12 @@ FROM scrolltech/go-rust-builder:go-1.20-rust-nightly-2022-12-10 as builder

ADD . /go-ethereum

ARG LIBSCROLL_ZSTD_VERSION
ARG SCROLL_LIB_PATH

RUN mkdir -p $SCROLL_LIB_PATH

COPY --from=zkp-builder /app/target/release/libzkp.so $SCROLL_LIB_PATH
COPY --from=zkp-builder /app/target/release/libzktrie.so $SCROLL_LIB_PATH
RUN wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so

ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SCROLL_LIB_PATH
ENV CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
Expand All @@ -46,21 +43,19 @@ RUN cd /go-ethereum && env GO111MODULE=on go run build/ci.go install -buildtags
FROM ubuntu:20.04

RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates wget
&& apt-get -qq install -y --no-install-recommends ca-certificates

COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/

ARG LIBSCROLL_ZSTD_VERSION
ARG SCROLL_LIB_PATH

RUN mkdir -p $SCROLL_LIB_PATH

COPY --from=zkp-builder /app/target/release/libzkp.so $SCROLL_LIB_PATH
COPY --from=zkp-builder /app/target/release/libzktrie.so $SCROLL_LIB_PATH
RUN wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so

ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SCROLL_LIB_PATH
ENV CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
ENV CGO_LDFLAGS="-ldl -L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"

EXPOSE 8545 8546 30303 30303/udp
ENTRYPOINT ["geth"]
Expand Down
26 changes: 3 additions & 23 deletions Dockerfile.mockccc
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,20 @@
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""
ARG LIBSCROLL_ZSTD_VERSION=v0.1.0-rc0-ubuntu20.04
ARG SCROLL_LIB_PATH=/scroll/lib

# Build Geth in a stock Go builder container
FROM scrolltech/go-rust-builder:go-1.20-rust-nightly-2022-12-10 as builder

ADD . /go-ethereum

ARG LIBSCROLL_ZSTD_VERSION
ARG SCROLL_LIB_PATH

RUN mkdir -p $SCROLL_LIB_PATH

RUN apt-get -qq update && apt-get -qq install -y wget
RUN wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so

ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SCROLL_LIB_PATH
ENV CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
RUN cd /go-ethereum && env GO111MODULE=on go run build/ci.go install ./cmd/geth

# Pull Geth into a second stage deploy alpine container
FROM ubuntu:20.04

COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
ENV CGO_LDFLAGS="-ldl"

ARG LIBSCROLL_ZSTD_VERSION
ARG SCROLL_LIB_PATH

RUN mkdir -p $SCROLL_LIB_PATH

RUN apt-get -qq update && apt-get -qq install -y wget
RUN wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so

ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SCROLL_LIB_PATH
ENV CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/

EXPOSE 8545 8546 30303 30303/udp
ENTRYPOINT ["geth"]
Expand Down
29 changes: 12 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@
# with Go source code. If you know what GOPATH is then you probably
# don't need to bother with make.

.PHONY: geth android ios evm all test clean libzkp libzstd
.PHONY: geth android ios evm all test clean libzkp

GOBIN = ./build/bin
GO ?= latest
GORUN = go run
LIBSCROLL_ZSTD_VERSION = v0.1.0-rc0-ubuntu20.04
SCROLL_LIB_PATH = /scroll/lib
GORUN = env GO111MODULE=on go run

libzkp:
cd $(PWD)/rollup/circuitcapacitychecker/libzkp && make libzkp

libzstd:
@sudo mkdir -p $(SCROLL_LIB_PATH)
@sudo wget -O $(SCROLL_LIB_PATH)/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$(LIBSCROLL_ZSTD_VERSION)/libscroll_zstd.so

nccc_geth: libzstd ## geth without circuit capacity checker
@LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(SCROLL_LIB_PATH)" CGO_LDFLAGS="-L$(SCROLL_LIB_PATH) -Wl,-rpath,$(SCROLL_LIB_PATH)" $(GORUN) build/ci.go install ./cmd/geth
nccc_geth: ## geth without circuit capacity checker
$(GORUN) build/ci.go install ./cmd/geth
@echo "Done building."
@echo "Run \"$(GOBIN)/geth\" to launch geth."

geth: libzkp libzstd
@sudo cp $(PWD)/rollup/circuitcapacitychecker/libzkp/libzkp.so $(SCROLL_LIB_PATH)
@sudo cp $(PWD)/rollup/circuitcapacitychecker/libzkp/libzktrie.so $(SCROLL_LIB_PATH)
@LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(SCROLL_LIB_PATH)" CGO_LDFLAGS="-L$(SCROLL_LIB_PATH) -Wl,-rpath,$(SCROLL_LIB_PATH)" $(GORUN) build/ci.go install -buildtags circuit_capacity_checker ./cmd/geth
geth: libzkp
$(GORUN) build/ci.go install -buildtags circuit_capacity_checker ./cmd/geth
@echo "Done building."
@echo "Run \"$(GOBIN)/geth\" to launch geth."

Expand All @@ -44,14 +36,17 @@ ios:
@echo "Done building."
@echo "Import \"$(GOBIN)/Geth.framework\" to use the library."

test:
./run_test.sh
test: all
# genesis test
cd ${PWD}/cmd/geth; go test -test.run TestCustomGenesis
# module test
$(GORUN) build/ci.go test ./consensus ./core ./eth ./miner ./node ./trie ./rollup/...

lint: ## Run linters.
$(GORUN) build/ci.go lint

clean:
go clean -cache
env GO111MODULE=on go clean -cache
rm -fr build/_workspace/pkg/ $(GOBIN)/*

# The devtools target installs tools required for 'go generate'.
Expand Down
3 changes: 3 additions & 0 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ func doInstall(cmdline []string) {
// Show packages during build.
gobuild.Args = append(gobuild.Args, "-v")

// Add -ldl flags for libscroll_zstd.a.
gobuild.Args = append(gobuild.Args, "-ldflags", "-extldflags -ldl")
colinlyguo marked this conversation as resolved.
Show resolved Hide resolved

// Now we choose what we're even building.
// Default: collect all 'main' packages in cmd/ and build those.
packages := flag.Args()
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ require (
github.com/prometheus/tsdb v0.7.1
github.com/rjeczalik/notify v0.9.1
github.com/rs/cors v1.7.0
github.com/scroll-tech/da-codec v0.0.0-20240516115958-db04f5e6772c
github.com/scroll-tech/zktrie v0.8.4
github.com/scroll-tech/da-codec v0.0.0-20240604103336-17c1ba7dd66d
github.com/scroll-tech/zktrie v0.8.2
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4
github.com/stretchr/testify v1.9.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,10 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj
github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scroll-tech/da-codec v0.0.0-20240516115958-db04f5e6772c h1:Vi1BGENMGO8yjmnJe6QP9Eb1OPPuEi4+wd8d/DxhJ6Q=
github.com/scroll-tech/da-codec v0.0.0-20240516115958-db04f5e6772c/go.mod h1:1wWYii0OPwd5kw+xrz0PFgS420xNadrNF1x/ELJT+TM=
github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE=
github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
github.com/scroll-tech/da-codec v0.0.0-20240604103336-17c1ba7dd66d h1:ywij6xtaviuNbpdeOrimT0C5S560Lz2E1kl7AUYXCbE=
github.com/scroll-tech/da-codec v0.0.0-20240604103336-17c1ba7dd66d/go.mod h1:1wWYii0OPwd5kw+xrz0PFgS420xNadrNF1x/ELJT+TM=
github.com/scroll-tech/zktrie v0.8.2 h1:UMuIfA+jdgWMLmTgTL64Emo+zzMOdcnH0+eYdDcshxQ=
github.com/scroll-tech/zktrie v0.8.2/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo=
github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
Expand Down
17 changes: 0 additions & 17 deletions rollup/rollup_sync_service/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions run_test.sh

This file was deleted.

Loading