mirror of https://github.com/waku-org/nwaku.git
chore(rln-relay): logs, updated submodule, leaves_set metric (#2024)
* chore(rln-relay): logs, updated submodule, leaves_set metric * chore(rln-relay): update build script, fix makefile
This commit is contained in:
parent
dac072f843
commit
2e515a06ed
|
@ -143,7 +143,7 @@
|
|||
path = vendor/zerokit
|
||||
url = https://github.com/vacp2p/zerokit.git
|
||||
ignore = dirty
|
||||
branch = v0.3.2
|
||||
branch = v0.3.4
|
||||
[submodule "vendor/nim-regex"]
|
||||
path = vendor/nim-regex
|
||||
url = https://github.com/nitely/nim-regex.git
|
||||
|
|
5
Makefile
5
Makefile
|
@ -119,16 +119,17 @@ clean: | clean-libbacktrace
|
|||
.PHONY: librln
|
||||
|
||||
LIBRLN_BUILDDIR := $(CURDIR)/vendor/zerokit
|
||||
LIBRLN_VERSION := v0.3.4
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
LIBRLN_FILE := rln.lib
|
||||
else
|
||||
LIBRLN_FILE := librln.a
|
||||
LIBRLN_FILE := librln_$(LIBRLN_VERSION).a
|
||||
endif
|
||||
|
||||
$(LIBRLN_FILE):
|
||||
echo -e $(BUILD_MSG) "$@" && \
|
||||
./scripts/build_rln.sh $(LIBRLN_BUILDDIR)
|
||||
./scripts/build_rln.sh $(LIBRLN_BUILDDIR) $(LIBRLN_VERSION) $(LIBRLN_FILE)
|
||||
|
||||
|
||||
librln: | $(LIBRLN_FILE)
|
||||
|
|
|
@ -7,25 +7,45 @@ set -e
|
|||
|
||||
# first argument is the build directory
|
||||
build_dir=$1
|
||||
rln_version=$2
|
||||
output_filename=$3
|
||||
|
||||
if [[ -z "$build_dir" ]]; then
|
||||
echo "No build directory specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$rln_version" ]]; then
|
||||
echo "No rln version specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$output_filename" ]]; then
|
||||
echo "No output filename specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the host triplet
|
||||
host_triplet=$(rustup show | grep "Default host: " | cut -d' ' -f3)
|
||||
|
||||
# Download the prebuilt rln library if it is available
|
||||
if curl --silent --fail-with-body -L "https://github.com/vacp2p/zerokit/releases/download/v0.3.2/$host_triplet-rln.tar.gz" >> "$host_triplet-rln.tar.gz"
|
||||
if curl --silent --fail-with-body -L "https://github.com/vacp2p/zerokit/releases/download/$rln_version/$host_triplet-rln.tar.gz" >> "$host_triplet-rln.tar.gz"
|
||||
then
|
||||
echo "Downloaded $host_triplet-rln.tar.gz"
|
||||
tar -xzf "$host_triplet-rln.tar.gz"
|
||||
mv release/librln.a .
|
||||
mv release/librln.a $output_filename
|
||||
rm -rf "$host_triplet-rln.tar.gz" release
|
||||
else
|
||||
echo "Failed to download $host_triplet-rln.tar.gz"
|
||||
# Build rln instead
|
||||
# first, check if submodule version = version in Makefile
|
||||
submodule_version=$(cargo metadata --format-version=1 --no-deps | jq '.packages[] | select(.name == "rln") | .version')
|
||||
if [[ "v$submodule_version" != "$rln_version" ]]; then
|
||||
echo "Submodule version (v$submodule_version) does not match version in Makefile ($rln_version)"
|
||||
echo "Please update the submodule to $rln_version"
|
||||
exit 1
|
||||
fi
|
||||
# if submodule version = version in Makefile, build rln
|
||||
cargo build --release -p rln --manifest-path "$build_dir/rln/Cargo.toml"
|
||||
cp "$build_dir/target/release/librln.a" .
|
||||
cp "$build_dir/target/release/librln.a" $output_filename
|
||||
fi
|
||||
|
|
|
@ -210,6 +210,7 @@ suite "Waku rln relay":
|
|||
idCredentialRes.isOk()
|
||||
check:
|
||||
rln.insertMembers(0, @[idCredentialRes.get().idCommitment])
|
||||
rln.leavesSet() == 1
|
||||
|
||||
test "insertMember rln utils":
|
||||
# create an RLN instance which also includes an empty Merkle tree
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b51896c3a710f567fc7e054681767d6547a8eb9b
|
||||
Subproject commit b903d8d740e0b8b82057bcc5377ddce05ae5676b
|
|
@ -106,7 +106,7 @@ method atomicBatch*(g: OnchainGroupManager,
|
|||
if not operationSuccess:
|
||||
raise newException(ValueError, "atomic batch operation failed")
|
||||
# TODO: when slashing is enabled, we need to track slashed members
|
||||
waku_rln_number_registered_memberships.set(int64(start.int + idCommitments.len - toRemoveIndices.len))
|
||||
waku_rln_number_registered_memberships.set(int64(g.rlnInstance.leavesSet()))
|
||||
|
||||
if g.registerCb.isSome():
|
||||
var membersSeq = newSeq[Membership]()
|
||||
|
@ -352,8 +352,10 @@ proc startOnchainSync(g: OnchainGroupManager): Future[void] {.async.} =
|
|||
let blockChunkSize = 2_000
|
||||
|
||||
var fromBlock = if g.latestProcessedBlock > g.rlnContractDeployedBlockNumber:
|
||||
info "syncing from last processed block", blockNumber = g.latestProcessedBlock
|
||||
g.latestProcessedBlock + 1
|
||||
else:
|
||||
info "syncing from rln contract deployed block", blockNumber = g.rlnContractDeployedBlockNumber
|
||||
g.rlnContractDeployedBlockNumber
|
||||
|
||||
try:
|
||||
|
@ -482,6 +484,7 @@ method init*(g: OnchainGroupManager): Future[void] {.async.} =
|
|||
var deployedBlockNumber: Uint256
|
||||
try:
|
||||
deployedBlockNumber = await rlnContract.deployedBlockNumber().call()
|
||||
debug "using rln storage", deployedBlockNumber, rlnContractAddress
|
||||
except CatchableError:
|
||||
raise newException(ValueError,
|
||||
"could not get the deployed block number: " & getCurrentExceptionMsg())
|
||||
|
@ -504,6 +507,7 @@ method init*(g: OnchainGroupManager): Future[void] {.async.} =
|
|||
except CatchableError:
|
||||
error "failed to restart group sync", error = getCurrentExceptionMsg()
|
||||
|
||||
waku_rln_number_registered_memberships.set(int64(g.rlnInstance.leavesSet()))
|
||||
g.initialized = true
|
||||
|
||||
method stop*(g: OnchainGroupManager): Future[void] {.async.} =
|
||||
|
|
|
@ -59,6 +59,10 @@ proc get_leaf*(ctx: ptr RLN, index: uint, output_buffer: ptr Buffer): bool {.imp
|
|||
## the output_buffer holds a serialized leaf of 32 bytes
|
||||
## the return bool value indicates the success or failure of the operation
|
||||
|
||||
proc leaves_set*(ctx: ptr RLN): uint {.importc: "leaves_set".}
|
||||
## gets the number of leaves set in the tree stored by ctx
|
||||
## the return uint value indicates the number of leaves set in the tree
|
||||
|
||||
proc init_tree_with_leaves*(ctx: ptr RLN, input_buffer: ptr Buffer): bool {.importc: "init_tree_with_leaves".}
|
||||
## sets multiple leaves in the tree stored by ctx to the value passed by input_buffer
|
||||
## the input_buffer holds a serialized vector of leaves (32 bytes each)
|
||||
|
|
Loading…
Reference in New Issue