Cache account witnesses
- Lingua principale
- Rust
- Stelle
- 78
- Fork
- 129
- Merge medio
- 4g 14h
- PR unite (30g)
- 52
Descrizione
`miden-client` provides various mechanisms to ease the execution of transactions with FPI:
- Users can specify before executing a transaction what data they need from a foreign account and it will be fetched before executing and added to the advice provider
- If nothing is specified, the `DataStore` reaches out to the node to resolve whatever witness is required
- With locally followed accounts, the client can also resolve witness without ever reaching out to the node
The last bullet point only really applies for storage/vault witnesses, and the followed account's data gets updated on every sync. Currently, the one thing the client cannot provide from the locally stored data is the account witnesses.
We should add a way to specify accounts for which the client can automatically get account witnesses at sync time. Initially we can make it very manual and in the future we can integrate it better with the importing process (for example, in the future it may be nice to be able to specify which combination of data from an account you want to retrieve on every sync: input notes, output notes, account witness, vault data, storage maps, etc.).
For an initial iteration we can add:
- One table for keeping `account_id` |-> `account_witness` mapping
- This table can be used to keep a list of account IDs to update
- We can add `Client::add_prefetch_account_witness(account_id: AccountId)` (or hopefully a better name) that adds the account ID to the new table, initially with a `NULL` witness.
- On each sync, we get all the account IDs in the table and we update them based on `GetAccount` requests. We should also keep account witnesses for watched accounts, which we already request anyway.
- During transaction execution we need to look up witnesses in this table, instead of going to the RPC every single time. When prefetching data (i.e, the first bullet point of the list above), we can avoid reaching out to the node if we have all the data at hand.
I think it makes sense to only keep a single account witness at a time, for the latest block only. In the future this can be expanded.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Look at the `miden-client` codebase, specifically the data fetching and syncing logic. Identify where account witnesses are currently resolved (likely via RPC calls) and where the new table for account_id -> account_witness mapping should be added. Examine the sync process to see how to integrate fetching witnesses for accounts in the new table. Check how transaction execution currently retrieves witnesses and modify it to check the local cache first.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- backend, databases
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100