diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index a0fe53b4f..9617d64de 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -8,6 +8,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + submodules: recursive - name: Create a file with all the pkgs run: go list ./... > pkgs.txt - name: Split pkgs into 4 files diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a4efa271a..0b7a825ca 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,6 +15,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master + - name: Checkout submodules + uses: textbook/git-checkout-submodule-action@master - name: Prepare id: prep run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cd8d36fd4..db8597409 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,6 +27,8 @@ jobs: with: go-version: "^1.15.4" - uses: actions/checkout@v2 + with: + submodules: recursive - uses: technote-space/get-diff-action@v4 with: PATTERNS: | diff --git a/DOCKER/Dockerfile b/DOCKER/Dockerfile index f2e39afbc..960b96175 100644 --- a/DOCKER/Dockerfile +++ b/DOCKER/Dockerfile @@ -2,8 +2,8 @@ FROM golang:1.15-alpine as builder RUN apk update && \ apk upgrade && \ - apk add --no-cache git make gcc libc-dev build-base curl jq bash file gmp-dev clang -COPY / /ostracon + apk add --no-cache git make gcc libc-dev build-base curl jq bash file gmp-dev clang libtool autoconf automake +COPY . /ostracon/ WORKDIR /ostracon RUN make build-linux @@ -25,7 +25,7 @@ ENV TMHOME /ostracon # could execute bash commands. RUN apk update && \ apk upgrade && \ - apk add --no-cache git make gcc libc-dev build-base curl jq bash file gmp-dev clang && \ + apk add --no-cache git make gcc libc-dev build-base curl jq bash file gmp-dev clang libtool autoconf automake && \ addgroup ostracon && \ adduser -S -G ostracon ostracon -h "$TMHOME" diff --git a/Makefile b/Makefile index 87609575e..e05a71952 100644 --- a/Makefile +++ b/Makefile @@ -3,21 +3,15 @@ SRCPATH=$(shell pwd) OUTPUT?=build/ostracon INCLUDE = -I=${GOPATH}/src/github.com/line/ostracon -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protobuf -BUILD_TAGS?='ostracon' +BUILD_TAGS ?= ostracon VERSION := $(shell git describe --always) -CGO_OPTPTION=0 -LIBSODIUM_TARGET= -PREPARE_LIBSODIUM_TARGET= +LIBSODIUM=1 ifeq ($(LIBSODIUM), 1) - BUILD_TAGS='libsodium ostracon' - LIBSODIUM_TARGET=libsodium -ifneq ($(OS), Windows_NT) -ifeq ($(shell uname -s), Linux) - PREPARE_LIBSODIUM_TARGET=prepare-libsodium-linux + BUILD_TAGS += libsodium + LIBSODIUM_TARGET = libsodium +else + LIBSODIUM_TARGET = endif -endif -endif -LIBSODIM_BUILD_TAGS='libsodium ostracon' LD_FLAGS = -X github.com/line/ostracon/version.Version=$(VERSION) BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)" HTTPS_GIT := https://github.com/line/ostracon.git @@ -72,7 +66,7 @@ build: $(LIBSODIUM_TARGET) CGO_ENABLED=1 go build $(BUILD_FLAGS) -tags "$(BUILD_TAGS)" -o $(OUTPUT) ./cmd/ostracon/ .PHONY: build -install: +install: build CGO_ENABLED=1 go install $(BUILD_FLAGS) -tags "$(BUILD_TAGS)" ./cmd/ostracon .PHONY: install @@ -151,15 +145,28 @@ install_abci: ######################################## ### libsodium +ifeq ($(shell uname -s), Darwin) +prepare-libsodium-linux: + brew install libtool autoconf automake +else +ifeq ($(shall uname -s), Linux) prepare-libsodium-linux: apt-get update && apt-get -y install libtool libboost-all-dev autoconf build-essential +else +prepare-libsodium-linux: + @echo "$(error This platform isn't supported. Please build libsodium manually.)" +endif +endif libsodium: - cd $(SRCPATH)/crypto/vrf/internal/vrf/libsodium && \ - ./autogen.sh && \ - ./configure --disable-shared --prefix="$(SRCPATH)/crypto/vrf/internal/vrf/" && \ - $(MAKE) && \ - $(MAKE) install + @if [ ! -f $(SRCPATH)/crypto/vrf/internal/vrf/lib/libsodium.a ]; then \ + cd $(SRCPATH)/crypto/vrf/internal/vrf/libsodium && \ + ./autogen.sh && \ + ./configure --disable-shared --prefix="$(SRCPATH)/crypto/vrf/internal/vrf/" && \ + $(MAKE) && \ + $(MAKE) install; \ + fi +.PHONY: libsodium ######################################## ### Distribution @@ -287,8 +294,9 @@ DOCKER_CMD = docker run --rm \ -v `pwd`:$(DOCKER_HOME) \ -w $(DOCKER_HOME) DOCKER_IMG = golang:1.15-alpine -BUILD_CMD = apk add --update --no-cache git make gcc libc-dev build-base curl jq file gmp-dev clang \ +BUILD_CMD = apk add --update --no-cache git make gcc libc-dev build-base curl jq file gmp-dev clang libtool autoconf automake \ && cd $(DOCKER_HOME) \ + && make libsodium \ && make build-linux # Login docker-container for confirmation building linux binary diff --git a/crypto/vrf/vrf_libsodium.go b/crypto/vrf/vrf_libsodium.go index 475850dfd..31e153e09 100644 --- a/crypto/vrf/vrf_libsodium.go +++ b/crypto/vrf/vrf_libsodium.go @@ -23,7 +23,7 @@ func init() { } func (base vrfImplLibsodium) Prove(privateKey []byte, message []byte) (Proof, error) { - privKey := (*[libsodium.SECRETKEYBYTES]byte)(unsafe.Pointer(&(*privateKey))) + privKey := (*[libsodium.SECRETKEYBYTES]byte)(unsafe.Pointer(&privateKey)) pf, err := libsodium.Prove(privKey, message) if err != nil { return nil, err diff --git a/networks/local/localnode/Dockerfile b/networks/local/localnode/Dockerfile index 8499ea93f..ca9ad8418 100644 --- a/networks/local/localnode/Dockerfile +++ b/networks/local/localnode/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.15-alpine RUN apk update && \ apk upgrade && \ - apk add --no-cache git make gcc libc-dev build-base curl jq bash file gmp-dev clang + apk add --no-cache git make gcc libc-dev build-base curl jq bash file gmp-dev clang libtool autoconf automake VOLUME [ "/ostracon" ] WORKDIR /ostracon diff --git a/tests.mk b/tests.mk index 224a3874b..4c586ba4b 100644 --- a/tests.mk +++ b/tests.mk @@ -59,7 +59,7 @@ vagrant_test: .PHONY: vagrant_test ### go tests -test: +test: build @echo "--> Running go test" @go test -p 1 $(PACKAGES) -tags deadlock .PHONY: test