diff --git a/synapse/event_auth.py b/synapse/event_auth.py index 41e7746305..4bfe42f9bf 100644 --- a/synapse/event_auth.py +++ b/synapse/event_auth.py @@ -195,7 +195,9 @@ async def check_state_independent_auth_rules( for event_id in prev_state_events_ids if not batched_auth_events or event_id not in batched_auth_events } - # Try to load the `prev _state_events` from `batched_auth_events` initially + # We need to do some checks on the events provided as prev_state_events, so we need to load them. + # Try to load the `prev_state_events` from `batched_auth_events` initially as that can save us + # a database hit. prev_state_events = ( {} if not batched_auth_events diff --git a/synapse/events/builder.py b/synapse/events/builder.py index ef60f252e5..8920eef3e6 100644 --- a/synapse/events/builder.py +++ b/synapse/events/builder.py @@ -198,6 +198,7 @@ class EventBuilder: if auth_event_ids is None: # Every non-create event must have a room ID assert self.room_id is not None + assert not self.room_version.msc4242_state_dags state_ids = await self._state.compute_state_after_events( self.room_id, prev_event_ids, diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 99ddb2d7b8..f09de7ccb4 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -642,7 +642,7 @@ class EventCreationHandler: prev_state_events: The state event IDs which represent the current forward extremities of the state DAG. - Only applicable on room versions which use a state DAG. + Only applicable on room versions which use a state DAG (MSC4242). Raises: ResourceLimitError if server is blocked to some resource being @@ -1003,7 +1003,7 @@ class EventCreationHandler: based on the prev_events. prev_state_events: The state event IDs which represent the current forward extremities of the state DAG. - Only applicable on room versions which use a state DAG. + Only applicable on room versions which use a state DAG (MSC4242). Returns: The event, and its stream ordering (if deduplication happened, the previous, duplicate event). @@ -1281,8 +1281,8 @@ class EventCreationHandler: prev_state_events: The state event IDs which represent the current forward extremities of the state DAG. - Only applicable on room versions which use a state DAG. If unset, populates them - from the current state dag forward extremities. + Only applicable on room versions which use a state DAG (MSC4242). + If unset, populates them from the current state dag forward extremities. Returns: Tuple of created event, UnpersistedEventContext diff --git a/synapse/storage/controllers/persist_events.py b/synapse/storage/controllers/persist_events.py index d040fbf671..be742661be 100644 --- a/synapse/storage/controllers/persist_events.py +++ b/synapse/storage/controllers/persist_events.py @@ -1034,7 +1034,7 @@ class EventsPersistenceStorageController: **{SERVER_NAME_LABEL: self.server_name} ).observe(len(result)) - # There should always be at least one forward extremity. + # There should always be at least one forward extremity. assert result, f"No state dag forward extremities left in room {room_id}!" return result