update RLN contract abi functions and procs

This commit is contained in:
stubbsta 2025-04-15 12:40:27 +02:00
parent ef20fd1d1a
commit d8decd497c
2 changed files with 15 additions and 22 deletions

View File

@ -39,7 +39,7 @@ proc TheWakuNetworkConf*(T: type ClusterConf): ClusterConf =
rlnRelayDynamic: true,
rlnRelayChainId: RelayChainId,
rlnEpochSizeSec: 600,
rlnRelayUserMessageLimit: 100,
rlnRelayUserMessageLimit: 20,
numShardsInNetwork: 8,
discv5Discovery: true,
discv5BootstrapNodes:

View File

@ -30,17 +30,11 @@ logScope:
# using the when predicate does not work within the contract macro, hence need to dupe
contract(WakuRlnContract):
# this serves as an entrypoint into the rln membership set
proc register(
idCommitment: UInt256, userMessageLimit: UInt32, idCommitmentsToErase: seq[UInt256]
)
proc register(idCommitment: UInt256, userMessageLimit: UInt32, idCommitmentsToErase: seq[UInt256])
# Initializes the implementation contract (only used in unit tests)
proc initialize(maxMessageLimit: UInt256)
# this event is raised when a new member is registered
proc MembershipRegistered(
idCommitment: UInt256, membershipRateLimit: UInt256, index: UInt32
) {.event.}
proc MembershipRegistered(idCommitment: UInt256, membershipRateLimit: UInt256, index: UInt32) {.event.}
# this function denotes existence of a given user
proc isInMembershipSet(idCommitment: Uint256): bool {.view.}
# this constant describes the next index of a new member
@ -305,14 +299,12 @@ method register*(
let idCommitment = identityCredential.idCommitment.toUInt256()
let idCommitmentsToErase: seq[UInt256] = @[]
debug "registering the member",
idCommitment = idCommitment,
userMessageLimit = userMessageLimit,
idCommitmentsToErase = idCommitmentsToErase
idCommitment = idCommitment, userMessageLimit = userMessageLimit, idCommitmentsToErase = idCommitmentsToErase
var txHash: TxHash
g.retryWrapper(txHash, "Failed to register the member"):
await wakuRlnContract
.register(idCommitment, userMessageLimit.stuint(32), idCommitmentsToErase)
.send(gasPrice = gasPrice)
await wakuRlnContract.register(idCommitment, userMessageLimit.stuint(32),idCommitmentsToErase).send(
gasPrice = gasPrice
)
# wait for the transaction to be mined
var tsReceipt: ReceiptObject
@ -335,9 +327,7 @@ method register*(
debug "third topic", firstTopic = firstTopic
# the hash of the signature of MembershipRegistered(uint256,uint256,uint32) event is equal to the following hex value
if firstTopic !=
cast[FixedBytes[32]](keccak.keccak256.digest(
"MembershipRegistered(uint256,uint256,uint32)"
).data):
cast[FixedBytes[32]](keccak.keccak256.digest("MembershipRegistered(uint256,uint256,uint32)").data):
raise newException(ValueError, "register: unexpected event signature")
# the arguments of the raised event i.e., MembershipRegistered are encoded inside the data field
@ -633,10 +623,13 @@ method init*(g: OnchainGroupManager): Future[GroupManagerResult[void]] {.async.}
# now we check on the contract if the commitment actually has a membership
let idCommitmentBytes = keystoreCred.identityCredential.idCommitment
let idCommitmentUInt256 = keystoreCred.identityCredential.idCommitment.toUInt256()
let idCommitmentHex = idCommitmentBytes.inHex()
debug "Keystore idCommitment in bytes", idCommitmentBytes = idCommitmentBytes
debug "Keystore idCommitment in UInt256 ", idCommitmentUInt256 = idCommitmentUInt256
debug "Keystore idCommitment in hex ", idCommitmentHex = idCommitmentHex
let idCommitmentHex = idCommitmentBytes.inHex()
debug "Keystore idCommitment in bytes",
idCommitmentBytes = idCommitmentBytes
debug "Keystore idCommitment in UInt256 ",
idCommitmentUInt256 = idCommitmentUInt256
debug "Keystore idCommitment in hex ",
idCommitmentHex = idCommitmentHex
let idCommitment = idCommitmentUInt256
try:
# let membershipExists =