mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-06-04 21:19:28 +00:00
add contract root cache size as constant and function use fix
This commit is contained in:
parent
343f9cb325
commit
324d69c928
@ -7,6 +7,9 @@ import ../waku_keystore
|
||||
# Acceptable roots for merkle root validation of incoming messages
|
||||
const AcceptableRootWindowSize* = 50
|
||||
|
||||
#Size if RLN contract root cache
|
||||
const RlnContractRootCacheSize* = 5
|
||||
|
||||
# RLN membership key and index files path
|
||||
const RlnCredentialsFilename* = "rlnCredentials.txt"
|
||||
|
||||
|
||||
@ -167,7 +167,9 @@ proc updateRoots*(g: OnchainGroupManager): Future[bool] {.async.} =
|
||||
return false
|
||||
|
||||
proc updateRecentRoots*(g: OnchainGroupManager): Future[bool] {.async.} =
|
||||
let bytes = (await g.fetchMerkleRoot()).valueOr:
|
||||
## Fetch recent roots from the contract roots cache and update the validRoots deque, ensuring we maintain a window of acceptable roots.
|
||||
## Contract returns array if uint256 roots, newest first, zero-padded to the cache size (e.g. 5).
|
||||
let bytes = (await g.fetchMerkleRootsCache()).valueOr:
|
||||
error "Failed to fetch current Merkle root", error = error
|
||||
return false
|
||||
|
||||
@ -176,7 +178,7 @@ proc updateRecentRoots*(g: OnchainGroupManager): Future[bool] {.async.} =
|
||||
return false
|
||||
|
||||
let chunkCount = bytes.len div 32
|
||||
if chunkCount != 5:
|
||||
if chunkCount != RlnContractRootCacheSize:
|
||||
warn "Unexpected number of recent roots returned; proceeding anyway",
|
||||
count = chunkCount
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user