mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-08-02 13:33:15 +00:00
chore: more debugging message
This commit is contained in:
parent
6520137835
commit
e519abd4c9
@ -50,7 +50,7 @@ contract(WakuRlnContract):
|
|||||||
# this constant describes max message limit of rln contract
|
# this constant describes max message limit of rln contract
|
||||||
proc MAX_MESSAGE_LIMIT(): UInt256 {.view.}
|
proc MAX_MESSAGE_LIMIT(): UInt256 {.view.}
|
||||||
# this function returns the merkleProof for a given index
|
# this function returns the merkleProof for a given index
|
||||||
proc merkleProofElements(index: EthereumUInt40): seq[UInt256] {.view.}
|
proc merkleProofElements(index: UInt256): seq[UInt256] {.view.}
|
||||||
# this function returns the merkle root
|
# this function returns the merkle root
|
||||||
proc root(): Uint256 {.view.}
|
proc root(): Uint256 {.view.}
|
||||||
|
|
||||||
@ -102,33 +102,35 @@ proc fetchMerkleProofElements*(
|
|||||||
# First check if the index is valid and within range
|
# First check if the index is valid and within range
|
||||||
let commitmentIndexInvocation = g.wakuRlnContract.get().commitmentIndex()
|
let commitmentIndexInvocation = g.wakuRlnContract.get().commitmentIndex()
|
||||||
let currentCommitmentIndex = await commitmentIndexInvocation.call()
|
let currentCommitmentIndex = await commitmentIndexInvocation.call()
|
||||||
|
|
||||||
debug "------ Checking membership index validity ------",
|
|
||||||
membershipIndex = membershipIndex,
|
|
||||||
currentCommitmentIndex = currentCommitmentIndex.toHex()
|
|
||||||
|
|
||||||
# Convert membershipIndex to UInt256 for comparison with currentCommitmentIndex
|
|
||||||
let membershipIndexUint256 = stuint(membershipIndex, 256)
|
let membershipIndexUint256 = stuint(membershipIndex, 256)
|
||||||
|
let index40 = stuint(membershipIndex, 40)
|
||||||
|
|
||||||
|
debug "------ checking if membership index is validity ------",
|
||||||
|
membershipIndex = membershipIndex,
|
||||||
|
membershipIndexHEX = membershipIndex.toHex(),
|
||||||
|
membershipIndexUint256 = membershipIndexUint256,
|
||||||
|
membershipIndexUint256HEX = membershipIndexUint256.toHex(),
|
||||||
|
currentCommitmentIndex = currentCommitmentIndex,
|
||||||
|
currentCommitmentIndexHEX = currentCommitmentIndex.toHex(),
|
||||||
|
index40 = index40,
|
||||||
|
index40HEX = index40.toHex()
|
||||||
|
|
||||||
# Ensure the membershipIndex is less than the total number of commitments
|
# Ensure the membershipIndex is less than the total number of commitments
|
||||||
if membershipIndexUint256 >= currentCommitmentIndex:
|
if membershipIndexUint256 >= currentCommitmentIndex:
|
||||||
error "Invalid membership index",
|
error "Invalid membership index",
|
||||||
membershipIndex = membershipIndex,
|
membershipIndex = membershipIndex,
|
||||||
currentCommitmentIndex = currentCommitmentIndex.toHex()
|
currentCommitmentIndex = currentCommitmentIndex.toHex()
|
||||||
return err("Invalid membership index: " & $membershipIndex &
|
return err(
|
||||||
" is >= current commitment index: " & currentCommitmentIndex.toHex())
|
"Invalid membership index: " & $membershipIndex &
|
||||||
|
" is >= current commitment index: " & currentCommitmentIndex.toHex()
|
||||||
|
)
|
||||||
|
|
||||||
# Convert membership index to EthereumUInt40 for the contract call
|
let merkleProofInvocation =
|
||||||
let index40 = stuint(membershipIndex, 40)
|
g.wakuRlnContract.get().merkleProofElements(membershipIndexUint256)
|
||||||
debug "------ Using index for merkleProofElements ------",
|
|
||||||
originalIndex = membershipIndex, index40 = index40.toHex()
|
|
||||||
|
|
||||||
let merkleProofInvocation = g.wakuRlnContract.get().merkleProofElements(index40)
|
|
||||||
|
|
||||||
# Call without retry wrapper for debugging
|
|
||||||
let merkleProof = await merkleProofInvocation.call()
|
let merkleProof = await merkleProofInvocation.call()
|
||||||
|
|
||||||
# Need to wrap in "ok" to match the function return type
|
debug "------ Merkle proof ------", merkleProof = merkleProof
|
||||||
|
|
||||||
return ok(merkleProof)
|
return ok(merkleProof)
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
error "------ Failed to fetch Merkle proof elements ------",
|
error "------ Failed to fetch Merkle proof elements ------",
|
||||||
@ -343,7 +345,7 @@ method generateProof*(
|
|||||||
if g.userMessageLimit.isNone():
|
if g.userMessageLimit.isNone():
|
||||||
return err("user message limit is not set")
|
return err("user message limit is not set")
|
||||||
|
|
||||||
debug "calling generateProof from generateProof from group_manager onchain",
|
debug "------ calling generateProof from generateProof from group_manager onchain ------",
|
||||||
data = data,
|
data = data,
|
||||||
membershipIndex = g.membershipIndex.get(),
|
membershipIndex = g.membershipIndex.get(),
|
||||||
userMessageLimit = g.userMessageLimit.get()
|
userMessageLimit = g.userMessageLimit.get()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user