Skip to content

server, agent: concurrent short link updates by several owners - #2005

Draft
spaced4ndy wants to merge 10 commits into
simplex-chat:masterfrom
spaced4ndy:f/channel-multi-owner
Draft

spaced4ndy wants to merge 10 commits into
simplex-chat:masterfrom
spaced4ndy:f/channel-multi-owner

Conversation

@spaced4ndy

Copy link
Copy Markdown
Contributor

The server and client part of channels with several owners: the link server orders owners' changes to a channel's short link, so concurrent changes are neither lost nor overwritten unseen. Design: simplex-chat/simplex-chat#7873

Merging: this stays a draft until the simplex-chat pull request that uses it is ready. Then this one is merged first, and simplex-chat pins the merged commit. The agent part is added to this branch before then.

Protocol (SMP v24)

  • LSWP: replaces a short link's user data, and optionally the queue's recipient keys, in one step, only when the stored user data has the hash the owner sends. Otherwise it changes nothing and answers LCUR with the stored user data. Recipient command, never forwarded by a proxy.
  • LSET is refused on queues with more than one recipient key, so a single-owner write cannot overwrite data owned by several keys.
  • A transmission fits up to 6 recipient keys with the fixed and user data at their padded sizes.
  • The client function swapSMPQueueLink sends it only in v24 sessions.

Server stores

  • Memory store: the swap is one STM transaction. Postgres store: one transaction holding the row lock (SELECT … FOR UPDATE).
  • The LSET refusal is checked inside the store, on both stores.
  • Store log: a swap that changes keys writes a new LKEYS record (data and keys), followed by KEYS; a swap without keys writes LINK. Replay restores both. An older server skips LKEYS and restores the keys from KEYS.

Transport

  • A single command that fits the client's size check but not an encrypted block now fails on its own, and the session keeps working (also proposed on its own for master).

Tests and what isn't tested yet

  • New store, store-log, server and proxy tests: swap outcomes, keys, the LSET refusal through a stale queue record, concurrent swaps, restart replay, the size limit, the v24 gate, the proxy refusal.
  • The whole test suite passes with the memory stores. The Postgres builds and tests run at the end of the feature.
Short links
Message store tests
Store log tests
forwarded short link data swap

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.

2 participants