Skip to content

Commit

Permalink
feat: enable to use libsodium version ostracon (#113)
Browse files Browse the repository at this point in the history
* Add libsodium submodule

* Enable to use libsodium

* Update CHANGELOG

* Update ci tests

* Set LF
  • Loading branch information
ulbqb authored Nov 14, 2022
1 parent 31bcd5f commit 7dd4bb5
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
if: env.GIT_DIFF
- name: test & coverage report creation
run: |
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='ledger test_ledger_mock goleveldb'
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='ledger test_ledger_mock goleveldb libsodium'
if: env.GIT_DIFF
- uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -184,7 +184,7 @@ jobs:
if: env.GIT_DIFF
- name: test & coverage report creation
run: |
xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -json -timeout 30m -tags='cli_test goleveldb' | tee ${{ matrix.part }}-integration-output.txt
xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -json -timeout 30m -tags='cli_test goleveldb libsodium' | tee ${{ matrix.part }}-integration-output.txt
if: env.GIT_DIFF
- uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -252,7 +252,7 @@ jobs:
if: env.GIT_DIFF
- name: test report creation
run: |
xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -json -timeout 30m -tags='cli_multi_node_test goleveldb' | tee ${{ matrix.part }}-integration-multi-node-output.txt
xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -json -timeout 30m -tags='cli_multi_node_test goleveldb libsodium' | tee ${{ matrix.part }}-integration-multi-node-output.txt
if: env.GIT_DIFF
- uses: actions/upload-artifact@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ dependency-graph.png
*.aux
*.out
*.synctex.gz

# tools
tools/sodium
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tools/libsodium"]
path = tools/libsodium
url = https://github.com/algorand/libsodium.git
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#108](https://github.com/line/lbm/pull/108) Bump github.com/line/lbm-sdk from e19f863a8 to a389b6330
* [\#110](https://github.com/line/lbm/pull/110) apply GovMint on x/foundation
* [\#111](https://github.com/line/lbm/pull/111) Bump github.com/line/lbm-sdk from 66988a235 to 0.46.0-rc9
* (build) [\#113](https://github.com/line/lbm/pull/113) enable to use libsodium version ostracon

### Improvements

Expand Down
38 changes: 36 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ else
endif
endif

# VRF library selection
ifeq (libsodium,$(findstring libsodium,$(LBM_BUILD_OPTIONS)))
CGO_ENABLED=1
BUILD_TAGS += gcc libsodium
LIBSODIUM_TARGET = libsodium
CGO_CFLAGS += "-I$(LIBSODIUM_OS)/include"
CGO_LDFLAGS += "-L$(LIBSODIUM_OS)/lib -lsodium"
endif


# secp256k1 implementation selection
ifeq (libsecp256k1,$(findstring libsecp256k1,$(LBM_BUILD_OPTIONS)))
CGO_ENABLED=1
Expand Down Expand Up @@ -133,7 +143,7 @@ all: install lint test

build: BUILD_ARGS=-o $(BUILDDIR)/

build: go.sum $(BUILDDIR)/ dbbackend
build: go.sum $(BUILDDIR)/ dbbackend $(LIBSODIUM_TARGET)
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=$(CGO_ENABLED) go build -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...

build-static: go.sum $(BUILDDIR)/
Expand All @@ -143,7 +153,7 @@ build-static-centos7: go.sum $(BUILDDIR)/
docker build -t line/lbm-builder:static_centos7 -f builders/Dockerfile.static_centos7 .
docker run -it --rm -v $(shell pwd):/code -e LBM_BUILD_OPTIONS="$(LBM_BUILD_OPTIONS)" line/lbm-builder:static_centos7

install: go.sum $(BUILDDIR)/ dbbackend
install: go.sum $(BUILDDIR)/ dbbackend $(LIBSODIUM_TARGET)
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=$(CGO_ENABLED) go install $(BUILD_FLAGS) $(BUILD_ARGS) ./cmd/lbm

$(BUILDDIR)/:
Expand Down Expand Up @@ -328,3 +338,27 @@ test-docker-push: test-docker
benchmark \
build-docker-lbmnode localnet-start localnet-stop \
docker-single-node

###############################################################################
### tools ###
###############################################################################

VRF_ROOT = $(shell pwd)/tools
LIBSODIUM_ROOT = $(VRF_ROOT)/libsodium
LIBSODIUM_OS = $(VRF_ROOT)/sodium/$(shell go env GOOS)_$(shell go env GOARCH)
ifneq ($(TARGET_HOST), "")
LIBSODIUM_HOST = "--host=$(TARGET_HOST)"
endif

libsodium:
@if [ ! -f $(LIBSODIUM_OS)/lib/libsodium.a ]; then \
rm -rf $(LIBSODIUM_ROOT) && \
mkdir $(LIBSODIUM_ROOT) && \
git submodule update --init --recursive && \
cd $(LIBSODIUM_ROOT) && \
./autogen.sh && \
./configure --disable-shared --prefix="$(LIBSODIUM_OS)" $(LIBSODIUM_HOST) && \
$(MAKE) && \
$(MAKE) install; \
fi
.PHONY: libsodium
1 change: 1 addition & 0 deletions tools/libsodium
Submodule libsodium added at 004952

0 comments on commit 7dd4bb5

Please sign in to comment.