Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add a write up of the state delta resolution algorithm #3122

Closed
wants to merge 2 commits into from

Conversation

erikjohnston
Copy link
Member

No description provided.

\begin{algorithmic}
\STATE $to\_recalculate \leftarrow \text{empty set of state keys}$
\STATE $pending \leftarrow G_\delta$
\WHILE{$pending$ is empty}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\WHILE{$pending$ is not empty}

@richvdh
Copy link
Member

richvdh commented Apr 20, 2018

\end{split}
\end{equation} which we call state maps, for $F, G \subset K$.

We can then compute the set of all ``unconflicted events":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better described as "unconflicted state keys" maybe?

\begin{split}
u_{f,g} : U_{f,g} \longrightarrow &\ E\\
x \longmapsto &\ \begin{cases}
f(x), & \text{if}\ f \in F \\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x \in F

\end{equation} which gets the unconflicted event for a given state key.


We can also define a function on $C_{f,g} = F \cup G \setminus U_{f,g}$:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parens around f \cup G ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

We can also define a function on $C_{f,g} = F \cup G \setminus U_{f,g}$:
\begin{equation}
c_{f,g}: C_{f,g} \rightarrow E
\end{equation} which is used to resolve conflicts between $f$ and $g$. Note that $c_{f,g}$ is either $f(x)$ or $g(x)$.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ITYM $c_{f,g}(x)$ is either ...

I don't think it's true that c_{f,g} is either f or g

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

\end{equation} which we call the resolved state of $f$ and $g$.

\begin{lemma}
$\forall x \in U_{f,g} \ s.t.\ g(x) = g'(x)$ then $r_{f,g}(x) = r_{f,g'}(x)$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could do with clarifying. ITYM:

if $\forall x (g(x) = g'(x)), x \in U_{f_g}$, then ...

\end{split}
\end{equation} which we call the resolved state of $f$ and $g$.

\begin{lemma}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like you're about to prove this, which is confusing. Suggest just stating it rather than making it a Lemma.

\alpha: E \rightarrow \mathbb{P}(K)
\end{equation} to be the mapping of an event to the type/state keys needed to auth the event, and
\begin{equation}
\alpha_{f,g}(x) = \alpha f(x) \cup \alpha g(x)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's going on here? what does \alpha f(x) mean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\alpha f(x) = \alpha(f(x)), i.e. for the event in the state f, \alpha f(x) are its auth state keys

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup makes sense. more parens ftw.


Further, we can define
\begin{equation}
a_{f,g}(x) = \bigcup_{n=0}^\infty (\alpha_{f,g})^n(x)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't you use something other than a? (or something other than \alpha?) They look pretty similar.

Further, we can define
\begin{equation}
a_{f,g}(x) = \bigcup_{n=0}^\infty (\alpha_{f,g})^n(x)
\end{equation} to be the auth chain of $f(x)$ and $g(x)$. This is well defined as there are a finite number of elements in $F \cup G$ and $a_{f,g} \rightarrow F \cup G$.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think more to the point, α → F ∩ G

a_{f,g}(x) = \bigcup_{n=0}^\infty (\alpha_{f,g})^n(x)
\end{equation} to be the auth chain of $f(x)$ and $g(x)$. This is well defined as there are a finite number of elements in $F \cup G$ and $a_{f,g} \rightarrow F \cup G$.

If we consider the implementation of $c_{f,g}$ in Synapse we can see that it depends not only on the values of $x$, but also on the resolved state of their auth events, i.e. $r_{f,g}(\alpha_{f,g}(x))$. By ``depends on" we mean that if those are the same for different values of $f$ and $g$, then the result of $c_{f,g}(x)$ is the same.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm failing to grok the By depends on sentence. "those are the same": which are the same?

the term "depends on" is used heavily in the later proofs, so I think this needs defining more precisely.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By depends on I mean, say: c_f(x) depends on r_f(x), then forall g where r_f(x) = r_g(x) then c_g(x) = c_f(x).

Its basically saying that c could be written as a pure function from f(x), g(x) and r_{f,g}(\alpha_{f,g}(x))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(i'd be tempted to abuse a proportionality symbol \propto to represent the 'depends on' relationship.

Or redefine it in terms of independence.

\end{lemma}

\begin{proof}
$c_{f,g}(x)$ depends on $x \in a_{f,g}(x)$, and $r_{f,g}(\alpha_{f,g}(x))$. Now:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is x in a ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a_{f,g}(x) = x \cup \alpha_{f,g}(x) \cup (\alpha_{f,g})^2(x) \cup ...

$c_{f,g}(x)$ depends on $x \in a_{f,g}(x)$, and $r_{f,g}(\alpha_{f,g}(x))$. Now:
\[
\begin{split}
r_{f,g}(\alpha_{f,g}(x))\ =\ & u_{f,g}(\alpha_{f,g}(x)) \cup c_{f,g}(\alpha_{f,g}(x))\\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u is only defined over the unconflicted part of the state key space. I think it's clear what you mean, but it might be good to be more precise here.

\begin{split}
r_{f,g}(\alpha_{f,g}(x))\ =\ & u_{f,g}(\alpha_{f,g}(x)) \cup c_{f,g}(\alpha_{f,g}(x))\\
\end{split}
\] but by definition $u_{f,g}(\alpha_{f,g}(x))$ depends only on $\alpha_{f,g}(x)$, so $r_{f,g}(\alpha_{f,g}(x))$ depends on $a_{f,g}(x)$ and $c_{f,g}\alpha_{f,g}(x)$.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you be consistent about c_{f,g}\alpha_{f,g}(x) vs c_{f,g}(\alpha_{f,g}(x)) ? (with my preference heavily on the former). It's particularly weird to see r with extra parens in the same sentence as c without.

\begin{split}
r_{f,g}(\alpha_{f,g}(x))\ =\ & u_{f,g}(\alpha_{f,g}(x)) \cup c_{f,g}(\alpha_{f,g}(x))\\
\end{split}
\] but by definition $u_{f,g}(\alpha_{f,g}(x))$ depends only on $\alpha_{f,g}(x)$, so $r_{f,g}(\alpha_{f,g}(x))$ depends on $a_{f,g}(x)$ and $c_{f,g}\alpha_{f,g}(x)$.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think s/depends on a/depends on α/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you split the result of what r(...) depends on to a separate \begin{equation}, since you're about to use it for induction?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err, yes, (though α is a subset of a, so its correct to say that it depends on a)

\end{split}
\] but by definition $u_{f,g}(\alpha_{f,g}(x))$ depends only on $\alpha_{f,g}(x)$, so $r_{f,g}(\alpha_{f,g}(x))$ depends on $a_{f,g}(x)$ and $c_{f,g}\alpha_{f,g}(x)$.

By induction, $c_{f,g}\alpha_{f,g}(x)$ depends on $a_{f,g}(x)$ and $c_{f,g}(\alpha_{f,g})^n(x), \forall n$. Since $(\alpha_{f,g})^n(x)$ repeats and we know $c_{f,g}$ is well defined, we can infer that $c_{f,g}(x)$ depends only on $\bigcup_{n=0}^\infty (\alpha_{f,g})^n(x) = a_{f,g}(x)$.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depends on α ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if you mean the first "depends on". Though as above its correct to say it depends on a too.

@richvdh richvdh assigned erikjohnston and unassigned richvdh Apr 23, 2018
@erikjohnston
Copy link
Member Author

Rendered

@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Apr 26, 2018
@richvdh richvdh removed their assignment Aug 16, 2018
@ara4n
Copy link
Member

ara4n commented Mar 3, 2019

this would help with #1760 (i think?) as faster state res means that the number of extremities which need to be resolved is less of a consideration (especially if their intermediary resolution results have been cached and can be built on)

@florianjacob
Copy link

For reference why this was closed:

Matthew: “this was written for state resolution v1, and needs to be done for v2”

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants