0xMiden / 0xMiden/rust-sdk

`add_account` should track the tag associated with the `Address`

Offen
#1,260 8 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
78
Forks
129
Ø Merge
4 T. 14 Std.
Gemergte PRs (30 T.)
52

Beschreibung

# `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): https://github.com/0xMiden/miden-client/blob/ba14ca5e765c7c81c45a56a7114b0a156374387b/crates/rust-client/src/account/mod.rs#L155

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 `Address`es, 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 https://github.com/0xMiden/miden-base/issues/1837#issuecomment-3243999913.
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 `NoteTag`s 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](https://github.com/0xMiden/miden-client/issues/1229), instead of:
```rust
let note_tags: BTreeSet = 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`:
```rust
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:
```rust
let public_note_tags: BTreeSet = 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 = self.store.get_unique_note_tags_from_source(
NoteTagStoreSource::Address(AddressSource:All)
).await?;
// query the transport layer for private note tags
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.