From d0977a67d531266ba36cf0e0ab27cec614b3bdd0 Mon Sep 17 00:00:00 2001 From: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> Date: Fri, 12 Feb 2021 12:12:10 -0800 Subject: [PATCH] rlnlib dependency (#376) * adds rlnlib dependency * clones the full-node branch of rln repository * moves rlnlib dependency to the deps target * changes rlnlib path * adds test_rln_relay_wrappers to the v2 tests * loads rlnlib with different extensions based on the OS * deletes unnecessary imports * changes rlnlib extension to .exe for windows * minor * list files in rln/target/debug * edits rln lib name for windows * removes unnecessary commands * edits some comments * fetches specific commit of rln library --- Makefile | 5 ++++- tests/all_tests_v2.nim | 3 ++- waku/v2/protocol/waku_rln_relay/rln.nim | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index bbde55694..1011bc365 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ else NIM_PARAMS := $(NIM_PARAMS) -d:release endif -deps: | deps-common nat-libs waku.nims +deps: | deps-common nat-libs waku.nims rlnlib ifneq ($(USE_LIBBACKTRACE), 0) deps: | libbacktrace endif @@ -118,6 +118,9 @@ endif installganache: npm install ganache-cli; npx ganache-cli -p 8540 -g 0 -l 3000000000000& +rlnlib: + #cargo clean --manifest-path rln/Cargo.toml #TODO may need to clean the rln directory before cloning the rln repo + git clone --branch full-node https://github.com/kilic/rln; git --git-dir=rln/.git reset --hard a80f5d0; cargo build --manifest-path rln/Cargo.toml; test2: | build deps installganache echo -e $(BUILD_MSG) "build/$@" && \ diff --git a/tests/all_tests_v2.nim b/tests/all_tests_v2.nim index a4cdaa379..a63892c82 100644 --- a/tests/all_tests_v2.nim +++ b/tests/all_tests_v2.nim @@ -12,7 +12,8 @@ import ./v2/test_jsonrpc_waku, ./v2/test_peer_manager, ./v2/test_web3, # TODO remove it when rln-relay tests get finalized - ./v2/test_waku_rln_relay + ./v2/test_waku_rln_relay, + ./v2/test_rln_relay_wrappers # TODO Only enable this once swap module is integrated more nicely as a dependency, i.e. as submodule with CI etc # For PoC execute it manually and run separate module here: https://github.com/vacp2p/swap-contracts-module diff --git a/waku/v2/protocol/waku_rln_relay/rln.nim b/waku/v2/protocol/waku_rln_relay/rln.nim index 355d15dbe..4a54228a3 100644 --- a/waku/v2/protocol/waku_rln_relay/rln.nim +++ b/waku/v2/protocol/waku_rln_relay/rln.nim @@ -1,17 +1,17 @@ # this module contains the Nim wrappers for the rln library https://github.com/kilic/rln/blob/3bbec368a4adc68cd5f9bfae80b17e1bbb4ef373/src/ffi.rs -import stew/byteutils, os -from strutils import rsplit +import os -template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0] -# librln.dylib is the binary executable of rln library (originally implemented in rust with an exposed C API) +# librln.dylib is the rln library taken from https://github.com/kilic/rln (originally implemented in rust with an exposed C API) # contains the key generation and other relevant functions -# to generate librln.dylib, clone this repo https://github.com/kilic/rln -# and run the following command in the root directory of the cloned project -# cargo build -# can find the .dylib file under the target/debug directory -# this file is already generated and copied here -const libName* = sourceDir / "librln.dylib" # TODO may need to load different libs based on OS + +const libPath = "rln/target/debug/" +when defined(Windows): + const libName* = libPath / "rln.dll" +elif defined(Linux): + const libName* = libPath / "librln.so" +elif defined(MacOsX): + const libName* = libPath / "librln.dylib" # Data types -----------------------------