summary refs log tree commit diff
path: root/synapse/state/v2.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Split `event_auth.check` into two parts (#10940)Richard van der Hoff2021-09-291-3/+1
| | | | | | | | | | | | | Broadly, the existing `event_auth.check` function has two parts: * a validation section: checks that the event isn't too big, that it has the rught signatures, etc. This bit is independent of the rest of the state in the room, and so need only be done once for each event. * an auth section: ensures that the event is allowed, given the rest of the state in the room. This gets done multiple times, against various sets of room state, because it forms part of the state res algorithm. Currently, this is implemented with `do_sig_check` and `do_size_check` parameters, but I think that makes everything hard to follow. Instead, we split the function in two and call each part separately where it is needed.
* Update the MSC3083 support to verify if joins are from an authorized server. ↵Patrick Cloke2021-07-261-6/+5
| | | | (#10254)
* Use inline type hints in various other places (in `synapse/`) (#10380)Jonathan de Jong2021-07-151-9/+9
|
* Remove `synapse.types.Collection` (#9856)Richard van der Hoff2021-04-221-1/+2
| | | This is no longer required, since we have dropped support for Python 3.5.
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
| | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-1/+5
| | | | | | | - Update black version to the latest - Run black auto formatting over the codebase - Run autoformatting according to [`docs/code_style.md `](https://github.com/matrix-org/synapse/blob/80d6dc9783aa80886a133756028984dbf8920168/docs/code_style.md) - Update `code_style.md` docs around installing black to use the correct version
* Fix mainline ordering in state res v2 (#8971)Erik Johnston2020-12-181-1/+1
| | | | | | This had two effects 1) it'd give the wrong answer and b) would iterate *all* power levels in the auth chain of each event. The latter of which can be *very* expensive for certain types of IRC bridge rooms that have large numbers of power level changes.
* Pass room_id to get_auth_chain_difference (#8879)Erik Johnston2020-12-041-2/+7
| | | | | This is so that we can choose which algorithm to use based on the room ID.
* Correctly handle unpersisted events when calculating auth chain difference. ↵Erik Johnston2020-12-021-4/+83
| | | | | | | | | (#8827) We do state res with unpersisted events when calculating the new current state of the room, so that should be the only thing impacted. I don't think this is tooooo big of a deal as: 1. the next time a state event happens in the room the current state should correct itself; 2. in the common case all the unpersisted events' auth events will be pulled in by other state, so will still return the correct result (or one which is sufficiently close to not affect the result); and 3. we mostly use the state at an event to do important operations, which isn't affected by this.
* Fix typos and spelling errors. (#8639)Patrick Cloke2020-10-231-1/+1
|
* Define StateMap as immutable and add a MutableStateMap type. (#8183)Patrick Cloke2020-08-281-3/+3
|
* Add type hints for state. (#8140)Patrick Cloke2020-08-241-88/+167
|
* Convert state resolution to async/await (#7942)Patrick Cloke2020-07-241-58/+49
|
* Add another yield point to state res v2 (#7746)Erik Johnston2020-06-261-2/+10
|
* Yield during large v2 state res. (#7735)Erik Johnston2020-06-241-10/+46
| | | | | | | | | | | State res v2 across large data sets can be very CPU intensive, and if all the relevant events are in the cache the algorithm will run from start to finish within a single reactor tick. This can result in blocking the reactor tick for several seconds, which can have major repercussions on other requests. To fix this we simply add the occaisonal `sleep(0)` during iterations to yield execution until the next reactor tick. The aim is to only do this for large data sets so that we don't impact otherwise quick resolutions.=
* Speed up state res v2 across large state differences. (#7725)Erik Johnston2020-06-191-1/+2
|
* Replace iteritems/itervalues/iterkeys with native versions. (#7692)Patrick Cloke2020-06-151-4/+2
|
* Improve get auth chain difference algorithm. (#7095)Erik Johnston2020-03-181-28/+4
| | | | | | | | | | | It was originally implemented by pulling the full auth chain of all state sets out of the database and doing set comparison. However, that can take a lot work if the state and auth chains are large. Instead, lets try and fetch the auth chains at the same time and calculate the difference on the fly, allowing us to bail early if all the auth chains converge. Assuming that the auth chains do converge more often than not, this should improve performance. Hopefully.
* Clarify list/set/dict/tuple comprehensions and enforce via flake8 (#6957)Patrick Cloke2020-02-211-4/+4
| | | | Ensure good comprehension hygiene using flake8-comprehensions.
* Reduce auth chains fetched during v2 state res. (#6952)Erik Johnston2020-02-191-1/+1
| | | | | | The state res v2 algorithm only cares about the difference between auth chains, so we can pass in the known common state to the `get_auth_chain` storage function so that it can ignore those events.
* Pass room version object into event_auth.check and check_redaction (#6788)Richard van der Hoff2020-01-281-1/+3
| | | | | | | These are easier to work with than the strings and we normally have one around. This fixes `FederationHander._persist_auth_tree` which was passing a RoomVersion object into event_auth.check instead of a string.
* Add StateMap type alias (#6715)Erik Johnston2020-01-161-4/+5
|
* Hacks to work around #6605 (#6608)Richard van der Hoff2019-12-311-15/+37
| | | | | When we have an event which refers to non-existent auth_events, ignore said events rather than exploding in a ball of fire. Fixes #6605.
* sanity-checking for events used in state res (#6531)Richard van der Hoff2019-12-161-27/+73
| | | | | When we perform state resolution, check that all of the events involved are in the right room.
* Replace returnValue with return (#5736)Amber Brown2019-07-231-13/+13
|
* Run Black. (#5482)Amber Brown2019-06-201-48/+44
|
* Pass through room version to event authErik Johnston2019-01-251-5/+9
|
* Add helpers for getting prev and auth events (#4139)Erik Johnston2018-11-061-8/+8
| | | | | | | * Add helpers for getting prev and auth events This is in preparation for allowing the event format to change between room versions.
* Fix None exception in state res v2Erik Johnston2018-11-021-0/+4
|
* Rename resolve_events_with_factoryErik Johnston2018-10-241-1/+1
|
* Add v2 state res algorithm.Erik Johnston2018-10-161-0/+544
We hook this up to the vdh test room version.