Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom queryFilter #57

Merged
merged 7 commits into from
Apr 27, 2023
Merged

feat: add custom queryFilter #57

merged 7 commits into from
Apr 27, 2023

Conversation

weboko
Copy link
Contributor

@weboko weboko commented Apr 25, 2023

Addressing the issue when RLNContract cannot fetch history if the range is too wide.
More details on the issue: waku-org/examples.waku.org#225 (comment)

@weboko weboko marked this pull request as ready for review April 25, 2023 21:15
@weboko weboko changed the title feat: add custom fetcher feat: add custom queryFilter Apr 25, 2023
};

// these value should be tested on other networks
const FETCH_CHUNK = 5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the issue we are encountering are going to be dependent on the Wallet and RPC Provider.

MetaMask using infura is the one with an issue. But If a user used MetaMask with another provider, fetch chunk may need to be lower or higher.

Hence, a few things:

  1. It should probably be configurable so webapp developer can fine tune the experience as it mays also depends on other calls they do to the blockchain
  2. May be good to do further research and understand how other application do this (going through all logs of a contracts).
  3. I believe we already discussed that with previous researcher, but maybe using event log as the only way to get information of existing membership is not a good smart contract design? I am not familiar with smart contract design patterns but a function call on the smart contract to get a list of memberships may be a more efficient approach, only using events to listen to new members. WDYT @rymnc ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re 3, we made the gas efficient choice to store all idCommitments in a mapping. While this makes the contract more gas efficient, it definitely increases complexity client side. If clients would prefer the tree being stored onchain, we can create a variant of the RLN contracts that do that. Let me know 🫡

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re 3, we made the gas efficient choice to store all idCommitments in a mapping. While this makes the contract more gas efficient, it definitely increases complexity client side. If clients would prefer the tree being stored onchain, we can create a variant of the RLN contracts that do that. Let me know 🫡

since idCommitments are present on a contract that means there is no reason to query events, no?

Copy link
Contributor Author

@weboko weboko Apr 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably be configurable so webapp developer can fine tune the experience as it mays also depends on other calls they do to the blockchain

Exposed configuration to outside

May be good to do further research and understand how other application do this (going through all logs of a contracts).

I did some research and I see when someone needs to query many blocks then there are two solutions - query in chunks (or have a gateway that allows huge query to run) or store data somewhere on a contract

are there any other solutions, @rymnc , @richard-ramos ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either that or use thegraph to query the events.

The problem with storing the data in the smart contract is that it will probably increase the cost of registering a new membership. Retrieving the query in chunks seem to be the usual workaround (here's an implementation i found in TS that we could use to retrieve the logs: https://github.com/MarkusSprunck/ethereum-event-scan/blob/master/src/app/services/reader.service.ts#L279-L358). I'm also thinking that to speedup loading the events next time the example is accessed, perhaps we should store them in localstorage or indexeddb, but that is something that could be implemented in future PRs

@weboko weboko merged commit 7e0966a into master Apr 27, 2023
@weboko weboko deleted the weboko/fetcher branch April 27, 2023 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants