Skip to content

EventBuilder: stop emitting legacy origin/prev_state keys for room v3+ - #469

Open
SamyRai wants to merge 2 commits into
matrix-org:mainfrom
SamyRai:fix/omit-legacy-event-format-keys-v3plus
Open

SamyRai wants to merge 2 commits into
matrix-org:mainfrom
SamyRai:fix/omit-legacy-event-format-keys-v3plus

Conversation

@SamyRai

@SamyRai SamyRai commented Sep 22, 2026

Copy link
Copy Markdown

EventBuilder.Build serialises every event with the top-level origin key, and state events additionally get prev_state: []. Both keys were removed from the event format in room v3.

Strict peers that redact with a legacy key list before deriving event IDs (e.g. SyTest's mock federation server) end up with IDs that disagree with the ones we declared and fail resolving our event references. This surfaces as the long-failing SyTest case Server correctly resyncs when server leaves and rejoins a room against Dendrite.

This change gates both keys on EventFormatV1 (rooms v1/v2 only). Newly built events remain self-consistent: content hashes and signatures are computed over exactly what is serialised, and both the spec (12-key) and legacy (17-key) redaction of a key-free event produce the same reference hash. Stored events are unaffected — redaction simply no longer finds the keys.

A regression test asserts key presence/absence across room versions 1, 2, 6, 10 and 12, for state and non-state events.

Damir Mukimov added 2 commits September 22, 2026 20:00
The 'origin' key and the state-event 'prev_state' key were removed from
the event format in room v3. EventBuilder.Build emitted them for all
room versions, which makes strict peers (e.g. SyTest's mock federation
server) that keep those keys when redacting derive event IDs that
disagree with the declared ones.

Only emit both keys for EventFormatV1 (room v1/v2). New v3+ events are
self-consistent: content hashes and signatures are computed over what is
actually serialised, and both spec (12-key) and legacy (17-key) redaction
of a key-free event produce the same reference hash. Stored events are
unaffected.
The repository is Apache-2.0 and its files carry no per-file headers.
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.

1 participant