Expand description
F3 (feature f3-hash-ids, off by default): rooms created while the feature is on are DAG rooms.
Every event in them (state, membership, messages) is a signed room-version-11 event with
prev_events, auth_events, depth, a content hash, this server’s ed25519 signature and an id
that is the reference hash of the signed event. Legacy rooms are never touched.
The rules live in m4a-matrix-core (storage-agnostic). This file is the store side:
ConnDaganswers the core’sDagReadfrom thedag_*tables (dag_schema.rs);prepare_localis called from the two store write functions: it builds, checks, signs and stores the event inside the caller’s transaction, so the DAG rows and the event/state projection commit or roll back together;receive_pdutakes an event from a peer (signature, hash, auth rules, soft-fail, forks merged by state resolution v2) and projects it in one transaction;import_snapshotstarts a replica from a peer’s state (invite, send_join);skeletonizeerases the content of a delivered event and keeps its id and signatures.
Not done here: redactions and public-channel (pub_events) messages keep legacy ids; gaps in
prev_events are refused rather than back-filled.
Structs§
- ConnDag
- The DAG of one room as the core sees it.
- Prepared
- The id and content a local event ended up with.
- Received
- What
receive_pdudid.
Enums§
- RecvErr
- Why a peer’s event was not taken.
Functions§
- add_key
- Add one fetched remote key (standard base64) to
keys. - auth_
chain_ of - Auth chain (events not in
seedsthemselves) of the given events, as stored wire JSON. - backfill_
json backfill: the eventsvand their ancestors, newest first.- event_
auth_ json event_auth: the auth chain of one event.- extremity_
ids - Forward extremity ids of a room.
- import_
snapshot - Start (or complete) a replica of a DAG room from a peer’s snapshot: every event is checked for its signature and content hash, stored as an outlier, the state events are projected, and the snapshot’s extremities become this replica’s forward extremities.
- import_
spec_ invite - An invite from a server that follows the spec (room version 11, no snapshot): the invite event
is verified and stored as an outlier (it is all this server knows of the room), and the stripped
state the inviter sent is projected under placeholder ids so a client can show what it is invited
to. The real events replace the placeholders when the invitee joins (
import_snapshot). - is_
f3_ room - is_
f3_ wire - A wire event of the DAG layer: hashed, no
event_idof its own. - join_
template - Template for a peer’s join (make_join): an unsigned event with this room’s
prev_events,auth_eventsanddepth. - mark_
room - missing_
events_ json get_missing_events: the ancestors oflatest(notlatestthemselves) that are not at or behindearliest, oldest first. Skeletons are served as stored.- missing_
keys - Public keys needed to check
pdus, for signers whose keys are our own (the caller fills in the rest). Returns the(server, key id)pairs that still need a key. - origin_
in_ room - Whether
originhas a user in the room (invited, joined or left): the condition for serving it history. - own_
public_ key - Public key (standard base64) of one of our own signing keys, active or retired.
- prepare_
local - Called from the store’s two write functions for every event a local user creates.
None: the room is legacy, the caller keeps its own id.Some: the event was built, checked against the room’s auth rules, signed and stored intx; the caller writes its projection with this id. - process_
historic - Events of the past from a peer (get_missing_events, backfill, an auth chain): each is checked (signature, hash or skeleton form, id, its own auth events, the state before it), stored as a non-extremity, and its timeline row is written when this server has none. They never change the current state or the forward extremities; the live event that needed them does that.
- receive_
detail receive_pduthat says when events are missing.origin: Noneis for events relayed by another server (fetched with get_missing_events): the sender may be on any server.- receive_
pdu - A peer’s event for a DAG room, sent by
originitself (the sender must be its user).keysmust hold the public key of every server that signed it (the caller fetched them). Everything lands in one transaction. - rules
- sign_
own - Sign a filled-in template with this server’s key. Returns the event id and the wire event.
- skeletonize
- Erase the content of a delivered event: the room row and the stored wire JSON become the redacted form. Its id (a hash of the redacted form), edges, hashes and signatures stay, so peers still validate it. Refuses while a federation delivery of the event is still queued.
- snapshot_
events - Every event of a snapshot as one list: state, extremities, auth chain.
- snapshot_
json - The room as it was right after
at(an event this server holds): the state events of that state and the event itself, as stored wire JSON. A peer that is invited or joins starts its replica from this, withatas its only forward extremity, so the events that follow cite something it holds. - state_
at_ json state_ids(ids only) orstate(events): the room’s state right afterat, and the auth chain.- state_
join_ rule_ is_ public - A DAG room is open to anyone when its current
m.room.join_rulesstate sayspublic. The rule is state (the rooms table’s column is fixed at creation); this is how a closed-kind room is opened to a federated user without an invite. - wire_id
- Event id of a wire event that has none of its own.