From 1d770c5c38c6498b02b6b5e4ad8505fafcc2db32 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 29 Mar 2022 20:17:47 -0500 Subject: [PATCH 1/3] Allow non-member state sent in room batch to resolve for historic events Part of https://github.com/matrix-org/synapse/issues/12110 Complement test: https://github.com/matrix-org/complement/pull/354 Previously, they didn't resolve because async `filter_events_for_client` removes all outlier state except for out-of-band membership. --- synapse/handlers/room_batch.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/synapse/handlers/room_batch.py b/synapse/handlers/room_batch.py index a0255bd1439c..69b0a87c01e2 100644 --- a/synapse/handlers/room_batch.py +++ b/synapse/handlers/room_batch.py @@ -213,9 +213,6 @@ async def persist_state_events_at_start( room_id=room_id, action=membership, content=event_dict["content"], - # Mark as an outlier to disconnect it from the normal DAG - # and not show up between batches of history. - outlier=True, historical=True, # Only the first event in the state chain should be floating. # The rest should hang off each other in a chain. @@ -246,9 +243,6 @@ async def persist_state_events_at_start( state_event["sender"], app_service_requester.app_service ), event_dict, - # Mark as an outlier to disconnect it from the normal DAG - # and not show up between batches of history. - outlier=True, historical=True, # Only the first event in the state chain should be floating. # The rest should hang off each other in a chain. From ea0c99d36bd6b66895e7b07b11b7fb5b0ca23e96 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 29 Mar 2022 22:20:59 -0500 Subject: [PATCH 2/3] Add changelog --- changelog.d/12329.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12329.bugfix diff --git a/changelog.d/12329.bugfix b/changelog.d/12329.bugfix new file mode 100644 index 000000000000..aef41173433a --- /dev/null +++ b/changelog.d/12329.bugfix @@ -0,0 +1 @@ +Fix non-member state events not resolving for historical events when used in [MSC2716](https://github.com/matrix-org/matrix-spec-proposals/pull/2716) `/batch_send` `state_events_at_start`. From 5151de0f2cdf624593988e5c0810a046a5415e01 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 1 Apr 2022 17:50:55 -0500 Subject: [PATCH 3/3] Remove mentions of outlier having a role with the historical state chain --- synapse/handlers/room_batch.py | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/synapse/handlers/room_batch.py b/synapse/handlers/room_batch.py index 69b0a87c01e2..78e299d3a5c5 100644 --- a/synapse/handlers/room_batch.py +++ b/synapse/handlers/room_batch.py @@ -156,8 +156,8 @@ async def persist_state_events_at_start( ) -> List[str]: """Takes all `state_events_at_start` event dictionaries and creates/persists them in a floating state event chain which don't resolve into the current room - state. They are floating because they reference no prev_events and are marked - as outliers which disconnects them from the normal DAG. + state. They are floating because they reference no prev_events which disconnects + them from the normal DAG. Args: state_events_at_start: @@ -218,23 +218,18 @@ async def persist_state_events_at_start( # The rest should hang off each other in a chain. allow_no_prev_events=index == 0, prev_event_ids=prev_event_ids_for_state_chain, - # Since each state event is marked as an outlier, the - # `EventContext.for_outlier()` won't have any `state_ids` - # set and therefore can't derive any state even though the - # prev_events are set. Also since the first event in the - # state chain is floating with no `prev_events`, it can't - # derive state from anywhere automatically. So we need to - # set some state explicitly. + # The first event in the state chain is floating with no + # `prev_events` which means it can't derive state from + # anywhere automatically. So we need to set some state + # explicitly. # # Make sure to use a copy of this list because we modify it # later in the loop here. Otherwise it will be the same - # reference and also update in the event when we append later. + # reference and also update in the event when we append + # later. state_event_ids=state_event_ids.copy(), ) else: - # TODO: Add some complement tests that adds state that is not member joins - # and will use this code path. Maybe we only want to support join state events - # and can get rid of this `else`? ( event, _, @@ -248,13 +243,10 @@ async def persist_state_events_at_start( # The rest should hang off each other in a chain. allow_no_prev_events=index == 0, prev_event_ids=prev_event_ids_for_state_chain, - # Since each state event is marked as an outlier, the - # `EventContext.for_outlier()` won't have any `state_ids` - # set and therefore can't derive any state even though the - # prev_events are set. Also since the first event in the - # state chain is floating with no `prev_events`, it can't - # derive state from anywhere automatically. So we need to - # set some state explicitly. + # The first event in the state chain is floating with no + # `prev_events` which means it can't derive state from + # anywhere automatically. So we need to set some state + # explicitly. # # Make sure to use a copy of this list because we modify it # later in the loop here. Otherwise it will be the same