32 Commits

Author SHA1 Message Date
Kegan Dougal
08d3ec9745 only use the hero avatar if the room is a DM 2024-01-22 10:34:06 +00:00
Kegan Dougal
0bd026fc09 bugfix: correctly tell clients when the fallback key has been used
Fixes a class of unable to decrypt errors caused when the fallback
key was used but the client was unaware.
2024-01-04 17:06:28 +00:00
David Robertson
5e9b594826
Report all errors when trying multiple matchers 2023-10-19 14:22:27 +01:00
David Robertson
e7e78a6754
Mark log matchers as helpers 2023-10-19 14:21:35 +01:00
David Robertson
a51230d852
Merge remote-tracking branch 'origin/main' into dmr/extension-scoping-fix 2023-08-15 17:41:56 +01:00
David Robertson
59a6554615
Define avatar field on sync3.Room 2023-07-18 10:42:44 +01:00
David Robertson
64183a3b99
Add helper Matcher for logging the rooms section
Useful for debugging a test.
2023-07-18 10:39:34 +01:00
David Robertson
4eb9bcc27f
Improve MatchResponse errmsg formatting
- Print it out in red so you can spot it easily in a long test log
- Pretty print the response json, because life's too short to train your
  brain to be a JSON parser.
2023-07-18 10:38:35 +01:00
David Robertson
790ae22726
MatchRoomSubscription: include room ID in err msg 2023-07-18 10:36:20 +01:00
Kegan Dougal
f22ef91da6 bugfix: distinguish between a 0 invited_count and a missing invited_count 2023-07-07 15:16:59 +01:00
David Robertson
59d2d27d3d
Improve test output 2023-06-16 10:34:33 +01:00
David Robertson
212dc34d78
Deflake gappy state integration test 2023-04-27 15:42:35 +01:00
David Robertson
02456f37de
Merge branch 'dmr/finer-extensions-account-data' into dmr/fine-extensions-receipts 2023-04-03 20:11:45 +01:00
David Robertson
7f491b03cf
Fix matchers to not segfault 2023-04-03 19:45:47 +01:00
David Robertson
4ad28818d2
Batch of comments 2023-04-03 19:29:11 +01:00
David Robertson
3d305f6988
Remove unused matcher 2023-04-03 14:04:44 +01:00
David Robertson
0ff7ff0b42
Test 2 2023-04-03 13:56:38 +01:00
David Robertson
3a44187245
Test case 1 2023-04-03 12:50:14 +01:00
David Robertson
15209b5e71
Update tests 2023-03-31 17:46:32 +01:00
David Robertson
11ca86f085
Initial test case 2023-03-31 15:28:03 +01:00
David Robertson
8d134b6ed9
Rudimentary test case 2023-03-28 14:53:21 +01:00
Kegan Dougal
66a010f249 extensions refactor: handle processing extensions in the same way
This allows us to automatically trace and automatically process only
enabled extensions. Live update code will be modified to use the same
code paths.
2023-02-08 12:58:52 +00:00
kegsay
d5af0266c8
Merge branch 'main' into kegan/lists-as-keys 2023-01-18 15:25:03 +00:00
Kegan Dougal
6c4f7d3722 improvement: completely refactor device data updates
- `Conn`s now expose a direct `OnUpdate(caches.Update)` function
  for updates which concern a specific device ID.
- Add a bitset in `DeviceData` to indicate if the OTK or fallback keys were changed.
- Pass through the affected `DeviceID` in `pubsub.V2DeviceData` updates.
- Remove `DeviceDataTable.SelectFrom` as it was unused.
- Refactor how the poller invokes `OnE2EEData`: it now only does this if
  there are changes to OTK counts and/or fallback key types and/or device lists,
  and _only_ sends those fields, setting the rest to the zero value.
- Remove noisy logging.
- Add `caches.DeviceDataUpdate` which has no data but serves to wake-up the long poller.
- Only send OTK counts / fallback key types when they have changed, not constantly. This
  matches the behaviour described in MSC3884

The entire flow now looks like:
- Poller notices a diff against in-memory version of otk count and invokes `OnE2EEData`
- Handler updates device data table, bumps the changed bit for otk count.
- Other handler gets the pubsub update, directly finds the `Conn` based on the `DeviceID`.
  Invokes `OnUpdate(caches.DeviceDataUpdate)`
- This update is handled by the E2EE extension which then pulls the data out from the database
  and returns it.
- On initial connections, all OTK / fallback data is returned.
2022-12-22 15:08:42 +00:00
Kegan Dougal
ca6ceb28da BREAKING: Change the API to refer to lists by keys not index positions
This provides more flexibility to refer to lists as well as delete them.
2022-12-20 13:32:39 +00:00
Kegan Dougal
aa28df161c Rename package -> github.com/matrix-org/sliding-sync 2022-12-15 11:08:50 +00:00
Kegan Dougal
be8543a21a add extensions for typing and receipts; bugfixes and additional perf improvements
Features:
 - Add `typing` extension.
 - Add `receipts` extension.
 - Add comprehensive prometheus `/metrics` activated via `SYNCV3_PROM`.
 - Add `SYNCV3_PPROF` support.
 - Add `by_notification_level` sort order.
 - Add `include_old_rooms` support.
 - Add support for `$ME` and `$LAZY`.
 - Add correct filtering when `*,*` is used as `required_state`.
 - Add `num_live` to each room response to indicate how many timeline entries are live.

Bug fixes:
 - Use a stricter comparison function on ranges: fixes an issue whereby UTs fail on go1.19 due to change in sorting algorithm.
 - Send back an `errcode` on HTTP errors (e.g expired sessions).
 - Remove `unsigned.txn_id` on insertion into the DB. Otherwise other users would see other users txn IDs :(
 - Improve range delta algorithm: previously it didn't handle cases like `[0,20] -> [20,30]` and would panic.
 - Send HTTP 400 for invalid range requests.
 - Don't publish no-op unread counts which just adds extra noise.
 - Fix leaking DB connections which could eventually consume all available connections.
 - Ensure we always unblock WaitUntilInitialSync even on invalid access tokens. Other code relies on WaitUntilInitialSync() actually returning at _some_ point e.g on startup we have N workers which bound the number of concurrent pollers made at any one time, we need to not just hog a worker forever.

Improvements:
 - Greatly improve startup times of sync3 handlers by improving `JoinedRoomsTracker`: a modest amount of data would take ~28s to create the handler, now it takes 4s.
 - Massively improve initial initial v3 sync times, by refactoring `JoinedRoomsTracker`, from ~47s to <1s.
 - Add `SlidingSyncUntil...` in tests to reduce races.
 - Tweak the API shape of JoinedUsersForRoom to reduce state block processing time for large rooms from 63s to 39s.
 - Add trace task for initial syncs.
 - Include the proxy version in UA strings.
 - HTTP errors now wait 1s before returning to stop clients tight-looping on error.
 - Pending event buffer is now 2000.
 - Index the room ID first to cull the most events when returning timeline entries. Speeds up `SelectLatestEventsBetween` by a factor of 8.
 - Remove cancelled `m.room_key_requests` from the to-device inbox. Cuts down the amount of events in the inbox by ~94% for very large (20k+) inboxes, ~50% for moderate sized (200 events) inboxes. Adds book-keeping to remember the unacked to-device position for each client.
2022-12-14 18:53:55 +00:00
Kegan Dougal
7e7a8a98ce feat/bugfix: Add invited|joined_count to room response JSON
This is so clients can accurately calculate the push rule:
```
{"kind":"room_member_count","is":"2"}
```
Also fixed a bug in the global room metadata for the joined/invited
counts where it could be wrong because of Synapse sending duplicate
join events as we were tracking +-1 deltas. We now calculate these
counts based on the set of user IDs in a specific membership state.
2022-08-30 17:27:58 +01:00
Kegan Dougal
47ddc04652 E2EE extension: Add support for device_unused_fallback_key_types
With tests
2022-08-09 10:05:18 +01:00
Kegan Dougal
0d3157d610 Add support for txn_id in request/response
Missing buffering
2022-08-03 15:33:56 +01:00
Kegan Dougal
a40441e963 Migrate lists_test to end-to-end tests
Add more helper functions like `WithPos` and `MatchTimeline`.
2022-07-26 17:54:58 +01:00
Kegan Dougal
5b0e8568ea tests: move Match* functions to testutils/m
In preparation for migrating end-to-end style integration tests
to be actual end-to-end tests. The intended split is:
 - Does the test exclusively use the public sliding sync API for test assertions?
 - Does the test exclusively use the public sync v2 API for configuring the test?
If the answer to both questions is YES, then they should be end-to-end tests.
Some examples of this include testing core functionality of the API like
room subscriptions, multiple lists, filters, extensions, etc.

Some examples of tests which are NOT end-to-end tests include:
 - Testing connection handling (e.g sending multiple duplicate requests)
 - Ensuring outstanding requests get cancelled.
 - Testing restarts of the proxy.
 - Testing out-of-order responses.
 - Benchmarks.

These all involve configuring the test / asserting different things, which would
be extremely difficult to reliably engineer using a real homeserver.
2022-07-26 10:11:06 +01:00