Skip to content

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

@miloszm

Description

@miloszm

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions