waku-org/nwaku

chore(rln-relay): deprecate tree sync strategy

Opened this issue · 4 comments

Background

With the changes to the rln-v2 contracts, it is now possible to fetch the merkleProofElements from the contract and use that to generate proofs instead.

Details

Add a proc to the contract definition in

contract(WakuRlnContract):
# this serves as an entrypoint into the rln membership set
proc register(
idCommitment: UInt256, userMessageLimit: UInt32
)
# Initializes the implementation contract (only used in unit tests)
proc initialize(maxMessageLimit: UInt256)
# this event is raised when a new member is registered
proc MemberRegistered(
rateCommitment: UInt256, index: Uint32
) {.event.}
# this function denotes existence of a given user
proc memberExists(idCommitment: Uint256): UInt256 {.view.}
# this constant describes the next index of a new member
proc commitmentIndex(): UInt256 {.view.}
# this constant describes the block number this contract was deployed on
proc deployedBlockNumber(): UInt256 {.view.}
# this constant describes max message limit of rln contract
proc MAX_MESSAGE_LIMIT(): UInt256 {.view.}
like so -

  # this function returns the merkleProof for a given index
  proc merkleProofElements(index: Uint32): seq[Uint256] {.view.}

and fetch it every time an event is emitted by the contract. Use this to generate proofs instead.

Acceptance criteria

A list of tasks that need to be done for the issue to be considered resolved.

  • Cache the root of the tree every time an event is emitted by the contract
  • Use the new api in zerokit to generate proofs by passing in the serialized witness
  • Cache the merkleProof every time an event is emitted by the contract
  • Override the GroupManager.generateProof in the OnchainGroupManager by using the custom witness we will pass in

This issue is blocked at the moment due to our nim-web3 dependency being out of date. The version we use does not support returning a sequence of elements from the smart contract.

After bumping to the latest version of nim-web3, transaction signing seems to not work as expected, and hence we're blocked

@seemenkina I know with this issue being blocked your focus has been elsewhere, but do you know if there's an update on the nim-web3 limitation?

@jm-clius as I see yesterday they started using a newer version of nim in the dependencies - I suspect it will now be possible to continue with this task

@seemenkina, thanks for the feedback. My understanding from nwaku is that the dependencies in nwaku will be updated within the next few days. :) cc @NagyZoltanPeter