Skip to content

Extend contract to reduce number of Web3 RPC calls #116

@stubbsta

Description

@stubbsta

Background

In the current RLN implementation, each nwaku node that needs to generate or verify a zero-knowledge proof polls the on-chain Merkle tree contract every 5 seconds to fetch the latest root. This is necessary because the root changes each time another membership is registered or erased, potentially with every new block (e.g., Linea has a 2–3s block time).
This results in a continuous stream of eth_call requests to a Web3 RPC endpoint.
This issue is defined in the roadmap and related discussions here.

Problem

The frequent polling results in a high number of RPC requests, which can negatively impact users—especially those using limited or free-tier Web3 RPC providers, or those running multiple nodes that share the same endpoint.

A bug was identified related to membership insertion time - it is currently possible for a node to receive a message with a root "from the future" which is then invalid. This may be solved with the improved WebRTC call strategy that this issue aims to achieve.

Possible Solutions

  1. Add a sliding window of latest roots to the contract - added gas cost to write to the contract
  2. A node is triggered for the latest root when it receives a message
  3. Polling strategy - run simulations to determine what polling time is optimal and what are the factors that impact it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions