Sync keyvaluestore (rebased) - #6608
Open
ma2bd wants to merge 5 commits into
Open
Conversation
…t and cast-lint allow in sync_views_tests.
… the e2e lockfile.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The
KeyValueStoreis an async library used for implementing the views. That is fine forprotocol code, but contract code is actually synchronous, so using
KeyValueStorethere isthe wrong tool.
This is a rebased version of #6153 on top of the current
main(the original branch haddrifted 151 commits behind and no longer merged cleanly).
Fixes #3026.
Proposal
Introduce a
SyncKeyValueStorethat performs the operations synchronously. The translationis direct. After this, the justification for
async fn execute_operation(_)collapses and wecan write
fn execute_operation(_)instead; that asyncness was entirely artificial since thelinera-sdkcode already does a.blocking_wait()under the hood.A similar change cannot be made for the
Servicetrait since it usesasync-graphqlfunctionality, which has no sync variant.
Notes on the rebase
The reconciliation with
mainpreserved the following changes that landed after the originalbranch was cut:
u32-based, overflow-checked index/count arithmetic inLogView/QueueView(the syncviews mirror the same
u32on-disk key format via the sharedbase_pre_save/base_post_savehelpers).
MemoryDatabase/MemoryStore, dropping the now-removedmax_stream_queriesplumbing.wrapped-fungibleexample's mint/burn redesign, converted to the synchronous contract API.socialexample (summarize_eventsstaysasyncasthe trait declares; view reads inside it are now synchronous). The
summarize_eventsentrypoint uses the sync
run_entrypointand resolves its future via.blocking_wait().evm-bridgeexample andpublish-read-data-blobfixture were deleted onmain, so theyare dropped here too.
Test Plan
CI. Locally:
cargo build --workspace,cargo test -p linera-views(144 lib tests + 10sync_views_tests; the only failure istest_queue_operations_with_scylla_db_context, whichneeds a live ScyllaDB),
cargo test -p linera-views-derive, the examples workspacecargo check/clippy, and nightlycargo fmt --checkall pass.Release Plan
testnetbranch, thenSince the
.blocking_wait()calls are insidelinera-sdkrather than the protocol, this can bebackported to
testnet_conway; the documentation would need to be updated accordingly.Links