From 301b07f2ad3f39e90dc2676aeef389162b53d579 Mon Sep 17 00:00:00 2001 From: kaichaosun Date: Fri, 29 Aug 2025 16:49:58 +0800 Subject: [PATCH] chore: fix rln in nimble --- .gitignore | 3 +++ scripts/build_rln.sh | 19 +++++++++++++++++++ vendor/nim-serialization | 2 +- vendor/nim-web3 | 2 +- waku.nimble | 26 +++++++++++++++++--------- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 7430c3e99..b20ca633a 100644 --- a/.gitignore +++ b/.gitignore @@ -79,3 +79,6 @@ waku_handler.moc.cpp # Nix build result result + +# Nimble + nimble.paths diff --git a/scripts/build_rln.sh b/scripts/build_rln.sh index cd2fa3827..a4c825ecf 100755 --- a/scripts/build_rln.sh +++ b/scripts/build_rln.sh @@ -5,6 +5,20 @@ set -e +# --- lock setup --- +lockdir="build/rln.lock" +mkdir -p build + +# try to acquire lock (atomic) +while ! mkdir "${lockdir}" 2>/dev/null; do + echo "Another process is building RLN, waiting..." + sleep 1 +done + +# cleanup on exit +cleanup() { rm -rf "${lockdir}"; } +trap cleanup EXIT + # first argument is the build directory build_dir=$1 rln_version=$2 @@ -14,6 +28,11 @@ output_filename=$3 [[ -z "${rln_version}" ]] && { echo "No rln version specified"; exit 1; } [[ -z "${output_filename}" ]] && { echo "No output filename specified"; exit 1; } +if [[ -f "${output_filename}" ]]; then + echo "RLN library already exists: ${output_filename}, skipping build." + exit 0 +fi + # Get the host triplet host_triplet=$(rustc --version --verbose | awk '/host:/{print $2}') diff --git a/vendor/nim-serialization b/vendor/nim-serialization index 6f525d544..73d6108d9 160000 --- a/vendor/nim-serialization +++ b/vendor/nim-serialization @@ -1 +1 @@ -Subproject commit 6f525d5447d97256750ca7856faead03e562ed20 +Subproject commit 73d6108d9c7ad0a1283d1e361a3f86e6c676a305 diff --git a/vendor/nim-web3 b/vendor/nim-web3 index 81ee8ce47..48fb2d4a2 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit 81ee8ce479d86acb73be7c4f365328e238d9b4a3 +Subproject commit 48fb2d4a215c20326b0cb945913b1d614a0564b9 diff --git a/waku.nimble b/waku.nimble index 3627f6047..31073839f 100644 --- a/waku.nimble +++ b/waku.nimble @@ -11,26 +11,36 @@ license = "MIT or Apache License 2.0" ### Dependencies requires "nim >= 2.2.4", "chronicles", - "confutils", + "confutils#e214b39", "chronos", "dnsdisc", "eth", "json_rpc", "libbacktrace", "nimcrypto", + "serialization >= 0.4.9", "stew", "stint", "metrics", "libp2p == 1.10.1", # Only for Waku v2 - "web3", + "web3#48fb2d4", # fix 0.7.0 undeclared field: 'stream' error "presto", "regex", "results", "db_connector", - "minilru", - "quic" + "minilru" ### Helper functions + +proc ensureRln(libFile: string = "build/librln.a", version = "v0.7.0") = + if not fileExists(libFile): + echo "Building RLN library..." + let buildDir = getCurrentDir() + let outFile = libFile + exec "bash ./scripts/build_rln.sh " & buildDir & " " & version & " " & outFile + else: + echo "RLN library already exists: " & libFile + proc buildModule(filePath, params = "", lang = "c"): bool = if not dirExists "build": mkDir "build" @@ -52,11 +62,9 @@ proc buildModule(filePath, params = "", lang = "c"): bool = proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") = if not dirExists "build": mkDir "build" - # allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims" - var extra_params = params - for i in 2 ..< paramCount(): - extra_params &= " " & paramStr(i) - exec "nim " & lang & " --out:build/" & name & " --mm:refc " & extra_params & " " & + + ensureRln() + exec "nim " & lang & " --out:build/" & name & " --mm:refc " & " --passL:build/librln.a --passL:-lm --passL:-L" & getCurrentDir() & " " & params & " " & srcDir & name & ".nim" proc buildLibrary(name: string, srcDir = "./", params = "", `type` = "static") =