Stop trying to auth/persist events whose auth events we do not have. (#10907)

This commit is contained in:
Richard van der Hoff 2021-09-24 14:01:45 +01:00 committed by GitHub
parent bb7fdd821b
commit 0420d4e6a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

1
changelog.d/10907.bugfix Normal file
View File

@ -0,0 +1 @@
Fix a long-standing bug which could cause events pulled over federation to be incorrectly rejected.

View File

@ -1194,10 +1194,17 @@ class FederationEventHandler:
auth = {} auth = {}
for auth_event_id in event.auth_event_ids(): for auth_event_id in event.auth_event_ids():
ae = persisted_events.get(auth_event_id) ae = persisted_events.get(auth_event_id)
if ae: if not ae:
auth[(ae.type, ae.state_key)] = ae logger.warning(
else: "Event %s relies on auth_event %s, which could not be found.",
logger.info("Missing auth event %s", auth_event_id) event,
auth_event_id,
)
# the fact we can't find the auth event doesn't mean it doesn't
# exist, which means it is premature to reject `event`. Instead we
# just ignore it for now.
return None
auth[(ae.type, ae.state_key)] = ae
context = EventContext.for_outlier() context = EventContext.for_outlier()
context = await self._check_event_auth( context = await self._check_event_auth(
@ -1208,8 +1215,10 @@ class FederationEventHandler:
) )
return event, context return event, context
events_to_persist = await yieldable_gather_results(prep, fetched_events) events_to_persist = (
await self.persist_events_and_notify(room_id, events_to_persist) x for x in await yieldable_gather_results(prep, fetched_events) if x
)
await self.persist_events_and_notify(room_id, tuple(events_to_persist))
async def _check_event_auth( async def _check_event_auth(
self, self,
@ -1235,8 +1244,7 @@ class FederationEventHandler:
claimed_auth_event_map: claimed_auth_event_map:
A map of (type, state_key) => event for the event's claimed auth_events. A map of (type, state_key) => event for the event's claimed auth_events.
Possibly incomplete, and possibly including events that are not yet Possibly including events that were rejected, or are in the wrong room.
persisted, or authed, or in the right room.
Only populated when populating outliers. Only populated when populating outliers.