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

Simplifies consuming bls-zexe dependency #1022

Merged
merged 13 commits into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 2 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,11 @@ executors:
GO_VERSION: "1.13.7"
CELO_MONOREPO_BRANCH_TO_TEST: master
jobs:
build-bls-zexe:
docker:
- image: circleci/rust:1.41.0
working_directory: ~/repos/geth
steps:
- checkout
- run:
name: Setup Rust language
command: |
rustup install 1.41.0
rustup default 1.41.0
- run:
name: Compile bls-zexe
command: |
export PATH=$PATH:$HOME/.cargo/bin
make bls-zexe

- persist_to_workspace:
root: ~/repos
paths:
- geth
build-geth:
executor: golang
resource_class: medium+
steps:
- attach_workspace:
at: ~/repos
- checkout
- restore_cache:
keys:
- go-mod-v1-{{ checksum "go.sum" }}
Expand Down Expand Up @@ -133,17 +111,13 @@ jobs:
echo "go1.13 is required"
exit 1
fi
- run:
name: Setup Rust language
command: curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.41.0
- run:
name: Compile ios client
command: make ios
- persist_to_workspace:
root: ~/repos
paths:
- geth/build/bin/Geth.framework.tgz
- geth/vendor/github.com/celo-org/bls-zexe/target/universal/release/libepoch_snark.a

publish-mobile-client:
docker:
Expand Down Expand Up @@ -263,11 +237,8 @@ workflows:
version: 2
build:
jobs:
- build-bls-zexe
- checkout-monorepo
- build-geth:
requires:
- build-bls-zexe
- build-geth
- lint:
requires:
- build-geth
Expand Down
2 changes: 1 addition & 1 deletion CeloBlockchain.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Pod::Spec.new do |s|
s.summary = package['description']
s.source = { :git => package['repository']['url'], :tag => s.version }
s.source_files = 'build/bin/Geth.framework/**/*.h', 'Empty.m'
s.vendored_libraries = 'libGeth.a', 'crypto/bls/bls-zexe/target/universal/release/libepoch_snark.a'
s.vendored_libraries = 'libGeth.a'
s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-ObjC' }
end
12 changes: 1 addition & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,13 @@
#
# To use this image for testing, modify GETH_NODE_DOCKER_IMAGE_TAG in celo-monorepo/.env file

FROM ubuntu:16.04 as rustbuilder
RUN apt update && apt install -y curl musl-tools
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH=$PATH:~/.cargo/bin
RUN $HOME/.cargo/bin/rustup install 1.41.0 && $HOME/.cargo/bin/rustup default 1.41.0 && $HOME/.cargo/bin/rustup target add x86_64-unknown-linux-musl
ADD ./crypto /go-ethereum/crypto
RUN cd /go-ethereum/crypto/bls/bls-zexe && $HOME/.cargo/bin/cargo build --target x86_64-unknown-linux-musl --release

# Build Geth in a stock Go builder container
FROM golang:1.13-alpine as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git

ADD . /go-ethereum
RUN mkdir -p /go-ethereum/crypto/bls/bls-zexe/target/release
COPY --from=rustbuilder /go-ethereum/crypto/bls/bls-zexe/target/x86_64-unknown-linux-musl/release/libepoch_snark.a /go-ethereum/crypto/bls/bls-zexe/target/release/
RUN cd /go-ethereum && make geth
RUN cd /go-ethereum && make geth-musl

# Pull Geth into a second stage deploy alpine container
FROM alpine:latest
Expand Down
11 changes: 1 addition & 10 deletions Dockerfile.alltools
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
FROM ubuntu:16.04 as rustbuilder
RUN apt update && apt install -y curl musl-tools
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN $HOME/.cargo/bin/rustup install 1.41.0 && $HOME/.cargo/bin/rustup default 1.41.0 && $HOME/.cargo/bin/rustup target add x86_64-unknown-linux-musl
ADD ./crypto /go-ethereum/crypto
RUN cd /go-ethereum/crypto/bls/bls-zexe && $HOME/.cargo/bin/cargo build --target x86_64-unknown-linux-musl --release

# Build Geth in a stock Go builder container
FROM golang:1.13-alpine as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git

ADD . /go-ethereum
RUN mkdir -p /go-ethereum/crypto/bls/bls-zexe/target/release
COPY --from=rustbuilder /go-ethereum/crypto/bls/bls-zexe/target/x86_64-unknown-linux-musl/release/libepoch_snark.a /go-ethereum/crypto/bls/bls-zexe/target/release/
RUN cd /go-ethereum && make all
RUN cd /go-ethereum && make all-musl

# Pull all binaries into a second stage deploy alpine container
FROM alpine:latest
Expand Down
111 changes: 12 additions & 99 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,9 @@

GOBIN = ./build/bin
GO ?= latest
BLS_RS_PATH ?= crypto/bls/bls-zexe

CARGO_exists := $(shell command -v cargo 2> /dev/null)
RUSTUP_exists := $(shell command -v rustup 2> /dev/null)
CARGO_LIPO_exists := $(shell command -v cargo-lipo 2> /dev/null)
LSB_exists := $(shell command -v lsb_release 2> /dev/null)

ifdef CARGO_exists
.PHONY: $(BLS_RS_PATH)/target/release/libepoch_snark.a
endif

OS :=
ifeq ("$(LSB_exists)","")
OS = darwin
Expand All @@ -32,13 +24,15 @@ endif
export NDK_VERSION ?= android-ndk-r19c
export ANDROID_NDK ?= $(PWD)/ndk_bundle/$(NDK_VERSION)


geth: bls-zexe
geth:
build/env.sh go run build/ci.go install ./cmd/geth
@echo "Done building."
@echo "Run \"$(GOBIN)/geth\" to launch geth."

bls-zexe: $(BLS_RS_PATH)/target/release/libepoch_snark.a
geth-musl:
build/env.sh go run build/ci.go install -musl ./cmd/geth
@echo "Done building with musl."
@echo "Run \"$(GOBIN)/geth\" to launch geth."

check_android_env:
@test $${ANDROID_NDK?Please set environment variable ANDROID_NDK}
Expand All @@ -59,73 +53,23 @@ ifeq ("$(wildcard $(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64)","")
endif
endif


bls-zexe-android: check_android_env ndk_bundle
ifeq ("$(RUSTUP_exists)","")
$(error "No rustup in PATH, consult https://github.com/celo-org/celo-monorepo/blob/master/SETUP.md to install Rust.")
else
rustup target add aarch64-linux-android
rustup target add armv7-linux-androideabi
rustup target add i686-linux-android
rustup target add x86_64-linux-android
cd $(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin && \
ln -s aarch64-linux-android21-clang aarch64-linux-android-clang; test aarch64-linux-android-clang && \
ln -s armv7a-linux-androideabi16-clang arm-linux-androideabi-clang; test arm-linux-androideabi-clang && \
ln -s i686-linux-android16-clang i686-linux-android-clang; test i686-linux-android-clang && \
ln -s x86_64-linux-android21-clang x86_64-linux-android-clang; test x86_64-linux-android-clang

cd $(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin && \
test -f aarch64-linux-android-clang && \
test -f arm-linux-androideabi-clang && \
test -f i686-linux-android-clang && \
test -f x86_64-linux-android-clang

PATH="$$PATH:$(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin:$(ANDROID_NDK)/toolchains/aarch64-linux-android-4.9/prebuilt/$(OS)-x86_64/bin" && \
cd $(BLS_RS_PATH) && cargo build --release --target=aarch64-linux-android --lib

PATH="$$PATH:$(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin:$(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(OS)-x86_64/bin" && \
cd $(BLS_RS_PATH) && cargo build --release --target=armv7-linux-androideabi --lib

PATH="$$PATH:$(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin:$(ANDROID_NDK)/toolchains/aarch64-linux-android-4.9/prebuilt/$(OS)-x86_64/bin" && \
cd $(BLS_RS_PATH) && cargo build --release --target=i686-linux-android --lib

PATH="$$PATH:$(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin:$(ANDROID_NDK)/toolchains/aarch64-linux-android-4.9/prebuilt/$(OS)-x86_64/bin" && \
cd $(BLS_RS_PATH) && cargo build --release --target=x86_64-linux-android --lib
endif

bls-zexe-ios:
ifeq ("$(RUSTUP_exists)","")
$(error "No rustup in PATH, consult https://github.com/celo-org/celo-monorepo/blob/master/SETUP.md")
else
ifeq ("$(CARGO_LIPO_exists)","")
cargo install cargo-lipo
endif
rustup target add aarch64-apple-ios armv7-apple-ios x86_64-apple-ios i386-apple-ios
cd $(BLS_RS_PATH) && cargo lipo --release --targets=aarch64-apple-ios,armv7-apple-ios,x86_64-apple-ios,i386-apple-ios
endif


$(BLS_RS_PATH)/target/release/libepoch_snark.a:
ifeq ("$(CARGO_exists)","")
$(error "No cargo in PATH, consult https://github.com/celo-org/celo-monorepo/blob/master/SETUP.md")
else
cd $(BLS_RS_PATH) && cargo build --release
endif

swarm:
build/env.sh go run build/ci.go install ./cmd/swarm
@echo "Done building."
@echo "Run \"$(GOBIN)/swarm\" to launch swarm."

all: bls-zexe
all:
build/env.sh go run build/ci.go install

android: bls-zexe-android
all-musl:
build/env.sh go run build/ci.go install -musl

android:
ANDROID_NDK_HOME=$(ANDROID_NDK) build/env.sh go run build/ci.go aar --local
@echo "Done building."
@echo "Import \"$(GOBIN)/geth.aar\" to use the library."

ios: bls-zexe-ios
ios:
build/env.sh go run build/ci.go xcode --local
pushd "$(GOBIN)"; rm -rf Geth.framework.tgz; tar -czvf Geth.framework.tgz Geth.framework; popd
@echo "Done building."
Expand All @@ -141,10 +85,7 @@ clean-geth:
go clean -cache
rm -fr build/_workspace/pkg/ $(GOBIN)/*

clean-bls-zexe:
rm -rf $(BLS_RS_PATH)/target

clean: clean-geth clean-bls-zexe
clean: clean-geth


# The devtools target installs tools required for 'go generate'.
Expand All @@ -171,15 +112,11 @@ geth-linux: geth-linux-386 geth-linux-amd64 geth-linux-arm geth-linux-mips64 get
@ls -ld $(GOBIN)/geth-linux-*

geth-linux-386:
rustup target add i686-unknown-linux-gnu
cd $(BLS_RS_PATH) && cargo build --target=i686-unknown-linux-gnu --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/386 -v ./cmd/geth
@echo "Linux 386 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep 386

geth-linux-amd64:
rustup target add x86_64-unknown-linux-gnu
cd $(BLS_RS_PATH) && cargo build --target=x86_64-unknown-linux-gnu --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/amd64 -v ./cmd/geth
@echo "Linux amd64 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep amd64
Expand All @@ -190,63 +127,47 @@ geth-linux-arm: geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-ar

geth-linux-arm-5:
# requires an arm compiler, on Ubuntu: sudo apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
rustup target add arm-unknown-linux-gnueabi
cd $(BLS_RS_PATH) && cargo build --target=arm-unknown-linux-gnueabi --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-5 -v ./cmd/geth
@echo "Linux ARMv5 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep arm-5

geth-linux-arm-6:
rustup target add arm-unknown-linux-gnueabi
cd $(BLS_RS_PATH) && cargo build --target=arm-unknown-linux-gnueabi --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-6 -v ./cmd/geth
@echo "Linux ARMv6 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep arm-6

geth-linux-arm-7:
# requires an arm compiler, on Ubuntu: sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
rustup target add arm-unknown-linux-gnueabihf
cd $(BLS_RS_PATH) && cargo build --target=arm-unknown-linux-gnueabihf --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-7 -v --tags arm7 ./cmd/geth
@echo "Linux ARMv7 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep arm-7

geth-linux-arm64:
# requires an arm64 compiler, on Ubuntu: sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
rustup target add aarch64-unknown-linux-gnu
cd $(BLS_RS_PATH) && cargo build --target=aarch64-unknown-linux-gnu --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm64 -v ./cmd/geth
@echo "Linux ARM64 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep arm64

geth-linux-mips:
# requires a mips compiler, on Ubuntu: sudo apt-get install gcc-mips-linux-gnu
rustup target add mips-unknown-linux-gnu
cd $(BLS_RS_PATH) && cargo build --target=mips-unknown-linux-gnu --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips --ldflags '-extldflags "-static"' -v ./cmd/geth
@echo "Linux MIPS cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep mips

geth-linux-mipsle:
# requires a mips compiler, on Ubuntu: sudo apt-get install gcc-mipsel-linux-gnu
rustup target add mipsel-unknown-linux-gnu
cd $(BLS_RS_PATH) && cargo build --target=mipsel-unknown-linux-gnu --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mipsle --ldflags '-extldflags "-static"' -v ./cmd/geth
@echo "Linux MIPSle cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep mipsle

geth-linux-mips64:
# requires a mips compiler, on Ubuntu: sudo apt-get install gcc-mips64-linux-gnuabi64
rustup target add mips64-unknown-linux-gnuabi64
cd $(BLS_RS_PATH) && cargo build --target=mips64-unknown-linux-gnuabi64 --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64 --ldflags '-extldflags "-static"' -v ./cmd/geth
@echo "Linux MIPS64 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep mips64

geth-linux-mips64le:
# requires a mips compiler, on Ubuntu: sudo apt-get install gcc-mips64el-linux-gnuabi64
rustup target add mips64el-unknown-linux-gnuabi64
cd $(BLS_RS_PATH) && cargo build --target=mips64el-unknown-linux-gnuabi64 --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64le --ldflags '-extldflags "-static"' -v ./cmd/geth
@echo "Linux MIPS64le cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep mips64le
Expand All @@ -258,17 +179,13 @@ geth-darwin: geth-darwin-386 geth-darwin-amd64
geth-darwin-386:
# needs include files for asm errno, on Ubuntu: sudo apt-get install linux-libc-dev:i386
# currently doesn't compile on Ubuntu
rustup target add i686-apple-darwin
cd $(BLS_RS_PATH) && cargo build --target=i686-apple-darwin --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=darwin/386 -v ./cmd/geth
@echo "Darwin 386 cross compilation done:"
@ls -ld $(GOBIN)/geth-darwin-* | grep 386

geth-darwin-amd64:
# needs include files for asm errno, on Ubuntu: sudo apt-get install linux-libc-dev
# currently doesn't compile on Ubuntu
rustup target add x86_64-apple-darwin
cd $(BLS_RS_PATH) && cargo build --target=x86_64-apple-darwin --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=darwin/amd64 -v ./cmd/geth
@echo "Darwin amd64 cross compilation done:"
@ls -ld $(GOBIN)/geth-darwin-* | grep amd64
Expand All @@ -279,16 +196,12 @@ geth-windows: geth-windows-386 geth-windows-amd64

geth-windows-386:
# currently doesn't compile on Ubuntu, missing libunwind in xgo
rustup target add i686-pc-windows-msvc
cd $(BLS_RS_PATH) && cargo build --target=i686-pc-windows-msvc --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/386 -v ./cmd/geth
@echo "Windows 386 cross compilation done:"
@ls -ld $(GOBIN)/geth-windows-* | grep 386

geth-windows-amd64:
# currently doesn't compile on Ubuntu, missing libunwind in xgo
rustup target add x86_64-pc-windows-gnu
cd $(BLS_RS_PATH) && cargo build --target=x86_64-pc-windows-gnu --release
build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/amd64 -v ./cmd/geth
@echo "Windows amd64 cross compilation done:"
@ls -ld $(GOBIN)/geth-windows-* | grep amd64
5 changes: 0 additions & 5 deletions accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1596,11 +1596,6 @@ func TestGolangBindings(t *testing.T) {
if out, err := replacer.CombinedOutput(); err != nil {
t.Fatalf("failed to replace binding test dependency to current source tree: %v\n%s", err, out)
}
replacerBls := exec.Command(gocmd, "mod", "edit", "-replace", "github.com/celo-org/bls-zexe/go="+filepath.Join(pwd, "..", "..", "..", "crypto", "bls", "bls-zexe", "go")) //nolint:goimports
replacerBls.Dir = pkg
if out, err := replacerBls.CombinedOutput(); err != nil {
t.Fatalf("failed to replace binding test dependency to current source tree for bls-zexe: %v\n%s", err, out)
}
// Test the entire package and report any failures
cmd := exec.Command(gocmd, "test", "-v", "-count", "1")
cmd.Dir = pkg
Expand Down
2 changes: 1 addition & 1 deletion accounts/keystore/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"time"

//nolint:goimports
"github.com/celo-org/bls-zexe/go/bls"
"github.com/celo-org/celo-bls-go/bls"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down
2 changes: 1 addition & 1 deletion accounts/keystore/passphrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"os"
"path/filepath"

"github.com/celo-org/bls-zexe/go/bls"
"github.com/celo-org/celo-bls-go/bls"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
Expand Down