Skip to content

feat(kv-store): add readOnlyTransaction to AztecAsyncKVStore - #440

Draft
spalladino wants to merge 2 commits into
spl/faster-block-ingestionfrom
spl/kv-store-read-only-tx
Draft

spalladino wants to merge 2 commits into
spl/faster-block-ingestionfrom
spl/kv-store-read-only-tx

Conversation

@spalladino

@spalladino spalladino commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Stack

Bottom to top, each PR targets the branch below it:

Context

Part of A-1817. Redoes the TypeScript API of AztecProtocol/aztec-packages#25280 (closed after the repo split). The native read-only LMDB transactions are in AztecProtocol/aztec-packages#25631 and not released yet, so this adds the API with every backend delegating to transactionAsync. A-2377 swaps the lmdb-v2 implementation to a real native snapshot once released.

Approach

  • AztecAsyncKVStore.readOnlyTransaction(callback): runs the callback against a consistent view. Implemented on lmdb-v2, lmdb v1, sqlite-opfs, indexeddb and the pxe store spy, all delegating to transactionAsync (same nesting semantics). On lmdb-v2 it still goes through the writer queue for now; callers must not write inside it, since that will stop working once it becomes a real snapshot.
  • ReadTransaction.getMany (from feat: getMany in maps #129) now sends at most 1024 keys per GET message, bounding message size and how long one read holds its transaction.

API changes

AztecAsyncKVStore gains readOnlyTransaction<T>(callback: () => Promise<T>): Promise<T>.

Adds `readOnlyTransaction(callback)`, which runs the callback against a consistent view of the store so that no
write can land between two of its reads. Nested calls reuse the enclosing transaction, matching `transactionAsync`.

Every backend, lmdb-v2 included, implements it with `transactionAsync` for now, so on lmdb-v2 the callback still
goes through the single writer queue. Callers can move their read paths onto it today; a later change can back the
lmdb-v2 implementation with a native LMDB read transaction, so readers stop queueing behind writers, without
touching those callers.
…ssages

`ReadTransaction.getMany` sent every key in a single GET message. It now sends at most `GET_CHUNK_SIZE` (1024) keys
per message, which bounds the size of each request and response for callers that batch-read many keys, such as
the archiver's per-block log reads.

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