0xPolygonMiden / miden-client

Client library that facilitates interaction with the Miden rollup
MIT License
25 stars 22 forks source link

Add WebStore to miden-client #402

Closed dagarcia7 closed 20 hours ago

dagarcia7 commented 6 days ago

Summary

This PR adds the WebStore, a WASM-compatible implementation of the miden-client Store trait.

It uses IndexedDB as its backend storage method to provide dependable, high-performance, and persistent storage for web-based clients, enabling seamless interaction with the Miden node in web contexts.

The existing SqliteStore utilizes SQLite as its backend, taking advantage of its robust and efficient database capabilities for data persistence. SQLite is a widely-used, serverless, self-contained SQL database engine that offers stable storage and effective querying for applications.

However, SQLite is not compatible with WASM due to its reliance on native file system access and multi-threading, which are not available in the web environment. WASM operates within a restricted sandbox in the browser, lacking direct access to the underlying file system and threading capabilities that SQLite requires.

dagarcia7 commented 1 day ago

Addressed as much feedback as I could! Just a heads up, I'm seeing this when I run cargo build --features idxdb

error[E0599]: no method named `hash` found for reference `&Note` in the current scope
   --> src/client/transactions/mod.rs:252:34
    |
252 |                 .map(|note| note.hash())
    |                                  ^^^^ method not found in `&Note`

error[E0599]: no method named `hash` found for reference `&Note` in the current scope
   --> src/client/transactions/mod.rs:257:63
    |
257 |             .filter_map(|n| (!tx_note_auth_hashes.contains(&n.hash())).then_some(n.id()))
    |                                                               ^^^^ method not found in `&Note`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `miden-client` (lib) due to 2 previous errors

I think this also shows up in regular, non WebStore builds too. Is this a known error?

bobbinth commented 1 day ago

I think this also shows up in regular, non WebStore builds too. Is this a known error?

Running cargo update may fix this.

dagarcia7 commented 1 day ago

I think this also shows up in regular, non WebStore builds too. Is this a known error?

Running cargo update may fix this.

Fixed!

Seeing this now in the integration tests

if [ -d miden-node ]; then cd miden-node ; else git clone https://github.com/0xPolygonMiden/miden-node.git && cd miden-node; fi
Cloning into 'miden-node'...
cd miden-node && git checkout "polydez-future-notes" && git pull origin "polydez-future-notes" && cargo update
error: pathspec 'polydez-future-notes' did not match any file(s) known to git
make: *** [Makefile:[8](https://github.com/0xPolygonMiden/miden-client/actions/runs/9752692487/job/26916774346?pr=402#step:6:9)4: node] Error 1
Error: Process completed with exit code 2.

Unsure what that could be as well!

bobbinth commented 1 day ago

Seeing this now in the integration tests

You probably need to rebase this branch from the latest next (if I'm reading the error correctly, it is trying to get miden-node code from a branch which has been merged into next already).

dagarcia7 commented 1 day ago

Seeing this now in the integration tests

You probably need to rebase this branch from the latest next (if I'm reading the error correctly, it is trying to get miden-node code from a branch which has been merged into next already).

I should be rebased I think 🤔 I tried to do this locally, but not sure if it's the same conditions given that I'm on a forked repo and there's funkiness with origin vs. upstream

mFragaBA commented 1 day ago

@dagarcia7 #407 got merged, it'll probably get some conflicts when you merge/rebase