Merge ce19d16c31b26e193f98e42fd1a9261dab386b98 into 834eea945d05b4092466f3953467b28467e6b24c

This commit is contained in:
fryorcraken 2025-12-19 16:02:28 +01:00 committed by GitHub
commit c006b52ab6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 140 additions and 8 deletions

View File

@ -0,0 +1,53 @@
name: Test Nimble Installation
on:
pull_request:
push:
branches:
- simpler-deps
jobs:
test-nimble-install:
continue-on-error: true # Some runs get oddly cancelled
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest] # TODO: Windows
nim-version: ['2.2.4'] # TODO: tests with more versions
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: "true" # Needed to pull RLN script
- uses: nim-lang/setup-nimble-action@v1
with:
nimble-version: "0.20.1"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Display Nimble version
run: nimble --version
- name: Run nimble install on waku
run: nimble install
timeout-minutes: 60
- name: Run nimble check on waku
run: nimble check -l
timeout-minutes: 60
- name: Build example project
working-directory: examples/nimble
run: |
echo "Building example project..."
nimble --verbose build
- name: Run example project
working-directory: examples/nimble
run: |
echo "Running example project..."
# nimble --verbose run # TODO: Use nimble run
./example

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
# Nimble packages
/vendor/.nimble
nimbledeps
# Generated Files
*.generated.nim

4
examples/nimble/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
nimbledeps
nimble.develop
nimble.paths
example

View File

@ -0,0 +1,11 @@
# begin Nimble config (version 2)
when withDir(thisDir(), system.fileExists("nimble.paths")):
include "nimble.paths"
# end Nimble config
import os
let rlnLib = getCurrentDir() / "build" / "librln.a"
echo "RLN lib path: ", rlnLib
switch("passL", rlnLib)
switch("passL", "-lm")

View File

@ -0,0 +1,33 @@
# Package
version = "0.1.0"
author = "fryorcraken"
description = "Test Waku with nimble"
license = "MIT"
srcDir = "src"
bin = @["example"]
# Dependencies
requires "chronos"
requires "results"
requires "waku#44bfddb245e30eeab850730dee67c41cbe7f7252"
import os
proc ensureRln(libFile: string = "build/librln.a", version = "v0.8.0") =
if not fileExists(libFile):
echo "Building RLN library..."
let buildDir = parentDir(parentDir(getCurrentDir())) & "/vendor/zerokit"
let outFile = libFile
let outDir = parentDir(outFile)
if not dirExists(outDir):
mkDir(outDir) # Ensure build directory exists
exec "bash ../../scripts/build_rln.sh " & buildDir & " " & version & " " & outFile
else:
echo "RLN library already exists: " & libFile
before build:
ensureRln()

View File

@ -0,0 +1,28 @@
import chronos, results
import waku
proc main() {.async.} =
echo("Starting Waku node...")
# Create a basic configuration for the Waku node
# No RLN so we don't need to path an eth rpc endpoint
let config = NodeConfig.init(
protocolsConfig = ProtocolsConfig.init(entryNodes = @[], clusterId = 42)
)
# Create the node using the library API's createNode function
let node = (await createNode(config)).valueOr:
echo("Failed to create node: ", error)
quit(1)
echo("Waku node created successfully!")
# Start the node
(await startWaku(addr node)).isOkOr:
echo("Failed to start node: ", error)
quit(1)
echo("Node started successfully! exiting")
when isMainModule:
waitFor main()

View File

@ -19,7 +19,7 @@ host_triplet=$(rustc --version --verbose | awk '/host:/{print $2}')
tarball="${host_triplet}"
tarball+="-rln.tar.gz"
tarball+="-default-rln.tar.gz"
# Download the prebuilt rln library if it is available
if curl --silent --fail-with-body -L \

View File

@ -8,6 +8,7 @@ version = "0.36.0"
author = "Status Research & Development GmbH"
description = "Waku, Private P2P Messaging for Resource-Restricted Devices"
license = "MIT or Apache License 2.0"
srcDir = "waku"
#bin = @["build/waku"]
### Dependencies
@ -30,7 +31,8 @@ requires "nim >= 2.2.4",
"regex",
"results",
"db_connector",
"minilru"
"minilru",
"https://github.com/vacp2p/mix#v0.1.0"
### Helper functions
proc buildModule(filePath, params = "", lang = "c"): bool =

View File

@ -7,4 +7,4 @@ import bearssl/rand, stew/byteutils
proc generateRequestId*(rng: ref HmacDrbgContext): string =
var bytes: array[10, byte]
hmacDrbgGenerate(rng[], bytes)
return toHex(bytes)
return byteutils.toHex(bytes)

View File

@ -30,7 +30,7 @@ type WakuFilterClient* = ref object of LPProtocol
func generateRequestId(rng: ref HmacDrbgContext): string =
var bytes: array[10, byte]
hmacDrbgGenerate(rng[], bytes)
return toHex(bytes)
return byteutils.toHex(bytes)
proc addSubscrObserver*(wfc: WakuFilterClient, obs: SubscriptionObserver) =
wfc.subscrObservers.add(obs)

View File

@ -79,7 +79,7 @@ proc messageIngress*(
let id = SyncID(time: msg.timestamp, hash: msgHash)
self.storage.insert(id, pubsubTopic, msg.contentTopic).isOkOr:
error "failed to insert new message", msg_hash = $id.hash.toHex(), error = $error
error "failed to insert new message", msg_hash = $byteutils.toHex(id.hash), error = $error
proc messageIngress*(
self: SyncReconciliation,
@ -87,7 +87,7 @@ proc messageIngress*(
pubsubTopic: PubsubTopic,
msg: WakuMessage,
) =
trace "message ingress", msg_hash = msgHash.toHex(), msg = msg
trace "message ingress", msg_hash = byteutils.toHex(msgHash), msg = msg
if msg.ephemeral:
return
@ -95,7 +95,7 @@ proc messageIngress*(
let id = SyncID(time: msg.timestamp, hash: msgHash)
self.storage.insert(id, pubsubTopic, msg.contentTopic).isOkOr:
error "failed to insert new message", msg_hash = $id.hash.toHex(), error = $error
error "failed to insert new message", msg_hash = $byteutils.toHex(id.hash), error = $error
proc messageIngress*(
self: SyncReconciliation,
@ -104,7 +104,7 @@ proc messageIngress*(
contentTopic: ContentTopic,
) =
self.storage.insert(id, pubsubTopic, contentTopic).isOkOr:
error "failed to insert new message", msg_hash = $id.hash.toHex(), error = $error
error "failed to insert new message", msg_hash = $byteutils.toHex(id.hash), error = $error
proc preProcessPayload(
self: SyncReconciliation, payload: RangesData