Skip to content

Commit

Permalink
adding new sync range param & fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SionoiS committed Aug 13, 2024
1 parent 5d44077 commit 499c5e6
Show file tree
Hide file tree
Showing 13 changed files with 299 additions and 253 deletions.
28 changes: 14 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ clean: | clean-librln
#################
.PHONY: testcommon

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

Expand All @@ -182,39 +182,39 @@ testcommon: | build deps negentropy
.PHONY: testwaku wakunode2 testwakunode2 example2 chat2 chat2bridge liteprotocoltester

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

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

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

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

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

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

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

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

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

Expand All @@ -233,11 +233,11 @@ test/%: | build deps librln

tools: networkmonitor wakucanary

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

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

Expand Down Expand Up @@ -291,7 +291,7 @@ docker-push:

STATIC ?= false

libwaku: | build deps librln negentropy
libwaku: | build deps librln
rm -f build/libwaku*
ifeq ($(STATIC), true)
echo -e $(BUILD_MSG) "build/[email protected]" && \
Expand Down Expand Up @@ -420,7 +420,7 @@ release-notes:
## Pass libnegentropy to linker.
NIM_PARAMS := $(NIM_PARAMS) --passL:./libnegentropy.so

all: | negentropy
deps: | negentropy

clean: | negentropy-clean

Expand Down
28 changes: 11 additions & 17 deletions tests/node/test_wakunode_sync.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import std/net, testutils/unittests, chronos, libp2p/crypto/crypto

import
../../../waku/
../../waku/
[node/waku_node, node/peer_manager, waku_core, waku_store, waku_archive, waku_sync],
../waku_store/store_utils,
../waku_archive/archive_utils,
Expand Down Expand Up @@ -53,16 +53,10 @@ suite "Store Sync - End to End":
server.mountStoreClient()

let mountServerSync = await server.mountWakuSync(
maxFrameSize = 0,
syncInterval = 1.hours,
relayJitter = 0.seconds,
enablePruning = false,
maxFrameSize = 0, syncInterval = 1.hours, relayJitter = 0.seconds
)
let mountClientSync = await client.mountWakuSync(
maxFrameSize = 0,
syncInterval = 2.milliseconds,
relayJitter = 0.seconds,
enablePruning = false,
maxFrameSize = 0, syncInterval = 2.milliseconds, relayJitter = 0.seconds
)

assert mountServerSync.isOk(), mountServerSync.error
Expand All @@ -71,7 +65,7 @@ suite "Store Sync - End to End":
# messages are retreived when mounting Waku sync
# but based on interval so this is needed for client only
for msg in messages:
client.wakuSync.ingessMessage(DefaultPubsubTopic, msg)
client.wakuSync.messageIngress(DefaultPubsubTopic, msg)

await allFutures(server.start(), client.start())

Expand Down Expand Up @@ -102,7 +96,7 @@ suite "Store Sync - End to End":
asyncTest "client message set differences":
let msg = fakeWakuMessage(@[byte 10])

client.wakuSync.ingessMessage(DefaultPubsubTopic, msg)
client.wakuSync.messageIngress(DefaultPubsubTopic, msg)
await client.wakuArchive.handleMessage(DefaultPubsubTopic, msg)

check:
Expand All @@ -116,7 +110,7 @@ suite "Store Sync - End to End":
asyncTest "server message set differences":
let msg = fakeWakuMessage(@[byte 10])

server.wakuSync.ingessMessage(DefaultPubsubTopic, msg)
server.wakuSync.messageIngress(DefaultPubsubTopic, msg)
await server.wakuArchive.handleMessage(DefaultPubsubTopic, msg)

check:
Expand Down Expand Up @@ -157,14 +151,14 @@ suite "Waku Sync - Pruning":
let mountServerSync = await server.mountWakuSync(
maxFrameSize = 0,
relayJitter = 0.seconds,
syncInterval = 1.hours,
enablePruning = false,
syncRange = 1.hours,
syncInterval = 5.minutes,
)
let mountClientSync = await client.mountWakuSync(
maxFrameSize = 0,
syncRange = 10.milliseconds,
syncInterval = 10.milliseconds,
relayJitter = 0.seconds,
enablePruning = true,
)

assert mountServerSync.isOk(), mountServerSync.error
Expand All @@ -181,10 +175,10 @@ suite "Waku Sync - Pruning":
for _ in 0 ..< 4:
for _ in 0 ..< 10:
let msg = fakeWakuMessage()
client.wakuSync.ingessMessage(DefaultPubsubTopic, msg)
client.wakuSync.messageIngress(DefaultPubsubTopic, msg)
await client.wakuArchive.handleMessage(DefaultPubsubTopic, msg)

server.wakuSync.ingessMessage(DefaultPubsubTopic, msg)
server.wakuSync.messageIngress(DefaultPubsubTopic, msg)
await server.wakuArchive.handleMessage(DefaultPubsubTopic, msg)

await sleepAsync(10.milliseconds)
Expand Down
10 changes: 9 additions & 1 deletion tests/waku_sync/sync_utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ proc newTestWakuSync*(
): Future[WakuSync] {.async.} =
let peerManager = PeerManager.new(switch)

let fakePruneCallback = proc(
pruneStart: Timestamp, pruneStop: Timestamp, cursor: Option[WakuMessageHash]
): Future[
Result[(seq[(WakuMessageHash, Timestamp)], Option[WakuMessageHash]), string]
] {.async: (raises: []), closure.} =
return ok((@[], none(WakuMessageHash)))

let res = await WakuSync.new(
peerManager = peerManager,
relayJitter = 0.seconds,
syncInterval = interval,
pruning = false,
wakuArchive = nil,
wakuStoreClient = nil,
pruneCallback = some(fakePruneCallback),
transferCallback = none(TransferCallback),
)

let proto = res.get()
Expand Down
Loading

0 comments on commit 499c5e6

Please sign in to comment.