diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 435bc24f48..f41fc04538 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -54,18 +54,9 @@ jobs: with: name: "${{ github.sha }}-${{ matrix.part }}" if: env.GIT_DIFF - - name: Set GOPATH - run: | - echo "::set-env name=GOPATH::$(go env GOPATH)" - - name: Set CGO_LDFLAGS - run: | - echo "::set-env name=CGO_LDFLAGS::"-L${GOPATH}/src/github.com/dashpay/bls-signatures/build"" - - name: Set CGO_CXXFLAGS - run: | - echo "::set-env name=CGO_CXXFLAGS::"-I${GOPATH}/src/github.com/dashpay/bls-signatures/src -I${GOPATH}/src/github.com/dashpay/bls-signatures/contrib/relic/include -I${GOPATH}/src/github.com/dashpay/bls-signatures/build/contrib/relic/include"" - name: test & coverage report creation run: | - (echo "Gopath: $CGO_CXXFLAGS") && (cat pkgs.txt.part.${{ matrix.part }} | xargs CGO_CXXFLAGS="$CGO_CXXFLAGS" CGO_LDFLAGS="$CGO_LDFLAGS" go test -mod=readonly -timeout 8m -race -coverprofile=${{ matrix.part }}profile.out -covermode=atomic) + cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 8m -race -coverprofile=${{ matrix.part }}profile.out -covermode=atomic if: env.GIT_DIFF - uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 3be72454fc..3df22ee8a8 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -13,16 +13,6 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 4 steps: - - name: Set GOPATH - run: | - echo "::set-env name=GOPATH::$(go env GOPATH)" - - name: Set CGO_LDFLAGS - run: | - echo "::set-env name=CGO_LDFLAGS::"-L${GOPATH}/src/github.com/dashpay/bls-signatures/build"" - - name: Set CGO_CXXFLAGS - run: | - echo "::set-env name=CGO_CXXFLAGS::"-I${GOPATH}/src/github.com/dashpay/bls-signatures/src -I${GOPATH}/src/github.com/dashpay/bls-signatures/contrib/relic/include -I${GOPATH}/src/github.com/dashpay/bls-signatures/build/contrib/relic/include"" - - name: test & coverage report creation - uses: actions/checkout@v2 - uses: technote-space/get-diff-action@v4 with: diff --git a/.gitignore b/.gitignore index a1e17329e3..2788df9043 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,5 @@ terraform.tfstate.backup terraform.tfstate.d profile\.out + +third_party/bls-signatures/build diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..f7b7db4241 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "third_party/bls-signatures/src"] + path = third_party/bls-signatures/src + url = https://github.com/dashpay/bls-signatures diff --git a/Makefile b/Makefile index 35d63644dc..fb67da531e 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,6 @@ REPO_NAME=github.com/dashevo/tenderdash BUILD_TAGS?=tendermint VERSION := $(shell git describe --always) LD_FLAGS = -X ${REPO_NAME}/version.TMCoreSemVer=$(VERSION) -CGO_LDFLAGS = "-L${GOPATH}/src/github.com/dashpay/bls-signatures/build" -CGO_CXXFLAGS = "-I${GOPATH}/src/github.com/dashpay/bls-signatures/src -I${GOPATH}/src/github.com/dashpay/bls-signatures/contrib/relic/include -I${GOPATH}/src/github.com/dashpay/bls-signatures/build/contrib/relic/include" BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)" HTTPS_GIT := https://${REPO_NAME}.git DOCKER_BUF := docker run -v $(shell pwd):/workspace --workdir /workspace bufbuild/buf @@ -49,9 +47,9 @@ endif # allow users to pass additional flags via the conventional LDFLAGS variable LD_FLAGS += $(LDFLAGS) -all: check bls_bindings_build build test install -install: bls_bindings_build -build: bls_bindings_build +all: check build test install +build: build-bls +install: install-bls .PHONY: all @@ -60,22 +58,27 @@ include tools.mk include tests.mk ############################################################################### -### Build BLS library ### +### Build/Install BLS library ### ############################################################################### -bls_bindings_build: - @sh scripts/build_bls_library.sh -.PHONY: bls_bindings_build + +build-bls: + @third_party/bls-signatures/build.sh +.PHONY: build-bls + +install-bls: build-bls + @sudo third_party/bls-signatures/install.sh +.PHONY: install-bls ############################################################################### ### Build Tendermint ### ############################################################################### build: - CGO_CXXFLAGS=$(CGO_CXXFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o $(OUTPUT) ./cmd/tendermint/ + CGO_ENABLED=$(CGO_ENABLED) go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o $(OUTPUT) ./cmd/tendermint/ .PHONY: build install: - CGO_CXXFLAGS=$(CGO_CXXFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint + CGO_ENABLED=$(CGO_ENABLED) go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint .PHONY: install ############################################################################### @@ -121,11 +124,11 @@ proto-check-breaking-ci: ############################################################################### build_abci: - CGO_CXXFLAGS=$(CGO_CXXFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) go build -mod=readonly -i ./abci/cmd/... + @go build -mod=readonly -i ./abci/cmd/... .PHONY: build_abci install_abci: - CGO_CXXFLAGS=$(CGO_CXXFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) go install -mod=readonly ./abci/cmd/... + @go install -mod=readonly ./abci/cmd/... .PHONY: install_abci ############################################################################### @@ -192,8 +195,6 @@ format: lint: @echo "--> Running linter" - @export CGO_CXXFLAGS=$(CGO_CXXFLAGS) - @export CGO_LDFLAGS=$(CGO_LDFLAGS) @golangci-lint run .PHONY: lint diff --git a/abci/tests/test_app/test.sh b/abci/tests/test_app/test.sh index 9092a75ede..5747154ba6 100755 --- a/abci/tests/test_app/test.sh +++ b/abci/tests/test_app/test.sh @@ -2,12 +2,6 @@ set -e # These tests spawn the counter app and server by execing the ABCI_APP command and run some simple client tests against it - -GOPATH=$(go env GOPATH) -export CGO_ENABLED="1" -export CGO_LDFLAGS="-L${GOPATH}/src/github.com/dashpay/bls-signatures/build" -export CGO_CXXFLAGS="-I${GOPATH}/src/github.com/dashpay/bls-signatures/src -I${GOPATH}/src/github.com/dashpay/bls-signatures/contrib/relic/include -I${GOPATH}/src/github.com/dashpay/bls-signatures/build/contrib/relic/include" - # Get the directory of where this script is. export PATH="$GOBIN:$PATH" SOURCE="${BASH_SOURCE[0]}" @@ -26,7 +20,6 @@ echo "----------------------" echo "RUN COUNTER OVER GRPC" # test golang counter via grpc -echo "CGO_CXXFLAGS="$CGO_CXXFLAGS" CGO_LDFLAGS="$CGO_LDFLAGS" ABCI_APP="counter --abci=grpc" ABCI="grpc" go run -mod=readonly ./*.go" ABCI_APP="counter --abci=grpc" ABCI="grpc" go run -mod=readonly ./*.go echo "----------------------" diff --git a/go.mod b/go.mod index 9ae3618caf..b25bd292f0 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/btcsuite/btcutil v1.0.2 github.com/confio/ics23/go v0.6.3 github.com/cosmos/iavl v0.15.0-rc5 - github.com/dashpay/bls-signatures/go-bindings v0.0.0-20201119162734-497e2f1bb053 + github.com/dashpay/bls-signatures/go-bindings v0.0.0-20201127091120-745324b80143 github.com/fortytw2/leaktest v1.3.0 github.com/go-kit/kit v0.10.0 github.com/go-logfmt/logfmt v0.5.0 diff --git a/go.sum b/go.sum index bb21f8972f..f6914f11ad 100644 --- a/go.sum +++ b/go.sum @@ -103,6 +103,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/dashpay/bls-signatures/go-bindings v0.0.0-20201119162734-497e2f1bb053 h1:6DEUzGdE5fxvfkiE8VDg6R5G1XHqHXtKqcGttlqpN2M= github.com/dashpay/bls-signatures/go-bindings v0.0.0-20201119162734-497e2f1bb053/go.mod h1:wO0DBQIumICIPq4cWwH3LTxdD6gnHrX2XkUpah5Lj1o= +github.com/dashpay/bls-signatures/go-bindings v0.0.0-20201127091120-745324b80143 h1:Q13WvpP9zZTmQy7O3q2tCXHXOB+dM0nnvPu7TuSieQQ= +github.com/dashpay/bls-signatures/go-bindings v0.0.0-20201127091120-745324b80143/go.mod h1:wO0DBQIumICIPq4cWwH3LTxdD6gnHrX2XkUpah5Lj1o= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/scripts/build_bls_library.sh b/scripts/build_bls_library.sh deleted file mode 100755 index 6547ce9472..0000000000 --- a/scripts/build_bls_library.sh +++ /dev/null @@ -1,23 +0,0 @@ -GOPATH=$(go env GOPATH) -BLS_REPO_PATH="${GOPATH}"/src/github.com/dashpay/bls-signatures - -# Install packages for bindings -GO111MODULE=off go get golang.org/x/tools/cmd/goimports -GO111MODULE=off go get golang.org/x/lint/golint - -# Cleaning previous build -rm -rf "${BLS_REPO_PATH}" -mkdir -pv "${GOPATH}"/github.com/quantumexplorer/ - -# Cloning bls repo and fetching dependencies -git clone https://github.com/dashpay/bls-signatures.git "$BLS_REPO_PATH" -cd "$BLS_REPO_PATH" -git submodule update --init --recursive - -# Build the bindings -mkdir build -cd build -cmake ../ -cmake --build . -- -j 6 -cd "${BLS_REPO_PATH}"/go-bindings -make diff --git a/test/app/test.sh b/test/app/test.sh index 2ee43092dd..b5fabafa19 100755 --- a/test/app/test.sh +++ b/test/app/test.sh @@ -11,8 +11,6 @@ set -ex GOPATH=$(go env GOPATH) export PATH="$GOBIN:$PATH" export TMHOME=$HOME/.tendermint_app -export CGO_LDFLAGS="-L${GOPATH}/src/github.com/dashpay/bls-signatures/build" -export CGO_CXXFLAGS="-I${GOPATH}/src/github.com/dashpay/bls-signatures/src -I${GOPATH}/src/github.com/dashpay/bls-signatures/contrib/relic/include -I${GOPATH}/src/github.com/dashpay/bls-signatures/build/contrib/relic/include" function kvstore_over_socket(){ rm -rf $TMHOME @@ -127,4 +125,3 @@ case "$1" in echo "" counter_over_grpc_grpc esac - diff --git a/tests.mk b/tests.mk index 090ea7e651..ddc136635e 100644 --- a/tests.mk +++ b/tests.mk @@ -60,7 +60,7 @@ vagrant_test: ### go tests test: @echo "--> Running go test" - CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_CXXFLAGS=$(CGO_CXXFLAGS) go test -p 1 $(PACKAGES) -tags deadlock + @go test -p 1 $(PACKAGES) -tags deadlock .PHONY: test test_race: diff --git a/third_party/bls-signatures/build.sh b/third_party/bls-signatures/build.sh new file mode 100755 index 0000000000..65c3d14afc --- /dev/null +++ b/third_party/bls-signatures/build.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +SRC_PATH="$SCRIPT_PATH/src" +BUILD_PATH="$SCRIPT_PATH/build" + +git submodule update --init third_party/bls-signatures/src + +# Create folders for source and build data +mkdir -p $BUILD_PATH + +# Configurate the library build +cmake -B $BUILD_PATH -S $SRC_PATH + +# Build the library +make -C $BUILD_PATH + +exit 0 diff --git a/third_party/bls-signatures/install.sh b/third_party/bls-signatures/install.sh new file mode 100755 index 0000000000..cbe19a3653 --- /dev/null +++ b/third_party/bls-signatures/install.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +BUILD_PATH="$SCRIPT_PATH/build" + +if [ ! -d $BUILD_PATH ]; then + echo "$BUILD_PATH doesn't exist. Run \"make build-bls\" first." >/dev/stderr + exit 1 +fi + +# Install the library +make -C $BUILD_PATH install + +exit 0 diff --git a/third_party/bls-signatures/src b/third_party/bls-signatures/src new file mode 160000 index 0000000000..745324b801 --- /dev/null +++ b/third_party/bls-signatures/src @@ -0,0 +1 @@ +Subproject commit 745324b801439fde199da1586f1b5d7c9b4c7070