Skip to content

Sync keyvaluestore (rebased) - #6608

Open
ma2bd wants to merge 5 commits into
mainfrom
ma2bd/sync-keyvaluestore-rebased
Open

Sync keyvaluestore (rebased)#6608
ma2bd wants to merge 5 commits into
mainfrom
ma2bd/sync-keyvaluestore-rebased

Conversation

@ma2bd

@ma2bd ma2bd commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Motivation

The KeyValueStore is an async library used for implementing the views. That is fine for
protocol code, but contract code is actually synchronous, so using KeyValueStore there is
the wrong tool.

This is a rebased version of #6153 on top of the current main (the original branch had
drifted 151 commits behind and no longer merged cleanly).

Fixes #3026.

Proposal

Introduce a SyncKeyValueStore that performs the operations synchronously. The translation
is direct. After this, the justification for async fn execute_operation(_) collapses and we
can write fn execute_operation(_) instead; that asyncness was entirely artificial since the
linera-sdk code already does a .blocking_wait() under the hood.

A similar change cannot be made for the Service trait since it uses async-graphql
functionality, which has no sync variant.

Notes on the rebase

The reconciliation with main preserved the following changes that landed after the original
branch was cut:

  • The u32-based, overflow-checked index/count arithmetic in LogView/QueueView (the sync
    views mirror the same u32 on-disk key format via the shared base_pre_save/base_post_save
    helpers).
  • The memory backend split into MemoryDatabase/MemoryStore, dropping the now-removed
    max_stream_queries plumbing.
  • The wrapped-fungible example's mint/burn redesign, converted to the synchronous contract API.
  • The checkpoint-events additions to the social example (summarize_events stays async as
    the trait declares; view reads inside it are now synchronous). The summarize_events
    entrypoint uses the sync run_entrypoint and resolves its future via .blocking_wait().
  • The evm-bridge example and publish-read-data-blob fixture were deleted on main, so they
    are dropped here too.

Test Plan

CI. Locally: cargo build --workspace, cargo test -p linera-views (144 lib tests + 10
sync_views_tests; the only failure is test_queue_operations_with_scylla_db_context, which
needs a live ScyllaDB), cargo test -p linera-views-derive, the examples workspace
cargo check/clippy, and nightly cargo fmt --check all pass.

Release Plan

  • These changes should be backported to the latest testnet branch, then
    • be released in a new SDK,
    • be released in a validator hotfix.

Since the .blocking_wait() calls are inside linera-sdk rather than the protocol, this can be
backported to testnet_conway; the documentation would need to be updated accordingly.

Links

@ma2bd ma2bd mentioned this pull request Jul 16, 2026
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.

Have a version of linera_views that is synchronous

1 participant