Skip to content

Commit bb6d8fa

Browse files
authored
feat: enable to use libsodium version ostracon (#793)
* Add libsodium option * Add libsodium submodule * Ignore tools/sodium * Install and link libsodium * Remove debug code * Change to https submodule * Update CHANGELOG * Update ci tests
1 parent 6792efe commit bb6d8fa

File tree

6 files changed

+44
-5
lines changed

6 files changed

+44
-5
lines changed

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ jobs:
138138
USE_PRELOAD: 1,4
139139
SAVE_BRANCH_LAUNCH_DEPTH: 1
140140
run: |
141-
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'
141+
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'
142142
if: env.GIT_DIFF
143143
- uses: actions/upload-artifact@v3
144144
with:
@@ -219,7 +219,7 @@ jobs:
219219
USE_PRELOAD: 1,4
220220
SAVE_BRANCH_LAUNCH_DEPTH: 1
221221
run: |
222-
xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -timeout 30m -race -tags='cgo ledger test_ledger_mock goleveldb'
222+
xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -timeout 30m -race -tags='cgo ledger test_ledger_mock goleveldb libsodium'
223223
if: env.GIT_DIFF
224224
- uses: actions/upload-artifact@v3
225225
with:

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@ dependency-graph.png
5656
*.out
5757
*.synctex.gz
5858

59+
# tools
60+
tools/sodium

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "tools/libsodium"]
2+
path = tools/libsodium
3+
url = https://github.com/algorand/libsodium.git

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
3838
## [Unreleased](https://github.com/line/lbm-sdk/compare/v0.46.0-rc9...HEAD)
3939

4040
### Features
41+
(build) [\#793](https://github.com/line/lbm-sdk/pull/793) enable to use libsodium version ostracon
4142

4243
### Improvements
4344
* (x/auth) [\#776](https://github.com/line/lbm-sdk/pull/776) remove unused MsgEmpty

Makefile

+35-3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ else
6868
endif
6969
endif
7070

71+
# VRF library selection
72+
ifeq (libsodium,$(findstring libsodium,$(LBM_BUILD_OPTIONS)))
73+
CGO_ENABLED=1
74+
BUILD_TAGS += gcc libsodium
75+
LIBSODIUM_TARGET = libsodium
76+
CGO_CFLAGS += "-I$(LIBSODIUM_OS)/include"
77+
CGO_LDFLAGS += "-L$(LIBSODIUM_OS)/lib -lsodium"
78+
endif
79+
7180
# secp256k1 implementation selection
7281
ifeq (libsecp256k1,$(findstring libsecp256k1,$(LBM_BUILD_OPTIONS)))
7382
CGO_ENABLED=1
@@ -115,7 +124,6 @@ include contrib/devtools/Makefile
115124
BUILD_TARGETS := build install
116125

117126
build: BUILD_ARGS=-o $(BUILDDIR)/
118-
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=$(CGO_ENABLED) go build -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...
119127

120128
build-docker: go.sum $(BUILDDIR)/
121129
docker build -t simapp:latest . --platform="linux/amd64" --build-arg ARCH=$(ARCH)
@@ -124,8 +132,8 @@ build-docker: go.sum $(BUILDDIR)/
124132
build-linux:
125133
GOOS=linux GOARCH=$(if $(findstring aarch64,$(shell uname -m)) || $(findstring arm64,$(shell uname -m)),arm64,amd64) LEDGER_ENABLED=false $(MAKE) build
126134

127-
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
128-
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...
135+
$(BUILD_TARGETS): go.sum $(BUILDDIR)/ $(LIBSODIUM_TARGET)
136+
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=$(CGO_ENABLED) go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...
129137

130138
$(BUILDDIR)/:
131139
mkdir -p $(BUILDDIR)/
@@ -536,3 +544,27 @@ rosetta-data:
536544
docker container rm data_dir_build
537545

538546
.PHONY: rosetta-data
547+
548+
###############################################################################
549+
### tools ###
550+
###############################################################################
551+
552+
VRF_ROOT = $(shell pwd)/tools
553+
LIBSODIUM_ROOT = $(VRF_ROOT)/libsodium
554+
LIBSODIUM_OS = $(VRF_ROOT)/sodium/$(shell go env GOOS)_$(shell go env GOARCH)
555+
ifneq ($(TARGET_HOST), "")
556+
LIBSODIUM_HOST = "--host=$(TARGET_HOST)"
557+
endif
558+
559+
libsodium:
560+
@if [ ! -f $(LIBSODIUM_OS)/lib/libsodium.a ]; then \
561+
rm -rf $(LIBSODIUM_ROOT) && \
562+
mkdir $(LIBSODIUM_ROOT) && \
563+
git submodule update --init --recursive && \
564+
cd $(LIBSODIUM_ROOT) && \
565+
./autogen.sh && \
566+
./configure --disable-shared --prefix="$(LIBSODIUM_OS)" $(LIBSODIUM_HOST) && \
567+
$(MAKE) && \
568+
$(MAKE) install; \
569+
fi
570+
.PHONY: libsodium

tools/libsodium

Submodule libsodium added at 004952b

0 commit comments

Comments
 (0)