From 3f28588dec6736d35ca615f6b87484d7c4a8aa4f Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 13 Oct 2021 22:50:22 -0500 Subject: [PATCH] Add graph to show how historical state plays into the DAG --- .../2716-batch-send-historical-messages.md | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/proposals/2716-batch-send-historical-messages.md b/proposals/2716-batch-send-historical-messages.md index 040318fe046..73dbc3148c3 100644 --- a/proposals/2716-batch-send-historical-messages.md +++ b/proposals/2716-batch-send-historical-messages.md @@ -499,6 +499,66 @@ flowchart BT + +#### Add in the historical state + +In order to show the display name and avatar for the historical messages, +the state provided by `state_events_at_start` needs to resolve when one of +the historical messages is fetched. + +It's probably most semantic to have the state float outside of the normal DAG +in a chain by referencing a fake `prev_event`. Then the insertion event +reference the last piece in the floating state chain. + +In Synapse, the fake `prev_event` causes it to look like an "outlier" because +the homeserver can't fully fetch and resolve the state at the point. As a +result, the state will not be resolved into the current state of the room, +and it won't be visible in the chat history. This allows us to insert multiple +batches without having a bunch of `@mxid joined the room` noise between each +batch. + +![](https://user-images.githubusercontent.com/558581/137247868-b7d5b996-02ac-49f8-bbfa-1417ddc60bae.png) + +[Mermaid live editor playground link](https://mermaid-js.github.io/mermaid-live-editor/edit/#eyJjb2RlIjoiZmxvd2NoYXJ0IEJUXG4gICAgc3ViZ3JhcGggbGl2ZVxuICAgICAgICBtYXJrZXIxPlwibWFya2VyXCJdIC0tLS0-IEIgLS0tLS0tLS0tLS0tLS0tLS0-IEFcbiAgICBlbmRcbiAgICBcbiAgICBzdWJncmFwaCBiYXRjaDBcbiAgICAgICAgYmF0Y2gwLWJhdGNoW1tcImJhdGNoXCJdXSAtLT4gYmF0Y2gwLTIoKFwiMlwiKSkgLS0-IGJhdGNoMC0xKCgxKSkgLS0-IGJhdGNoMC0wKCgwKSkgLS0-IGJhdGNoMC1pbnNlcnRpb25bL2luc2VydGlvblxcXVxuICAgIGVuZFxuXG4gICAgc3ViZ3JhcGggYm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IGJhdGNoMC1pbnNlcnRpb25CYXNlWy9pbnNlcnRpb25cXF0gLS0tLS0tLS0tLS0tLS0tPiBBXG4gICAgYmF0Y2gwLWJhdGNoIC0uLT4gYmF0Y2gwLWluc2VydGlvbkJhc2VbL2luc2VydGlvblxcXVxuICAgIGJhdGNoMS1iYXRjaCAtLi0-IGJhdGNoMC1pbnNlcnRpb25cbiAgICBiYXRjaDItYmF0Y2ggLS4tPiBiYXRjaDEtaW5zZXJ0aW9uXG4iLCJtZXJtYWlkIjoie1xuICBcInRoZW1lXCI6IFwiZGVmYXVsdFwiXG59IiwidXBkYXRlRWRpdG9yIjpmYWxzZSwiYXV0b1N5bmMiOnRydWUsInVwZGF0ZURpYWdyYW0iOmZhbHNlfQ) + +
+mermaid graph syntax + +```mermaid +flowchart BT + subgraph live + marker1>"marker"] ----> B -----------------> A + end + + subgraph batch0 + batch0-batch[["batch"]] --> batch0-2(("2")) --> batch0-1((1)) --> batch0-0((0)) --> batch0-insertion[/insertion\] + end + + subgraph batch1 + batch1-batch[["batch"]] --> batch1-2(("2")) --> batch1-1((1)) --> batch1-0((0)) --> batch1-insertion[/insertion\] + end + + subgraph batch2 + batch2-batch[["batch"]] --> batch2-2(("2")) --> batch2-1((1)) --> batch2-0((0)) --> batch2-insertion[/insertion\] + end + + + batch0-insertion --> memberBob0(["m.room.member (bob)"]) --> memberAlice0(["m.room.member (alice)"]) --> fakePrevEvent0{{fake_prev_event}} + batch1-insertion --> memberBob1(["m.room.member (bob)"]) --> memberAlice1(["m.room.member (alice)"]) --> fakePrevEvent1{{fake_prev_event}} + batch2-insertion --> memberBob2(["m.room.member (bob)"]) --> memberAlice2(["m.room.member (alice)"]) --> fakePrevEvent2{{fake_prev_event}} + + marker1 -.-> batch0-insertionBase + batch0-insertionBase[/insertion\] ---------------> A + batch0-batch -.-> batch0-insertionBase[/insertion\] + batch1-batch -.-> batch0-insertion + batch2-batch -.-> batch1-insertion +``` + +
+ + + + ## Potential issues Also see the security considerations section below.