Skip to content

Commit

Permalink
feat: Waku Sync Protocol
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan FB <[email protected]>
Co-authored-by: Prem Chaitanya Prathi <[email protected]>
  • Loading branch information
3 people committed May 3, 2024
1 parent cee020f commit d76b3d0
Show file tree
Hide file tree
Showing 16 changed files with 1,392 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,8 @@
branch = master
path = vendor/nim-results
url = https://github.com/arnetheduck/nim-results.git
[submodule "vendor/negentropy"]
ignore = untracked
path = vendor/negentropy
url = https://github.com/waku-org/negentropy.git
branch = master
21 changes: 15 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ else # "variables.mk" was included. Business as usual until the end of this file
##########
## Main ##
##########
.PHONY: all test update clean
.PHONY: all test update clean negentropy

# default target, because it's the first one that doesn't start with '.'
all: | wakunode2 example2 chat2 chat2bridge libwaku
all: | negentropy wakunode2 example2 chat2 chat2bridge libwaku

test: | testcommon testwaku

Expand All @@ -46,7 +46,7 @@ update: | update-common
rm -rf waku.nims && \
$(MAKE) waku.nims $(HANDLE_OUTPUT)

clean:
clean: | negentropy-clean
rm -rf build

# must be included after the default target
Expand Down Expand Up @@ -79,6 +79,9 @@ endif
endif
## end of Heaptracker options

## Pass libnegentropy to linker.
NIM_PARAMS := $(NIM_PARAMS) --passL:./libnegentropy.so

##################
## Dependencies ##
##################
Expand Down Expand Up @@ -182,19 +185,19 @@ testcommon: | build deps
.PHONY: testwaku wakunode2 testwakunode2 example2 chat2 chat2bridge

# install anvil only for the testwaku target
testwaku: | build deps anvil librln
testwaku: | build deps anvil librln negentropy
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim test -d:os=$(shell uname) $(NIM_PARAMS) waku.nims

wakunode2: | build deps librln
wakunode2: | build deps librln negentropy
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim wakunode2 $(NIM_PARAMS) waku.nims

benchmarks: | build deps librln
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim benchmarks $(NIM_PARAMS) waku.nims

testwakunode2: | build deps librln
testwakunode2: | build deps librln negentropy
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim testwakunode2 $(NIM_PARAMS) waku.nims

Expand Down Expand Up @@ -335,3 +338,9 @@ release-notes:
sed -E 's@#([0-9]+)@[#\1](https://github.com/waku-org/nwaku/issues/\1)@g'
# I could not get the tool to replace issue ids with links, so using sed for now,
# asked here: https://github.com/bvieira/sv4git/discussions/101
negentropy:
$(MAKE) -C vendor/negentropy/cpp && \
cp vendor/negentropy/cpp/libnegentropy.so ./
negentropy-clean:
$(MAKE) -C vendor/negentropy/cpp clean && \
rm libnegentropy.so
20 changes: 20 additions & 0 deletions tests/waku_sync/sync_utils.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{.used.}

import std/options, chronos, chronicles, libp2p/crypto/crypto

import
../../../waku/[node/peer_manager, waku_core, waku_sync], ../testlib/[common, wakucore]

proc newTestWakuSync*(
switch: Switch, handler: WakuSyncCallback
): Future[WakuSync] {.async.} =
const DefaultFrameSize = 153600
let
peerManager = PeerManager.new(switch)
proto = WakuSync.new(peerManager, DefaultFrameSize, 0.seconds, some(handler))
assert proto != nil

proto.start()
switch.mount(proto)

return proto
4 changes: 4 additions & 0 deletions tests/waku_sync/test_all.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{.used.}

import
./test_protocol
Loading

0 comments on commit d76b3d0

Please sign in to comment.