From c78ad6270fd8658458995bf6e639ecb0592d79fc Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Tue, 4 Jun 2024 02:19:39 +0800 Subject: [PATCH] feat: remove .so file dependency of libscroll_zstd --- Dockerfile | 5 ----- Dockerfile.mockccc | 5 ----- Makefile | 29 ++++++++++++---------------- go.mod | 4 ++-- go.sum | 8 ++++---- rollup/rollup_sync_service/README.md | 17 ---------------- run_test.sh | 28 --------------------------- 7 files changed, 18 insertions(+), 78 deletions(-) delete mode 100644 rollup/rollup_sync_service/README.md delete mode 100755 run_test.sh diff --git a/Dockerfile b/Dockerfile index 16bd1e83511c..730bccac7074 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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" @@ -50,14 +47,12 @@ RUN apt-get -qq update \ 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" diff --git a/Dockerfile.mockccc b/Dockerfile.mockccc index 51a65286ef0a..fe89c9edabb6 100644 --- a/Dockerfile.mockccc +++ b/Dockerfile.mockccc @@ -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 Geth in a stock Go builder container @@ -10,13 +9,11 @@ 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" @@ -26,13 +23,11 @@ FROM ubuntu:20.04 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 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" diff --git a/Makefile b/Makefile index c2b3d016cc20..95b6baae0f7e 100644 --- a/Makefile +++ b/Makefile @@ -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." @@ -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'. diff --git a/go.mod b/go.mod index 913f800dd39e..24f2c2a1845c 100644 --- a/go.mod +++ b/go.mod @@ -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-20240603180909-59f60267e4cc + 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 diff --git a/go.sum b/go.sum index 9e09f8da2c64..c5ee78f7a3c5 100644 --- a/go.sum +++ b/go.sum @@ -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-20240603180909-59f60267e4cc h1:BiLjkQTYF5zCowJyU8iQ/t72J1iiu4zCsoyp4ug8XCQ= +github.com/scroll-tech/da-codec v0.0.0-20240603180909-59f60267e4cc/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= diff --git a/rollup/rollup_sync_service/README.md b/rollup/rollup_sync_service/README.md deleted file mode 100644 index 0eb4aadf8916..000000000000 --- a/rollup/rollup_sync_service/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Running unit tests - -Follow these steps to run unit tests, in the repo's root dir: - -``` -docker pull scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 --platform linux/amd64 -docker run -it --rm -v "$(PWD):/workspace" -w /workspace scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 - -export LIBSCROLL_ZSTD_VERSION=v0.1.0-rc0-ubuntu20.04 -export SCROLL_LIB_PATH=/scroll/lib - -mkdir -p $SCROLL_LIB_PATH -wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SCROLL_LIB_PATH -export CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH" -go test -v -race ./rollup/rollup_sync_service/... -``` diff --git a/run_test.sh b/run_test.sh deleted file mode 100755 index 39eee287d08a..000000000000 --- a/run_test.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# Download .so files -export LIBSCROLL_ZSTD_VERSION=v0.1.0-rc0-ubuntu20.04 -export SCROLL_LIB_PATH=/scroll/lib - -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 - -# Set the environment variable -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SCROLL_LIB_PATH -export CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH" - -# Download and install the project dependencies -go run build/ci.go install -go get ./... - -# Save the root directory of the project -ROOT_DIR=$(pwd) - -# Run genesis test -cd $ROOT_DIR/cmd/geth -go test -test.run TestCustomGenesis - -# Run module tests -cd $ROOT_DIR -go run build/ci.go test ./consensus ./core ./eth ./miner ./node ./trie ./rollup/...