Skip to content

Commit

Permalink
Note a more efficient computation of the auth difference. (matrix-org…
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson authored Jun 15, 2022
1 parent 6792b7a commit a707266
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelogs/room_versions/newsfragments/1119.clarification
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
For room version 2 through 10: Note a more efficient way to compute the auth difference during state resolution.
19 changes: 13 additions & 6 deletions content/rooms/fragments/v2-state-res.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,20 @@ all of *their* auth events, and so on recursively, stretching back to the
start of the room. Put differently, these are the events reachable by walking
the graph induced by an event's `auth_events` links.

If *S* is a collection of
events, the *full auth chain of S* is the union of the auth chains of every
event *E* in *S*.

**Auth difference.**
The *auth difference* is calculated by first calculating the full auth
chain for each state *S*<sub>*i*</sub>, that is the union of the auth
chains for each event in *S*<sub>*i*</sub>, and then taking every event
that doesn't appear in every auth chain. If *C*<sub>*i*</sub> is the
full auth chain of *S*<sub>*i*</sub>, then the auth difference is
 ∪ *C*<sub>*i*</sub> −  ∩ *C*<sub>*i*</sub>.
For each state *S<sub>i</sub>*, compute its full auth chain.
The *auth difference* is the set of events which belong to some, but not all,
of these full auth chains. In symbols: if *F*(*S*) is the full auth
chain of a collection of events *S*, the auth difference is
∪<sub>*i*</sub> *F*(*S<sub>i</sub>*) - ∩<sub>*i*</sub> *F*(*S<sub>i</sub>*).

This can be computed more efficiently as
*F*(*C*) - ∩<sub>*i*</sub> *F*(*S*<sub>*i* - *C*</sub>) ,
where *C* is the conflicted state set.

**Full conflicted set.**
The *full conflicted set* is the union of the conflicted state set and
Expand Down

0 comments on commit a707266

Please sign in to comment.