matrix-org / matrix-org/matrix-spec

What exactly should servers do when they receive events over federation

Open
#804 10 comments 1 reaction 0 assignees View on GitHub
clarification
Dominant language
HTML
Stars
330
Forks
150
Avg merge
2h 21m
Merged PRs (30d)
3

Description

The spec is unclear about what exactly needs to be done when receiving pdus via the /send request. Here's what we came up with when developing Conduit:

When receiving an event one needs to:

0. Skip the PDU if we already know about it
1. Check the server is in the room
2. Check signatures, otherwise drop
3. Check content hash, redact if doesn't match
4. Fetch any missing auth events doing all checks listed here starting at 1. These are not
timeline events
5. Reject "due to auth events" if can't get all the auth events or some of the auth events are
also rejected "due to auth events" (TODO: Or should be just drop and ignore bad events?)
6. Reject "due to auth events" if the event doesn't pass auth based on the auth events
7. Persist this event as an outlier
8. If not timeline event: stop
9. Fetch any missing prev events doing all checks listed here starting at 1. These are timeline
events (TODO: probably queue this up in the background so we don't wait for this)
10. Fetch missing state and auth chain events by calling /state_ids at backwards extremities
doing all the checks in this list starting at 1. These are not timeline events
11. Check the auth of the event passes based on the state of the event
12. Ensure that the state is derived from the previous current state (i.e. we calculated by
doing state res where one of the inputs was a previously trusted set of state, don't just
trust a set of state we got from a remote) (TODO: we do this be always inserting our current room state into stateres, is that right?)
13. Check if the event passes auth based on the "current state" of the room, if not "soft fail"
it
14. Use state resolution to find new room state

Contributor guide

Open the contributing guide

Research direction

Start with the issue's proposed processing sequence for PDUs received through /send, especially the steps marked TODO. Compare the required handling of auth events, timeline events, missing state, rejection, and soft failure against the federation specification. Done means the specification clearly defines the complete behavior and resolves the open questions.

Written by the indexing model from the issue text.

Assessment

Domain
backend-api-design, documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.