Skip to content

add_account should track the tag associated with the Address #1260

@mmagician

Description

@mmagician

Address-derived vs. AccountId-derived NoteTag

The tag derived from an Address is (potentially) different than the tag derived from an AccountId.
Currently, when we add a new account to the client store, we fall back to AccountId-derived tag (via Account -> NoteTagRecord conversion):

self.store.add_note_tag(account.into()).await?;

But, client.add_account doesn't provide any option to specify the Address as a parameter.
There are two paths:

  1. Easy path: inside add_account, derive the "default" Address::AccountIdAddress by passing in the AccountId and AddressInterface::Unspecified.
  2. New interface: let users add Addresses, for example by exposing a new add_address method, similar to add_account. Potentially deprecate add_account.
  3. Change the interface of add_account to accept AccountIdAddress instead of AccountId. This is akin to what @PhilippGackstatter suggested in create_p2id_note should take Address as parameter (or should it?) miden-base#1837 (comment).
  4. Other ideas?

These approaches would further require adding a new enum variant Address to NoteTagSource (or potentially change NoteTagSource::Account to NoteTagSource::AccountIdAddress if we choose option 3).


Query the store for NoteTags based on the source.

This part could be potentially to be split out into a separate issue, depending on the decisions above^.

It would also be great if we could query the store for tags coming from a specific source.
This would allow us to limit the amount of notes downloaded from the note transport layer to only Address-derived tags. So in Fetch notes section here, instead of:

let note_tags: BTreeSet<NoteTag> = self.store.get_unique_note_tags().await?;
// query the gRPC node for these note_tags AND query the transport layer for these tags

we could define a new store-querying source interface: NoteTagStoreSource:

pub enum NoteTagStoreSource { // name TBD
    Address(AddressSource),
    Note(NoteSource),
    User(UserSource),
}

pub enum AddressSource {
    All,
    Exact(Address)
}

// etc. for NoteSource, UserSource

And then query as:

let public_note_tags: BTreeSet<NoteTag> = self.store.get_unique_note_tags().await?; // this doesn't change, gets all note tags
// query the gRPC node for public_note_tags

let public_note_tags: BTreeSet<NoteTag> = self.store.get_unique_note_tags_from_source(
    NoteTagStoreSource::Address(AddressSource:All)
).await?;
// query the transport layer for private note tags

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    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