This commit is contained in:
stubbsta 2025-04-02 09:19:20 +02:00
commit 59a8b18209
2 changed files with 31 additions and 34 deletions

View File

@ -21,7 +21,7 @@ suite "Waku config - apply preset":
let expectedConf = ClusterConf.TheWakuNetworkConf()
## Given
let preConfig = WakuNodeConf(cmd: noCommand, preset: "default")
let preConfig = WakuNodeConf(cmd: noCommand, preset: "twn")
## When
let res = applyPresetConfiguration(preConfig)
@ -41,13 +41,13 @@ suite "Waku config - apply preset":
assert conf.numShardsInNetwork == expectedConf.numShardsInNetwork
assert conf.discv5BootstrapNodes == expectedConf.discv5BootstrapNodes
test "Subscribes to all valid shards in default network":
test "Subscribes to all valid shards in twn":
## Setup
let expectedConf = ClusterConf.TheWakuNetworkConf()
## Given
let shards: seq[uint16] = @[0, 1, 2, 3, 4, 5, 6, 7]
let preConfig = WakuNodeConf(cmd: noCommand, preset: "default", shards: shards)
let preConfig = WakuNodeConf(cmd: noCommand, preset: "twn", shards: shards)
## When
let res = applyPresetConfiguration(preConfig)
@ -57,13 +57,13 @@ suite "Waku config - apply preset":
let conf = res.get()
assert conf.shards.len == expectedConf.numShardsInNetwork.int
test "Subscribes to some valid shards in default network":
test "Subscribes to some valid shards in twn":
## Setup
let expectedConf = ClusterConf.TheWakuNetworkConf()
## Given
let shards: seq[uint16] = @[0, 4, 7]
let preConfig = WakuNodeConf(cmd: noCommand, preset: "default", shards: shards)
let preConfig = WakuNodeConf(cmd: noCommand, preset: "twn", shards: shards)
## When
let resConf = applyPresetConfiguration(preConfig)
@ -76,12 +76,12 @@ suite "Waku config - apply preset":
for index, shard in shards:
assert shard in conf.shards
test "Subscribes to invalid shards in default network":
test "Subscribes to invalid shards in twn":
## Setup
## Given
let shards: seq[uint16] = @[0, 4, 7, 10]
let preConfig = WakuNodeConf(cmd: noCommand, preset: "default", shards: shards)
let preConfig = WakuNodeConf(cmd: noCommand, preset: "twn", shards: shards)
let postConfig = applyPresetConfiguration(preConfig)
## When

View File

@ -96,8 +96,6 @@ proc fetchMerkleProofElements*(
try:
let merkleProofInvocation = g.wakuRlnContract.get().getMerkleProof(index)
let merkleProof = await merkleProofInvocation.call()
debug "Fetched Merkle proof",
index = index, merkleProof = merkleProof
return ok(merkleProof)
except CatchableError as e:
error "Failed to fetch merkle proof", errMsg = e.msg
@ -160,31 +158,30 @@ proc updateRoots*(g: OnchainGroupManager): Future[bool] {.async.} =
return false
proc trackRootChanges*(g: OnchainGroupManager): Future[void] {.async.} =
## Continuously track changes to the Merkle root
initializedGuard(g)
let ethRpc = g.ethRpc.get()
let wakuRlnContract = g.wakuRlnContract.get()
# Set up the polling interval - more frequent to catch roots
const rpcDelay = 5.seconds
info "Starting to track Merkle root changes"
while true:
debug "starting to update roots"
let rootUpdated = await g.updateRoots()
if rootUpdated:
let proofResult = await g.fetchMerkleProofElements()
if proofResult.isErr():
error "Failed to fetch Merkle proof", error = proofResult.error
g.merkleProofCache = proofResult.get()
debug "sleeping for 5 seconds"
await sleepAsync(rpcDelay)
# proc trackRootChanges*(g: OnchainGroupManager): Future[void] {.async.} =
# ## Continuously track changes to the Merkle root
# initializedGuard(g)
#
# let ethRpc = g.ethRpc.get()
# let wakuRlnContract = g.wakuRlnContract.get()
#
# # Set up the polling interval - more frequent to catch roots
# const rpcDelay = 5.seconds
#
# info "Starting to track Merkle root changes"
#
# while true:
# debug "starting to update roots"
# let rootUpdated = await g.updateRoots()
#
# if rootUpdated:
# let proofResult = await g.fetchMerkleProofElements()
# if proofResult.isErr():
# error "Failed to fetch Merkle proof", error = proofResult.error
# g.merkleProofCache = proofResult.get()
#
# debug "sleeping for 5 seconds"
# await sleepAsync(rpcDelay)
method atomicBatch*(
g: OnchainGroupManager,