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

Improve performance of notes cache and notes nullifiers' calculation #5

Open
miloszm opened this issue Aug 26, 2024 · 1 comment
Open
Assignees

Comments

@miloszm
Copy link
Collaborator

miloszm commented Aug 26, 2024

Summary

When testing a user account owning a large number of notes, there are two main performance bottlenecks:

  1. adding a note to cache is slow as cache is based on vector while emulating a set behaviour
  2. all notes' nullifiers are calculated before each transaction sent, and there is no cache for nullifiers

The above two issues cause multiple minutes of processing for each transaction, when user has a few thousand notes

Possible solution design or implementation

For 1), base the cache implementation on BTreeSet rather than vector
For 2), introduce cache for nullifiers (consider change of the StateClient trait, which currently has the following method:

fn fetch_notes(&self, vk: &ViewKey) -> Result<Vec<EnrichedNote>, Self::Error>;

EnrichedNote type contains Note and block_height only, but it could also contain a nullifier for a given secret key, so that nullifier is also cached. This would save time if the user performs multiple operations with the same large set of notes.

Additional context

This improvement may also apply to other wallets within Dusk, such wallet-cli/wallet-core and a test wallet in Rusk.

@miloszm miloszm self-assigned this Aug 26, 2024
@dusk-network dusk-network deleted a comment Aug 26, 2024
@moCello
Copy link
Member

moCello commented Aug 26, 2024

In wallet-core there is a function map_owned that creates a map to store the Notes with their nullifiers, maybe that can help?

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

No branches or pull requests

2 participants