Skip to content

Commit

Permalink
build: refactor BLS library/bindings integration (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
xdustinface authored Dec 1, 2020
1 parent b11b385 commit 6a364b1
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 70 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ terraform.tfstate.backup
terraform.tfstate.d

profile\.out

third_party/bls-signatures/build
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "third_party/bls-signatures/src"]
path = third_party/bls-signatures/src
url = https://github.com/dashpay/bls-signatures
31 changes: 16 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand 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

###############################################################################
Expand Down Expand Up @@ -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

###############################################################################
Expand Down Expand Up @@ -192,8 +195,6 @@ format:

lint:
@echo "--> Running linter"
@export CGO_CXXFLAGS=$(CGO_CXXFLAGS)
@export CGO_LDFLAGS=$(CGO_LDFLAGS)
@golangci-lint run
.PHONY: lint

Expand Down
7 changes: 0 additions & 7 deletions abci/tests/test_app/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"
Expand All @@ -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 "----------------------"

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
23 changes: 0 additions & 23 deletions scripts/build_bls_library.sh

This file was deleted.

3 changes: 0 additions & 3 deletions test/app/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -127,4 +125,3 @@ case "$1" in
echo ""
counter_over_grpc_grpc
esac

2 changes: 1 addition & 1 deletion tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 18 additions & 0 deletions third_party/bls-signatures/build.sh
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions third_party/bls-signatures/install.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions third_party/bls-signatures/src
Submodule src added at 745324

0 comments on commit 6a364b1

Please sign in to comment.