Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 61c1296

Browse files
committed
Working once you connect the floating insertion event
1 parent 1ed0276 commit 61c1296

File tree

3 files changed

+80
-25
lines changed

3 files changed

+80
-25
lines changed

synapse/handlers/federation_event.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ async def backfill(
717717
# newest) so that events are persisted before they're referenced
718718
# as a `prev_event`.
719719
# chronological_events,
720-
reverse_chronological_events,
720+
#reverse_chronological_events,
721721
backfilled=True,
722722
)
723723

@@ -1935,8 +1935,10 @@ async def _check_event_auth(
19351935
)
19361936

19371937
logger.info(
1938-
"_check_event_auth(event=%s) claimed_auth_events=%s calculated_auth_event_ids=%s - %s (%s)",
1938+
"_check_event_auth(event=%s) match=%s claimed_auth_events=%s calculated_auth_event_ids=%s - %s (%s)",
19391939
event.event_id,
1940+
collections.Counter(event.auth_event_ids())
1941+
== collections.Counter(calculated_auth_event_ids),
19401942
event.auth_event_ids(),
19411943
calculated_auth_event_ids,
19421944
event.content.get("body", event.type),

synapse/state/__init__.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ async def compute_event_context(
307307
state_ids_before_event,
308308
event.content.get("body", event.type),
309309
getattr(event, "state_key", None),
310+
# stack_info=True,
310311
)
311312

312313
if state_ids_before_event:
@@ -370,7 +371,7 @@ async def compute_event_context(
370371
state_ids_before_event = None
371372

372373
logger.info(
373-
"compute_event_context(event=%s) entry.state_group=%s state_group_before_event_prev_group=%s deltas_to_state_group_before_event=%s - %s (%s)",
374+
"compute_event_context(event=%s) resolve_state_groups_for_events entry.state_group=%s state_group_before_event_prev_group=%s deltas_to_state_group_before_event=%s - %s (%s)",
374375
event.event_id,
375376
entry.state_group,
376377
state_group_before_event_prev_group,
@@ -456,6 +457,13 @@ async def compute_event_context(
456457
),
457458
}
458459
)
460+
logger.info(
461+
"compute_event_context(event=%s) Done creating context=%s for non-state event - %s (%s)",
462+
event.event_id,
463+
event_context,
464+
event.content.get("body", event.type),
465+
getattr(event, "state_key", None),
466+
)
459467

460468
return event_context
461469

@@ -527,6 +535,11 @@ async def resolve_state_groups_for_events(
527535

528536
state_group_ids = state_groups.values()
529537

538+
logger.info(
539+
"resolve_state_groups_for_events: state_group_ids=%s state_groups=%s",
540+
state_group_ids,
541+
state_groups,
542+
)
530543
log_kv({"state_group_ids": state_group_ids, "state_groups": state_groups})
531544

532545
# check if each event has same state group id, if so there's no state to resolve
@@ -539,6 +552,11 @@ async def resolve_state_groups_for_events(
539552
) = await self._state_storage_controller.get_state_group_delta(
540553
state_group_id
541554
)
555+
logger.info(
556+
"resolve_state_groups_for_events: Returning state_group_id=%s prev_group=%s",
557+
state_group_id,
558+
prev_group,
559+
)
542560
log_kv(
543561
{
544562
"message": "Returning state_group_id",
@@ -553,6 +571,9 @@ async def resolve_state_groups_for_events(
553571
delta_ids=delta_ids,
554572
)
555573
elif len(state_group_ids_set) == 0:
574+
logger.info(
575+
"resolve_state_groups_for_events: Returning empty state group since there are no state_group_ids"
576+
)
556577
log_kv(
557578
{
558579
"message": "Returning empty state group since there are no state_group_ids",
@@ -573,6 +594,11 @@ async def resolve_state_groups_for_events(
573594
None,
574595
state_res_store=StateResolutionStore(self.store),
575596
)
597+
logger.info(
598+
"resolve_state_groups_for_events: RResolving state groups and returning result state_to_resolve=%s result=%s",
599+
state_to_resolve,
600+
result,
601+
)
576602
log_kv(
577603
{
578604
"message": "Resolving state groups and returning result",

tests/handlers/test_federation_event.py

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,8 +1020,12 @@ async def get_room_state(
10201020
EventContentFields.MSC2716_NEXT_BATCH_ID: next_batch_id,
10211021
EventContentFields.MSC2716_HISTORICAL: True,
10221022
},
1023-
allow_no_prev_events=True,
1024-
prev_event_ids=[],
1023+
# It all works when I add a prev_event for the floating
1024+
# insertion event but the event no longer floats.
1025+
# It's able to resolve state at the prev_events though.
1026+
prev_event_ids=[event_before.event_id],
1027+
# allow_no_prev_events=True,
1028+
# prev_event_ids=[],
10251029
auth_event_ids=historical_auth_event_ids,
10261030
state_event_ids=historical_state_event_ids,
10271031
depth=inherited_depth,
@@ -1076,6 +1080,25 @@ async def get_room_state(
10761080
_add_to_known_event_list(base_insertion_event, historical_state_events)
10771081

10781082
# Chronological
1083+
pulled_events: List[EventBase] = [
1084+
# Beginning of room (oldest messages)
1085+
# *list(state_map.values()),
1086+
room_create_event,
1087+
pl_event,
1088+
as_membership_event,
1089+
state_map.get((EventTypes.JoinRules, "")),
1090+
state_map.get((EventTypes.RoomHistoryVisibility, "")),
1091+
event_before,
1092+
# HISTORICAL MESSAGE END
1093+
insertion_event,
1094+
historical_message_event,
1095+
batch_event,
1096+
base_insertion_event,
1097+
# HISTORICAL MESSAGE START
1098+
event_after,
1099+
# Latest in the room (newest messages)
1100+
]
1101+
10791102
# pulled_events: List[EventBase] = [
10801103
# # Beginning of room (oldest messages)
10811104
# # *list(state_map.values()),
@@ -1098,22 +1121,22 @@ async def get_room_state(
10981121
# The order that we get after passing reverse chronological events in
10991122
# that mostly passes. Only the insertion event is rejected but the
11001123
# historical messages appear /messages scrollback.
1101-
pulled_events: List[EventBase] = [
1102-
# Beginning of room (oldest messages)
1103-
# *list(state_map.values()),
1104-
room_create_event,
1105-
pl_event,
1106-
as_membership_event,
1107-
state_map.get((EventTypes.JoinRules, "")),
1108-
state_map.get((EventTypes.RoomHistoryVisibility, "")),
1109-
event_before,
1110-
event_after,
1111-
base_insertion_event,
1112-
batch_event,
1113-
historical_message_event,
1114-
insertion_event,
1115-
# Latest in the room (newest messages)
1116-
]
1124+
# pulled_events: List[EventBase] = [
1125+
# # Beginning of room (oldest messages)
1126+
# # *list(state_map.values()),
1127+
# room_create_event,
1128+
# pl_event,
1129+
# as_membership_event,
1130+
# state_map.get((EventTypes.JoinRules, "")),
1131+
# state_map.get((EventTypes.RoomHistoryVisibility, "")),
1132+
# event_before,
1133+
# event_after,
1134+
# base_insertion_event,
1135+
# batch_event,
1136+
# historical_message_event,
1137+
# insertion_event,
1138+
# # Latest in the room (newest messages)
1139+
# ]
11171140

11181141
import logging
11191142

@@ -1217,8 +1240,12 @@ async def get_room_state(
12171240
)
12181241
)
12191242

1220-
assert (
1221-
actual_events_in_room_chronological == expected_event_order
1222-
), assertion_message
1243+
# assert (
1244+
# actual_events_in_room_chronological == expected_event_order
1245+
# ), assertion_message
12231246

1224-
# self.assertEqual(actual_events_in_room_chronological, expected_event_order)
1247+
self.assertEqual(
1248+
[event.event_id for event in actual_events_in_room_chronological],
1249+
[event.event_id for event in expected_event_order],
1250+
assertion_message,
1251+
)

0 commit comments

Comments
 (0)