From a1f7ee2a0e892014855752432fa2e000c05f125f Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 14 Dec 2022 14:06:34 +0000 Subject: [PATCH 1/2] Allow `compute_state_after_events` to use partial state if fetching a subset of state that is trusted during a partial join. --- synapse/state/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/synapse/state/__init__.py b/synapse/state/__init__.py index ee5469d5a8e9..fdfb46ab82ad 100644 --- a/synapse/state/__init__.py +++ b/synapse/state/__init__.py @@ -202,14 +202,20 @@ async def compute_state_after_events( room_id: the room_id containing the given events. event_ids: the events whose state should be fetched and resolved. await_full_state: if `True`, will block if we do not yet have complete state - at the given `event_id`s, regardless of whether `state_filter` is - satisfied by partial state. + at these events and `state_filter` is not satisfied by partial state. + Defaults to `True`. Returns: the state dict (a mapping from (event_type, state_key) -> event_id) which holds the resolution of the states after the given event IDs. """ logger.debug("calling resolve_state_groups from compute_state_after_events") + if ( + await_full_state + and state_filter + and not state_filter.must_await_full_state(self.hs.is_mine_id) + ): + await_full_state = False ret = await self.resolve_state_groups_for_events( room_id, event_ids, await_full_state ) From 09bc604be6785dba13d7ca198abb361cbf5084b4 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 14 Dec 2022 14:15:09 +0000 Subject: [PATCH 2/2] Changelog --- changelog.d/14676.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/14676.misc diff --git a/changelog.d/14676.misc b/changelog.d/14676.misc new file mode 100644 index 000000000000..8a41df9c64c3 --- /dev/null +++ b/changelog.d/14676.misc @@ -0,0 +1 @@ +Faster joins: make `computer_state_after_events` consistent with other state-fetching functions that take a `StateFilter`.