Skip to content

(DO NOT MERGE) test: run the v6 embedded wallet in React Native - #772

Draft
Cheetah0x wants to merge 13 commits into
v6from
test/rn-v6
Draft

Cheetah0x wants to merge 13 commits into
v6from
test/rn-v6

Conversation

@Cheetah0x

@Cheetah0x Cheetah0x commented Nov 23, 2026 •

Copy link
Copy Markdown

Note

TL;DR Lets the v6 embedded wallet run inside a phone app by running its storage on the phone's own SQLite library. Browser wallets keep v6's storage and their data, and do not re-sync.

Experiment only. Do not merge.

This branch backports the labs side of AztecProtocol/aztec-packages#25878 (@aztec-foundation/react-native) to v6, so the v6 embedded wallet runs in an app's Hermes. On React Native the wallet's storage runs the v6 browser store and containers unchanged, with their SQL on op-sqlite instead of an OPFS worker. It replaces the earlier approach, which reimplemented the store over the kv-sqlite C++ Kv service.

Changes

  • The v6 sqlite-opfs store sends each request to a port, SqlitePort in store.ts, whose request(req) resolves with the response. In a browser, open() still takes the pool lock and runs the quarantine, then opens on connectSqliteWorker(log) (connect_worker.ts). That port starts the OPFS worker and matches its replies to requests by id, as the store did before. That module sits behind the #sqlite-worker package import, whose react-native target is a stub, so Metro never parses the worker's import.meta.
  • sqlite-opfs/op_sqlite_port.ts answers the same nine requests with op-sqlite. sqlite-opfs/react_native.ts opens the store on it and keeps the data-directory helpers. The react-native export condition on @aztec-labs/kv-store/sqlite-opfs (and on #msgpackr and #ordered-binary) selects it, so the PXE and the embedded wallet open it unchanged. Each store is a database file in <app data dir>/kv-store/<pool directory>/. The port leaves out op-sqlite's encryptionKey option for an unencrypted store, because op-sqlite's native open reads the option as a string whenever it is present, and an undefined key failed every unencrypted open on a device.
  • The table schema and the encryption-error mapping move out of the worker into modules that the worker and the op-sqlite adapter share.
  • @op-engineering/op-sqlite is an optional peer dependency (^19.0.5), and a pinned dev dependency for the tests. The app must list it in its own dependencies and set "op-sqlite": { "sqlcipher": true } in its package.json for encrypted stores.
  • Gives the wallets ./embedded entry the react-native condition.
  • Keeps PXE_DATA_SCHEMA_VERSION (16) as in v6. Web wallets see no change and do not re-sync.
  • Removes kv-store/src/kv-sqlite/, the ./kv-sqlite export and the portal: links to an aztec-packages checkout. The lockfile differs from v6 only by op-sqlite.

Differences from labs patches 0016–0018

  • 0016 (the browser store on kv-sqlite): not taken. React Native uses the v6 containers, so multimap values hash with ohash on both platforms.
  • 0017 (the store in React Native): replaced. The store's API and the data-directory helpers (listStores, deleteStore, deletePoolDirectory) are kept, but the store is v6's over op-sqlite rather than kv-sqlite over JSI. Encryption is SQLCipher rather than sqlite3mc's ChaCha20, so a database the kv-sqlite build encrypted does not open under this one.
  • 0018 (the embedded wallet's react-native condition): taken as is.

Results

In aztecprotocol/build:3.2 (linux-arm64), at 0abe6339af:

  • kv-store browser tests for sqlite-opfs: 132/132 across 11 files, as on v6. They include older_version_compat, store_management, and the pool lock and integrity tests.
  • React Native store tests: 69/69. They run the shared map, multimap, array, set and singleton suites, and the directory and encryption tests, against a stand-in for op-sqlite built on node:sqlite (react-native/fake_op_sqlite.ts). The stand-in rejects an encryptionKey option that is not a string, as op-sqlite does: without the port fix, 65 of the 69 fail. At c4018d60e2, breaking the adapter's blob conversion failed 32 of them.
  • The typecheck of kv-store, pxe and wallets passes, and so do eslint and prettier. TXE's bundle-size guard passes.
  • An esbuild bundle of @aztec-labs/kv-store/sqlite-opfs with the react-native condition has no import.meta, no Worker and no sqlite3mc-wasm. At c4018d60e2, the obsidion-wallet smoke build (aztec-labs-eng/obsidion-wallet#4421) bundled with Metro and compiled to Hermes bytecode.

On a device, at 0abe6339af: a local build of the obsidion-wallet engine app (aztec-labs-eng/obsidion-wallet#4427) ran a token deploy, mint and private transfer on an iPhone 17 Pro against staging-v6, with the wallet on op-sqlite and proving in Hermes. It passed in 248.2s, of which 52.5s was outside waiting for blocks.

Not yet run with op-sqlite: proof parity and the Hermes tests.

Known issues

  • Wrong-key handling with SQLCipher is checked only against the node:sqlite stand-in, not on a device.
  • On React Native, exportDb throws, and binding a bigint throws because op-sqlite cannot bind one. No container binds one.
  • The SQLCipher key is a JavaScript string on its way to op-sqlite, so it cannot be zeroed.
  • The browser's pool lock and pool integrity code still ships in the React Native bundle. Only the browser open() calls it.
  • RN Babel's regenerator transform runs only in debug Hermes builds. It fails on await inside a template literal at key-store/src/key_store.ts:408. Release builds work.

🤖 Generated with Claude Code

Cheetah0x and others added 4 commits November 23, 2026 11:11
Ports aztec-packages labs patches 0016-0018 (AztecProtocol/aztec-packages#25876,
#25878) onto v6, for an experiment only:

- kv-store runs its browser store on @aztec-labs/kv-sqlite and gains a
  react-native export of @aztec-labs/kv-store/sqlite-opfs.
- wallets resolves the embedded wallet's browser entry under React Native.
- PXE_DATA_SCHEMA_VERSION goes to 17, so the PXE opens a fresh store.

pins.mjs and the root resolutions take the kv-sqlite packages at v6's pin.
No release publishes them yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Points the kv-sqlite resolutions at ../../aztec-packages-rn-parity, a checkout of
AztecProtocol/aztec-packages cl/react-native, for a local experiment only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pins check maps only @aztec-foundation resolutions. kv-sqlite is an @aztec-labs package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@socket-security

socket-security Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​op-engineering/​op-sqlite@​19.0.51001008596100

View full report

Cheetah0x and others added 9 commits November 24, 2026 16:56
The React Native store needs only kv-sqlite and the sqlite-opfs react-native
entry. Rebuilding the browser OPFS store on kv-sqlite's wasm build changed the
multimap hash and forced a PXE re-sync, so this restores the v6 browser store.

- Restore src/sqlite-opfs to v6 and delete opfs_files.ts.
- Revert PXE_DATA_SCHEMA_VERSION to 16 and its compat snapshot.
- Restore the indexeddb array and the shared array suite to v6.
- Move sqlite3mc-wasm back to dependencies. Drop kv-sqlite-files.
- Export the encryption and corruption errors of kv-sqlite from the
  react-native entry, because the kv-sqlite store throws those classes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…elpers

- kv-sqlite re-exports the v6 sqlite-opfs error classes, so the package has
  one SqliteEncryptionError and one SqliteCorruptionError again.
- listStores and deletePoolDirectory are async, so a bad directory rejects
  as in the browser. The embedded wallet's corruption self-heal relies on
  `.catch` there. listStores lists only directories.
- The duplicate-value array case runs on the kv-sqlite store only, because
  the v6 browser and IndexedDB arrays do not support it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Points the kv-sqlite portals at ../../aztec-packages-ipc-audit-fixes, a
checkout of AztecProtocol/aztec-packages cl/ipc-audit-fixes at 1484720b69,
for a local experiment only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The kv-sqlite portals now point at the aztec-packages checkout of PR 25887
at 1385dc5bce, where kv-sqlite has no wasm module. The store tests run on
the process and napi backends, and the docs no longer list wasm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The v6 sqlite-opfs store now sends its requests to a port. In a browser
the port is the OPFS worker, as before. On React Native it is an adapter
over op-sqlite, so the app runs the v6 store and containers unchanged.

- The store takes the port from a connect function. Its open() keeps
  the pool lock, the quarantine and the worker.
- The worker's import.meta moves behind #sqlite-worker, so Metro never
  parses it.
- The schema and the encryption error mapping move to modules that the
  worker and the adapter share.
- kv-sqlite, its containers and its portals are removed. op-sqlite is
  an optional peer dependency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The OPFS worker's wiring moves to connect_worker.ts, so the store's
  open() passes connectSqliteWorker and does not wire the worker itself.
- The key checks become a function outside the class.
- The op-sqlite adapter moves to op_sqlite_port.ts. react_native.ts
  keeps the store's entry and the data-directory helpers.
- The test's op-sqlite stand-in moves to fake_op_sqlite.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The store now calls port.request(req) and awaits the response. The browser
worker connector owns the request ids and pending map, and op-sqlite returns
its responses directly instead of through a callback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
op-sqlite's native open reads encryptionKey as a string whenever the
option is present, so passing undefined failed every unencrypted open on a
device. The node:sqlite stand-in now rejects it the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant