Skip to content

Commit

Permalink
chore: update bls library (#535)
Browse files Browse the repository at this point in the history
* chore: update bls submodule revision

* chore: update bls lib

* chore: update CGO variables in CI

* refactor: remove rocksdb from e2e test, change based image to build e2e docker image
  • Loading branch information
shotonoff authored Dec 22, 2022
1 parent d786bea commit e382768
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 61 deletions.
15 changes: 8 additions & 7 deletions .github/actions/bls/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ runs:
path: ~/bls-cache
key: ${{ runner.os }}-${{ inputs.arch }}-bls-${{ steps.bls-revision.outputs.hash }}
- name: install bls deps
run: sudo apt-get update -qq && sudo apt-get install -qq --yes libgmp-dev libsodium-dev
run: sudo apt-get update -qq && sudo apt-get install -qq --yes libgmp-dev
shell: bash
- name: Build BLS library
run: make build-bls
Expand All @@ -40,12 +40,13 @@ runs:
run: |
mkdir -p ~/bls-cache/include/bls-dash
mkdir -p ~/bls-cache/lib
cp -r ./third_party/bls-signatures/build/_deps/sodium-build/libsodium.a ~/bls-cache/lib
cp -r ./third_party/bls-signatures/build/_deps/relic-build/lib/librelic_s.a ~/bls-cache/lib
cp -r ./third_party/bls-signatures/build/src/libbls-dash.a ~/bls-cache/lib
cp -rv ./third_party/bls-signatures/build/_deps/relic-src/include/* ~/bls-cache/include
cp -rv ./third_party/bls-signatures/build/_deps/relic-build/include/* ~/bls-cache/include
cp -rv ./third_party/bls-signatures/src/src/* ~/bls-cache/include/bls-dash
cp -r ./third_party/bls-signatures/build/depends/minialloc/libminialloc.a ~/bls-cache/lib
cp -r ./third_party/bls-signatures/build/depends/relic/lib/librelic_s.a ~/bls-cache/lib
cp -r ./third_party/bls-signatures/build/src/libdashbls.a ~/bls-cache/lib
cp -rv ./third_party/bls-signatures/build/depends/relic/include/* ~/bls-cache/include
cp -rv ./third_party/bls-signatures/src/depends/minialloc/include/* ~/bls-cache/include
cp -rv ./third_party/bls-signatures/src/depends/relic/include/* ~/bls-cache/include
cp -rv ./third_party/bls-signatures/src/include/* ~/bls-cache/include
if: steps.bls-cache.outputs.cache-hit != 'true'
shell: bash
- uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
timeout-minutes: 25
env:
FULLNODE_PUBKEY_KEEP: false
CGO_LDFLAGS: "-L/usr/local/lib -lbls-dash -lrelic_s -lgmp"
CGO_LDFLAGS: "-L/usr/local/lib -ldashbls -lrelic_s -lgmp -lminialloc"
CGO_CXXFLAGS: "-I/usr/local/include"
steps:
- uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
CGO_LDFLAGS: "-L/usr/local/lib -lbls-dash -lrelic_s -lgmp"
CGO_LDFLAGS: "-L/usr/local/lib -ldashbls -lrelic_s -lgmp -lminialloc"
CGO_CXXFLAGS: "-I/usr/local/include"
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y libpcap-dev
- name: Run Go Tests
env:
CGO_LDFLAGS: "-L/usr/local/lib -lbls-dash -lrelic_s -lgmp"
CGO_LDFLAGS: "-L/usr/local/lib -ldashbls -lrelic_s -lgmp -lminialloc"
CGO_CXXFLAGS: "-I/usr/local/include"
run: |
make test-group-${{ matrix.part }} NUM_SPLIT=6
Expand Down
2 changes: 1 addition & 1 deletion DOCKER/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM golang:1.19-alpine3.17 AS builder

RUN apk update && \
apk upgrade && \
apk add bash git gmp-dev sudo cmake build-base python3-dev libsodium-dev
apk add bash git gmp-dev sudo cmake build-base python3-dev

COPY . /src

Expand Down
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ GOGOPROTO_PATH = $(shell go list -m -f '{{.Dir}}' github.com/gogo/protobuf)
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CURR_DIR := $(dir $(MAKEFILE_PATH))

BLS_DIR="$(CURR_DIR)third_party/bls-signatures/build"
CGO_LDFLAGS ?= "-L$(BLS_DIR)/_deps/sodium-build \
-L$(BLS_DIR)/_deps/relic-build/lib \
-L$(BLS_DIR)/src \
-lbls-dash -lrelic_s -lgmp"
BLS_DIR="$(CURR_DIR)third_party/bls-signatures"

CGO_CXXFLAGS ?= "-I$(BLS_DIR)/_deps/relic-src/include \
-I$(BLS_DIR)/_deps/relic-build/include \
-I$(BLS_DIR)/src"
CGO_LDFLAGS ?= "-L$(BLS_DIR)/build/depends/minialloc \
-L$(BLS_DIR)/build/depends/relic/lib \
-L$(BLS_DIR)/build/src \
-ldashbls -lrelic_s -lgmp -lminialloc"

CGO_CXXFLAGS ?= "-I$(BLS_DIR)/build/depends/relic/include \
-I$(BLS_DIR)/src/depends/minialloc/include \
-I$(BLS_DIR)/src/depends/relic/include \
-I$(BLS_DIR)/src/include"

GO := CGO_ENABLED=$(CGO_ENABLED) CGO_CXXFLAGS=$(CGO_CXXFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) go

Expand Down Expand Up @@ -180,11 +182,11 @@ proto-doc:
###############################################################################

build_abci:
$(GO) go build -mod=readonly ./abci/cmd/...
$(GO) build -mod=readonly ./abci/cmd/...
.PHONY: build_abci

install_abci:
$(GO) go install -mod=readonly ./abci/cmd/...
$(GO) install -mod=readonly ./abci/cmd/...
.PHONY: install_abci


Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/containerd/continuity v0.3.0 // indirect
github.com/dashevo/dashd-go v0.23.4
github.com/dashevo/dashd-go/btcec/v2 v2.0.6 // indirect
github.com/dashpay/bls-signatures/go-bindings v0.0.0-20220324185745-cc53ca3c3a43 // indirect
github.com/dashpay/bls-signatures/go-bindings v0.0.0-20221214161719-85b7e61b5573
github.com/fortytw2/leaktest v1.3.0
github.com/fxamacker/cbor/v2 v2.4.0
github.com/go-chi/chi v4.1.2+incompatible // indirect
Expand Down Expand Up @@ -69,6 +69,7 @@ require (
github.com/go-pkgz/rest v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
)

Expand Down Expand Up @@ -229,7 +230,6 @@ require (
github.com/subosito/gotenv v1.4.0 // indirect
github.com/sylvia7788/contextcheck v1.0.4 // indirect
github.com/tdakkota/asciicheck v0.1.1 // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/tetafro/godot v1.4.11 // indirect
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 // indirect
github.com/tomarrell/wrapcheck/v2 v2.6.2 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,8 @@ github.com/dashevo/dashd-go/btcec/v2 v2.0.6/go.mod h1:fcMpVeKkJ7m6SklsT69jAt14xP
github.com/dashevo/dashd-go/btcutil v1.0.0-test.1/go.mod h1:2mhE2Kk98m0S+AO62DEyjfL7eQZBnEROM0qPP0nNl4g=
github.com/dashevo/dashd-go/btcutil v1.1.1 h1:BLjyMXXNQNyt4316qBo6yjsi/EufQvYfBxAECQm8WqY=
github.com/dashevo/dashd-go/btcutil v1.1.1/go.mod h1:BFNwyGUxqY1rJR6Mrxyw6dyHmyykKK7jIZu/ZdrTXXA=
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/dashpay/bls-signatures/go-bindings v0.0.0-20220324185745-cc53ca3c3a43 h1:Xov8Q6ig10jzQ5X7LaWJ36zTYOAQtnAu+2sbY9lSn1U=
github.com/dashpay/bls-signatures/go-bindings v0.0.0-20220324185745-cc53ca3c3a43/go.mod h1:auvGS60NBZ+a21aCCQh366PdsjDvHinsCvl28VrYPu4=
github.com/dashpay/bls-signatures/go-bindings v0.0.0-20221214161719-85b7e61b5573 h1:Jli26uNKAteXvVo4XXyrbfCl5lqL8zMJ9QQR1UfunCs=
github.com/dashpay/bls-signatures/go-bindings v0.0.0-20221214161719-85b7e61b5573/go.mod h1:auvGS60NBZ+a21aCCQh366PdsjDvHinsCvl28VrYPu4=
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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=
Expand Down
10 changes: 5 additions & 5 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,26 @@ vagrant_test:
### go tests
test:
@echo "--> Running go test"
CGO_ENABLED=$(CGO_ENABLED) go test -p 1 $(PACKAGES) -tags deadlock
$(GO) test -p 1 $(PACKAGES) -tags deadlock
.PHONY: test

test_verbose:
@echo "--> Running go test"
CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_CXXFLAGS=$(CGO_CXXFLAGS) go test -p 1 -v $(PACKAGES)
$(GO) test -p 1 -v $(PACKAGES)
.PHONY: test

test_race:
@echo "--> Running go test --race"
@go test -p 1 -race $(PACKAGES)
$(GO) test -p 1 -race $(PACKAGES)
.PHONY: test_race

test_race_verbose:
@echo "--> Running go test --race"
@go test -p 1 -v -race $(PACKAGES)
$(GO) test -p 1 -v -race $(PACKAGES)
.PHONY: test_race


test_deadlock:
@echo "--> Running go test --deadlock"
@go test -p 1 -v $(PACKAGES) -tags deadlock
$(GO) test -p 1 -v $(PACKAGES) -tags deadlock
.PHONY: test_race
23 changes: 19 additions & 4 deletions test/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@ ROOT_PATH := $(abspath $(lastword $(MAKEFILE_LIST)/../../../))

all: docker generator runner tests

CGO_ENABLED ?= 1

BLS_DIR="$(ROOT_PATH)/third_party/bls-signatures"
CGO_LDFLAGS ?= -L$(BLS_DIR)/build/depends/minialloc \
-L$(BLS_DIR)/build/depends/relic/lib \
-L$(BLS_DIR)/build/src \
-ldashbls -lrelic_s -lgmp -lminialloc

CGO_CXXFLAGS ?= -I$(BLS_DIR)/build/depends/relic/include \
-I$(BLS_DIR)/src/depends/minialloc/include \
-I$(BLS_DIR)/src/depends/relic/include \
-I$(BLS_DIR)/src/include

GO := CGO_ENABLED=$(CGO_ENABLED) CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go

docker:
docker build --tag tenderdash/e2e-node -f docker/Dockerfile ../..

node:
GOTRACEBACK=crash go build -gcflags="all=-N -l" -o build/node -tags badgerdb,boltdb,cleveldb,rocksdb,deadlock ./node
GOTRACEBACK=crash $(GO) build -gcflags="all=-N -l" -o build/node -tags badgerdb,boltdb,cleveldb,deadlock ./node

e2e/app/compile:
docker run --rm -it --entrypoint "/src/tenderdash/test/e2e/entrypoint.sh" -w "/src/tenderdash/test/e2e" -v $(ROOT_PATH)/test/e2e:/src/tenderdash/test/e2e tenderdash/e2e-node
Expand All @@ -24,12 +39,12 @@ runner/rotate: runner tests e2e/app/compile
./build/runner -f networks/rotate.toml

generator:
go build -o build/generator ./generator
$(GO) build -o build/generator ./generator

runner:
go build -o build/runner ./runner
$(GO) build -o build/runner ./runner

tests:
go test -o build/tests ./tests
$(GO) test -o build/tests ./tests

.PHONY: all docker generator runner tests node
24 changes: 8 additions & 16 deletions test/e2e/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# We need to build in a Linux environment to support C libraries, e.g. RocksDB.
# We need to build in a Linux environment to support C libraries
# We use Debian instead of Alpine, so that we can use binary database packages
# instead of spending time compiling them.
FROM golang:1.19-bullseye
FROM golang:1.19-alpine3.17

RUN apt-get -qq update -y && apt-get -qq upgrade -y >/dev/null
RUN apt-get -qq install -y cmake sudo libsodium-dev libgmp-dev libleveldb-dev librocksdb-dev python3-dev >/dev/null
RUN apk update && \
apk upgrade && \
apk add bash git gmp-dev sudo cmake build-base python3-dev leveldb-dev

# Set up build directory /src/tenderdash
WORKDIR /src/tenderdash
Expand All @@ -17,22 +18,13 @@ RUN go install github.com/go-delve/delve/cmd/dlv@latest
COPY go.mod go.sum ./
RUN go mod download

# Install BLS library
COPY third_party ./third_party
COPY test/Makefile ./test/Makefile
COPY Makefile ./
RUN make build-bls

ENV CGO_ENABLE=1
COPY .git ./.git

ENV CGO_LDFLAGS="-L/src/tenderdash/third_party/bls-signatures/build/_deps/sodium-build \
-L/src/tenderdash/third_party/bls-signatures/build/_deps/relic-build/lib \
-L/src/tenderdash/third_party/bls-signatures/build/src \
-lbls-dash -lrelic_s -lgmp"

ENV CGO_CXXFLAGS="-I/src/tenderdash/third_party/bls-signatures/build/_deps/relic-src/include \
-I/src/tenderdash/third_party/bls-signatures/build/_deps/relic-build/include \
-I/src/tenderdash/third_party/bls-signatures/build/src"
# Install BLS library
RUN make build-bls

# Copy Tenderdash source
COPY . .
Expand Down
1 change: 0 additions & 1 deletion test/e2e/generator/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var (
"goleveldb": 35,
"badgerdb": 35,
"boltdb": 15,
"rocksdb": 10,
"cleveldb": 5,
}
ABCIProtocols = weightedChoice{
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/networks/ci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ retain_blocks = 10

[node.validator04]
snapshot_interval = 5
database = "rocksdb"
database = "badgerdb"
persistent_peers = ["validator01"]
perturb = ["pause"]
block_sync = "v0"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/networks/dashcore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ perturb = ["kill"]

[node.validator04]
persistent_peers = ["validator01"]
database = "rocksdb"
database = "badgerdb"
abci_protocol = "builtin"
privval_protocol = "dashcore"
perturb = ["pause"]
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/networks/island.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ retain_blocks = 3
perturb = ["kill"]

[node.validator04]
database = "rocksdb"
database = "badgerdb"
abci_protocol = "builtin"
privval_protocol = "dashcore"
perturb = ["pause"]
Expand All @@ -69,7 +69,7 @@ privval_protocol = "dashcore"
perturb = ["kill", "pause", "disconnect", "restart"]

[node.validator06]
database = "rocksdb"
database = "cleveldb"
fast_sync = "v0"
privval_protocol = "dashcore"

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/networks/rotate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ perturb = ["kill"]

[node.validator04]
persistent_peers = ["validator01"]
database = "rocksdb"
database = "cleveldb"
abci_protocol = "builtin"
privval_protocol = "dashcore"
perturb = ["pause"]
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pkg/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func (n Node) Validate(testnet Testnet) error {
return fmt.Errorf("unsupported p2p queue type: %s", n.QueueType)
}
switch n.Database {
case "goleveldb", "cleveldb", "boltdb", "rocksdb", "badgerdb":
case "goleveldb", "cleveldb", "boltdb", "badgerdb":
default:
return fmt.Errorf("invalid database setting %q", n.Database)
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/bls-signatures/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SRC_PATH="$SCRIPT_PATH/src"
BUILD_PATH="$SCRIPT_PATH/build"
BLS_SM_PATH="third_party/bls-signatures/src"
BLS_GIT_REPO="https://github.com/dashpay/bls-signatures.git"
BLS_GIT_BRANCH="develop_0.1"
BLS_GIT_BRANCH="develop"

git submodule update --init $BLS_SM_PATH
if [ $? -ne 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion third_party/bls-signatures/src
Submodule src updated 778 files

0 comments on commit e382768

Please sign in to comment.