From b31218f07373363c3fc304bfc9eead12a4a94f9d Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Wed, 9 Nov 2022 18:24:28 +0900 Subject: [PATCH 1/8] Add libsodium option --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 76ba1cabf5..e9122031c3 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,12 @@ else endif endif +# VRF library selection +ifeq (libsodium,$(findstring libsodium,$(LBM_BUILD_OPTIONS))) + CGO_ENABLED=1 + BUILD_TAGS += gcc libsodium +endif + # secp256k1 implementation selection ifeq (libsecp256k1,$(findstring libsecp256k1,$(LBM_BUILD_OPTIONS))) CGO_ENABLED=1 From 21db19360e9aea5b91b856bf8352be07c279650b Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Wed, 9 Nov 2022 18:31:51 +0900 Subject: [PATCH 2/8] Add libsodium submodule --- .gitmodules | 3 +++ tools/libsodium | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 tools/libsodium diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..636951327b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tools/libsodium"] + path = tools/libsodium + url = git@github.com:algorand/libsodium diff --git a/tools/libsodium b/tools/libsodium new file mode 160000 index 0000000000..004952bb57 --- /dev/null +++ b/tools/libsodium @@ -0,0 +1 @@ +Subproject commit 004952bb57b2a6d2c033969820c80255e8362615 From a0939b721f4b05e6c61fa65acd6fe2c9697a274c Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Thu, 10 Nov 2022 14:11:21 +0900 Subject: [PATCH 3/8] Ignore tools/sodium --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ba30e1e40b..99e40be93e 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,5 @@ dependency-graph.png *.out *.synctex.gz +# tools +tools/sodium From dec2575e9de92e387115c5dd3737f612dfad8a5b Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Thu, 10 Nov 2022 14:14:53 +0900 Subject: [PATCH 4/8] Install and link libsodium --- Makefile | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e9122031c3..0b23871f09 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,9 @@ endif 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 @@ -121,7 +124,6 @@ include contrib/devtools/Makefile BUILD_TARGETS := build install build: BUILD_ARGS=-o $(BUILDDIR)/ - CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=$(CGO_ENABLED) go build -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... build-docker: go.sum $(BUILDDIR)/ docker build -t simapp:latest . --platform="linux/amd64" --build-arg ARCH=$(ARCH) @@ -130,8 +132,8 @@ build-docker: go.sum $(BUILDDIR)/ build-linux: GOOS=linux GOARCH=$(if $(findstring aarch64,$(shell uname -m)) || $(findstring arm64,$(shell uname -m)),arm64,amd64) LEDGER_ENABLED=false $(MAKE) build -$(BUILD_TARGETS): go.sum $(BUILDDIR)/ - go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... +$(BUILD_TARGETS): go.sum $(BUILDDIR)/ $(LIBSODIUM_TARGET) + CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=$(CGO_ENABLED) go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ @@ -542,3 +544,28 @@ rosetta-data: docker container rm data_dir_build .PHONY: rosetta-data + +############################################################################### +### 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 && \ + env; \ + fi +.PHONY: libsodium From 75c3a24c0e241ba8c23937c5778b5cce42a80456 Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Fri, 11 Nov 2022 13:13:42 +0900 Subject: [PATCH 5/8] Remove debug code --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0b23871f09..145be45a96 100644 --- a/Makefile +++ b/Makefile @@ -565,7 +565,6 @@ libsodium: ./autogen.sh && \ ./configure --disable-shared --prefix="$(LIBSODIUM_OS)" $(LIBSODIUM_HOST) && \ $(MAKE) && \ - $(MAKE) install && \ - env; \ + $(MAKE) install; \ fi .PHONY: libsodium From 1c4d7ea50765cf53950a71e922e66e497f5d1acd Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Fri, 11 Nov 2022 13:14:21 +0900 Subject: [PATCH 6/8] Change to https submodule --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 636951327b..d1f648c8f9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "tools/libsodium"] path = tools/libsodium - url = git@github.com:algorand/libsodium + url = https://github.com/algorand/libsodium.git From 1d8068f438e45e8946e7a16f70d0999f3b2447e8 Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Mon, 14 Nov 2022 12:19:55 +0900 Subject: [PATCH 7/8] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06b33ccaea..259282ba00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased](https://github.com/line/lbm-sdk/compare/v0.46.0-rc9...HEAD) ### Features +(build) [\#793](https://github.com/line/lbm-sdk/pull/793) enable to use libsodium version ostracon ### Improvements * (x/auth) [\#776](https://github.com/line/lbm-sdk/pull/776) remove unused MsgEmpty From 286833380b293dd146a8d9b7739fae290c5f2793 Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Fri, 11 Nov 2022 19:45:38 +0900 Subject: [PATCH 8/8] Update ci tests --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c7f26841e4..8bab10f7e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -138,7 +138,7 @@ jobs: USE_PRELOAD: 1,4 SAVE_BRANCH_LAUNCH_DEPTH: 1 run: | - cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='norace 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='norace ledger test_ledger_mock goleveldb libsodium' if: env.GIT_DIFF - uses: actions/upload-artifact@v3 with: @@ -219,7 +219,7 @@ jobs: USE_PRELOAD: 1,4 SAVE_BRANCH_LAUNCH_DEPTH: 1 run: | - xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -timeout 30m -race -tags='cgo ledger test_ledger_mock goleveldb' + xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -timeout 30m -race -tags='cgo ledger test_ledger_mock goleveldb libsodium' if: env.GIT_DIFF - uses: actions/upload-artifact@v3 with: