You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(platform-wallet-storage): atomic multi-key writes in KvStore #5666
TL;DR:KvStore has only single-key get / put / delete / list, so a client cannot write two related entries atomically. A crash or failed second write leaves them inconsistent.
User story
As a wallet app developer, I want to write several KvStore entries in one transaction, so that a record and the metadata that guards it are either both stored or both absent.
Scenario
Base flow
Dash Evo Tool stores an identity record and, next to it, a balance watermark: the block height of the balance it holds, used to refuse older balance responses. Both live in KvStore under the identity's scope.
Actual behavior
The record and the watermark are two separate put calls. If the second one fails after the first succeeded, the record exists without its watermark, and an older balance response can replace the newer balance until the next height-tagged write. The client cannot write the watermark first either: its own consistency rules drop a watermark that has no record, which is the right cleanup for orphans.
Expected behavior
The client writes both entries in one atomic operation: both are stored or neither is.
Detailed discussion
At 575d961, packages/rs-platform-wallet-storage/src/kv.rs (trait KvStore) exposes only per-key operations. The SQLite backend could offer a batch or transaction cheaply, since it is already one connection behind a mutex.
Possible shapes:
fn write_batch(&self, ops: &[KvOp]) -> Result<(), KvError> with KvOp::{Put { scope, key, value }, Delete { scope, key }}, applied in one SQLite transaction; or
a closure-style transaction(|tx| { tx.put(..)?; tx.delete(..)?; Ok(()) }).
Either keeps existing callers unchanged. The same value-size limits and read-only refusal apply per op.
Client context: dashpay/dash-evo-tool#1110 (feat/proof-owner-balance, src/context/identity_db/balance_watermark.rs): the first record write and its watermark seed. DET does not work around this, and the gap stays documented there until a batch API exists.
Activity