Skip to main content

Module f3

Module f3 

Source
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:

  • ConnDag answers the core’s DagRead from the dag_* tables (dag_schema.rs);
  • prepare_local is 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_pdu takes an event from a peer (signature, hash, auth rules, soft-fail, forks merged by state resolution v2) and projects it in one transaction;
  • import_snapshot starts a replica from a peer’s state (invite, send_join);
  • skeletonize erases 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_pdu did.

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 seeds themselves) of the given events, as stored wire JSON.
backfill_json
backfill: the events v and 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_id of its own.
join_template
Template for a peer’s join (make_join): an unsigned event with this room’s prev_events, auth_events and depth.
leave_template
Template for a peer’s leave (make_leave), like join_template.
mark_room
missing_events_json
get_missing_events: the ancestors of latest (not latest themselves) that are not at or behind earliest, 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 origin has 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.
pdu_json
One stored event as a wire PDU (GET /event/{eventId}), if it is a DAG event.
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 in tx; 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_pdu that says when events are missing. origin: None is 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 origin itself (the sender must be its user). keys must hold the public key of every server that signed it (the caller fetched them). Everything lands in one transaction.
room_of_event
The room a stored DAG event belongs to.
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, with at as its only forward extremity, so the events that follow cite something it holds.
state_at_json
state_ids (ids only) or state (events): the room’s state right after at, and the auth chain.
state_join_rule_is_public
A DAG room is open to anyone when its current m.room.join_rules state says public. 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.