Skip to content

Commit

Permalink
feat: make RLN available by default
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Sep 12, 2023
1 parent 2aea2f5 commit 0799d2e
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 40 deletions.
3 changes: 0 additions & 3 deletions .golangci.yaml

This file was deleted.

14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ BUILD_FLAGS ?= $(shell echo "-ldflags='\
ANDROID_TARGET ?= 23

# control rln code compilation
ifeq ($(RLN), true)
BUILD_TAGS := gowaku_rln
ifeq ($(NO_RLN), true)
BUILD_TAGS := gowaku_no_rln
endif

all: build
Expand All @@ -58,7 +58,7 @@ build:

chat2:
pushd ./examples/chat2 && \
${GOBIN} build -tags="gowaku_rln" -o ../../build/chat2 . && \
${GOBIN} build -o ../../build/chat2 . && \
popd

vendor:
Expand Down Expand Up @@ -130,7 +130,7 @@ static-library:
@echo "Building static library..."
${GOBIN} build \
-buildmode=c-archive \
-tags="${BUILD_TAGS}" \
-tags="${BUILD_TAGS} gowaku_no_rln" \
-o ./build/lib/libgowaku.a \
./library/c/
@echo "Static library built:"
Expand All @@ -146,7 +146,7 @@ dynamic-library:
rm -f ./build/lib/libgowaku.$(GOBIN_SHARED_LIB_EXT)*
$(GOBIN_SHARED_LIB_CFLAGS) $(GOBIN_SHARED_LIB_CGO_LDFLAGS) ${GOBIN} build \
-buildmode=c-shared \
-tags="${BUILD_TAGS}" \
-tags="${BUILD_TAGS} gowaku_no_rln" \
-o ./build/lib/libgowaku.$(GOBIN_SHARED_LIB_EXT) \
./library/c/
ifeq ($(detected_OS),Darwin)
Expand All @@ -166,14 +166,14 @@ mobile-android:
@echo "Android target: ${ANDROID_TARGET} (override with ANDROID_TARGET var)"
gomobile init && \
${GOBIN} get -d golang.org/x/mobile/cmd/gomobile && \
gomobile bind -v -target=android -androidapi=${ANDROID_TARGET} -ldflags="-s -w" -tags="${BUILD_TAGS}" $(BUILD_FLAGS) -o ./build/lib/gowaku.aar ./library/mobile
CGO=1 gomobile bind -v -target=android -androidapi=${ANDROID_TARGET} -ldflags="-s -w" -tags="${BUILD_TAGS} gowaku_no_rln" $(BUILD_FLAGS) -o ./build/lib/gowaku.aar ./library/mobile
@echo "Android library built:"
@ls -la ./build/lib/*.aar ./build/lib/*.jar

mobile-ios:
gomobile init && \
${GOBIN} get -d golang.org/x/mobile/cmd/gomobile && \
gomobile bind -target=ios -ldflags="-s -w" -tags="nowatchdog ${BUILD_TAGS}" $(BUILD_FLAGS) -o ./build/lib/Gowaku.xcframework ./library/mobile
gomobile bind -target=ios -ldflags="-s -w" -tags="nowatchdog ${BUILD_TAGS} gowaku_no_rln" $(BUILD_FLAGS) -o ./build/lib/Gowaku.xcframework ./library/mobile
@echo "IOS library built:"
@ls -la ./build/lib/*.xcframework

Expand Down
4 changes: 2 additions & 2 deletions cmd/waku/flags_no_rln.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !gowaku_rln
// +build !gowaku_rln
//go:build gowaku_no_rln
// +build gowaku_no_rln

package main

Expand Down
4 changes: 2 additions & 2 deletions cmd/waku/flags_rln.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build gowaku_rln
// +build gowaku_rln
//go:build !gowaku_no_rln
// +build !gowaku_no_rln

package main

Expand Down
4 changes: 2 additions & 2 deletions cmd/waku/node_no_rln.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !gowaku_rln
// +build !gowaku_rln
//go:build gowaku_no_rln
// +build gowaku_no_rln

package main

Expand Down
4 changes: 2 additions & 2 deletions cmd/waku/node_rln.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build gowaku_rln
// +build gowaku_rln
//go:build !gowaku_no_rln
// +build !gowaku_no_rln

package main

Expand Down
4 changes: 2 additions & 2 deletions cmd/waku/rlngenerate/command_no_rln.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !gowaku_rln
// +build !gowaku_rln
//go:build gowaku_no_rln
// +build gowaku_no_rln

package rlngenerate

Expand Down
4 changes: 2 additions & 2 deletions cmd/waku/rlngenerate/command_rln.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build gowaku_rln
// +build gowaku_rln
//go:build !gowaku_no_rln
// +build !gowaku_no_rln

package rlngenerate

Expand Down
4 changes: 2 additions & 2 deletions cmd/waku/rlngenerate/flags.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build gowaku_rln
// +build gowaku_rln
//go:build !gowaku_no_rln
// +build !gowaku_no_rln

package rlngenerate

Expand Down
4 changes: 2 additions & 2 deletions cmd/waku/rlngenerate/web3.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build gowaku_rln
// +build gowaku_rln
//go:build !gowaku_no_rln
// +build !gowaku_no_rln

package rlngenerate

Expand Down
4 changes: 2 additions & 2 deletions cmd/waku/server/no_rln.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !gowaku_rln
// +build !gowaku_rln
//go:build gowaku_no_rln
// +build gowaku_no_rln

package server

Expand Down
4 changes: 2 additions & 2 deletions cmd/waku/server/rln.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build gowaku_rln
// +build gowaku_rln
//go:build !gowaku_no_rln
// +build !gowaku_no_rln

package server

Expand Down
2 changes: 1 addition & 1 deletion examples/chat2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
all: build

build:
go build -tags="gowaku_rln" -o build/chat2 .
go build -o build/chat2 .

run:
./build/chat2
2 changes: 1 addition & 1 deletion examples/rln/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all build

build:
go build -tags="gowaku_rln" -o build/rln .
go build -o build/rln .

all: build
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
name = "go-waku";
src = self;
inherit subPackages;
tags = [ "gowaku_no_rln" ];
ldflags = [
"-X github.com/waku-org/go-waku/waku/v2/node.GitCommit=${commit}"
"-X github.com/waku-org/go-waku/waku/v2/node.Version=${version}"
Expand Down
4 changes: 2 additions & 2 deletions waku/v2/node/wakunode2_no_rln.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !gowaku_rln
// +build !gowaku_rln
//go:build gowaku_no_rln
// +build gowaku_no_rln

package node

Expand Down
4 changes: 2 additions & 2 deletions waku/v2/node/wakunode2_rln.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build gowaku_rln
// +build gowaku_rln
//go:build !gowaku_no_rln
// +build !gowaku_no_rln

package node

Expand Down
6 changes: 2 additions & 4 deletions waku/v2/node/wakuoptions_rln.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build gowaku_rln
// +build gowaku_rln
//go:build !gowaku_no_rln
// +build !gowaku_no_rln

package node

Expand All @@ -10,7 +10,6 @@ import (
)

// WithStaticRLNRelay enables the Waku V2 RLN protocol in offchain mode
// Requires the `gowaku_rln` build constrain (or the env variable RLN=true if building go-waku)
func WithStaticRLNRelay(memberIndex *r.MembershipIndex, spamHandler rln.SpamHandler) WakuNodeOption {
return func(params *WakuNodeParameters) error {
params.enableRLN = true
Expand All @@ -22,7 +21,6 @@ func WithStaticRLNRelay(memberIndex *r.MembershipIndex, spamHandler rln.SpamHand
}

// WithDynamicRLNRelay enables the Waku V2 RLN protocol in onchain mode.
// Requires the `gowaku_rln` build constrain (or the env variable RLN=true if building go-waku)
func WithDynamicRLNRelay(keystorePath string, keystorePassword string, treePath string, membershipContract common.Address, membershipIndex *uint, spamHandler rln.SpamHandler, ethClientAddress string) WakuNodeOption {
return func(params *WakuNodeParameters) error {
params.enableRLN = true
Expand Down

0 comments on commit 0799d2e

Please sign in to comment.