Skip to content

Fix state resolution v2.1 for room version 12 - #472

Open
mtrossbach wants to merge 1 commit into
matrix-org:mainfrom
siegelkern:fix-state-res-v2.1
Open

mtrossbach wants to merge 1 commit into
matrix-org:mainfrom
siegelkern:fix-state-res-v2.1

Conversation

@mtrossbach

Copy link
Copy Markdown
  • addFromAuthEventsIfNotRejected adds the matching auth event, not the event under check.
  • ResolveStateConflictsV2New holds the room's create event from the start (taken from the auth
    events, else from the state sets), as ReverseTopologicalOrdering does since Ensure the create event is cached prior to sorting #459: it takes part
    in every auth check and in the power level of a privileged creator, and under v2.1 it is otherwise
    absent until the unconflicted state is reapplied at the end. The create event is unique to the
    room, so this changes nothing under v2.
  • The conflicted subgraph walk no longer prints, and skips an event missing from the auth events
    (such an origin is a conflicted event, which the full conflicted set holds already).

Tests (stateresolutionv2_1_test.go) build signed room version 12 events and check that a
conflicted topic resolves by mainline order, that an event present in one state set alone survives,
that conflicted power levels and join rules resolve without a panic, that a power level change its
sender may not make is dropped, and that nothing is written to stdout.

Fixes #471

Pull Request Checklist

Signed-off-by: Markus Troßbach markus@trossbach.net

…2New

Three defects in the v2.1 path:

- authAndApplyEvents' fallback to an event's auth events added the event
  itself to the auth provider in place of the matching auth event, so
  every conflicted event checked before the partial state held its key
  failed auth. v2.1 starts the iterative auth checks from an empty state
  map, so this dropped every conflicted non-control event.
- In room version 12 the create event stands in no event's auth_events
  and v2.1 applies no unconflicted state first, so resolvedCreate was
  never set: getPowerLevelFromAuthEvents panicked on the first conflicted
  control event, and every auth check lacked the create event. The
  resolver now holds the room's create event from the start.
- calculateFullAuthChainAndConflictedSubgraph printed every conflicted
  subgraph to stdout, and inserted a nil PDU for a conflicted origin that
  was missing from the auth events.

Tests build a room version 12 room and resolve a conflicted topic, an
event present in one state set alone, conflicted power levels and join
rules, and a power level change its sender may not make.

Signed-off-by: Markus Troßbach <markus@trossbach.net>
mtrossbach added a commit to siegelkern/gomatrixserverlib that referenced this pull request Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

State resolution v2.1 drops conflicted events and panics for room version 12

1 participant