Correct a misnamed argument in state res v2 (#13467)

In state res v2, we apply two passes of iterative auth checks. The first
pass replays power events and events in their auth chains, but only
those belonging to the full conflicted set. The source code as written
suggests that we want only those belonging to the auth difference (which
is a smaller set of events).

At runtime we were doing the correct thing anyway, because the only
callsite of `_reverse_topological_power_sort` passes in the
`full_conflicted_set`. So this really is just a rename.
This commit is contained in:
David Robertson 2022-08-08 16:59:56 +01:00 committed by GitHub
parent ab18441573
commit 7a19995120
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

1
changelog.d/13467.misc Normal file
View File

@ -0,0 +1 @@
Correct a misnamed argument in state res v2 internals.

View File

@ -434,7 +434,7 @@ async def _add_event_and_auth_chain_to_graph(
event_id: str, event_id: str,
event_map: Dict[str, EventBase], event_map: Dict[str, EventBase],
state_res_store: StateResolutionStore, state_res_store: StateResolutionStore,
auth_diff: Set[str], full_conflicted_set: Set[str],
) -> None: ) -> None:
"""Helper function for _reverse_topological_power_sort that add the event """Helper function for _reverse_topological_power_sort that add the event
and its auth chain (that is in the auth diff) to the graph and its auth chain (that is in the auth diff) to the graph
@ -445,7 +445,7 @@ async def _add_event_and_auth_chain_to_graph(
event_id: Event to add to the graph event_id: Event to add to the graph
event_map event_map
state_res_store state_res_store
auth_diff: Set of event IDs that are in the auth difference. full_conflicted_set: Set of event IDs that are in the full conflicted set.
""" """
state = [event_id] state = [event_id]
@ -455,7 +455,7 @@ async def _add_event_and_auth_chain_to_graph(
event = await _get_event(room_id, eid, event_map, state_res_store) event = await _get_event(room_id, eid, event_map, state_res_store)
for aid in event.auth_event_ids(): for aid in event.auth_event_ids():
if aid in auth_diff: if aid in full_conflicted_set:
if aid not in graph: if aid not in graph:
state.append(aid) state.append(aid)
@ -468,7 +468,7 @@ async def _reverse_topological_power_sort(
event_ids: Iterable[str], event_ids: Iterable[str],
event_map: Dict[str, EventBase], event_map: Dict[str, EventBase],
state_res_store: StateResolutionStore, state_res_store: StateResolutionStore,
auth_diff: Set[str], full_conflicted_set: Set[str],
) -> List[str]: ) -> List[str]:
"""Returns a list of the event_ids sorted by reverse topological ordering, """Returns a list of the event_ids sorted by reverse topological ordering,
and then by power level and origin_server_ts and then by power level and origin_server_ts
@ -479,7 +479,7 @@ async def _reverse_topological_power_sort(
event_ids: The events to sort event_ids: The events to sort
event_map event_map
state_res_store state_res_store
auth_diff: Set of event IDs that are in the auth difference. full_conflicted_set: Set of event IDs that are in the full conflicted set.
Returns: Returns:
The sorted list The sorted list
@ -488,7 +488,7 @@ async def _reverse_topological_power_sort(
graph: Dict[str, Set[str]] = {} graph: Dict[str, Set[str]] = {}
for idx, event_id in enumerate(event_ids, start=1): for idx, event_id in enumerate(event_ids, start=1):
await _add_event_and_auth_chain_to_graph( await _add_event_and_auth_chain_to_graph(
graph, room_id, event_id, event_map, state_res_store, auth_diff graph, room_id, event_id, event_map, state_res_store, full_conflicted_set
) )
# We await occasionally when we're working with large data sets to # We await occasionally when we're working with large data sets to