Skip to content

Commit de7c01a

Browse files
committed
simulation: network-spec: fetch mini protocol
1 parent af05a3f commit de7c01a

File tree

1 file changed

+150
-6
lines changed

1 file changed

+150
-6
lines changed

simulation/docs/network-spec/miniprotocols.tex

Lines changed: 150 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ \subsubsection{Description}
8484
allowed. IB-relay, EB-relay, and Vote-relay are each parametrized by
8585
the maximum age beyond which a datum is no longer
8686
relayed\footnote{older EBs and IBs referenced by the blockchain can be
87-
accessed from the \catchup{} in Sec.\ref{ptcl:catch-up}}. IB-relay and
87+
accessed from the \catchup{} mini protocol (Sec.~\ref{ptcl:catch-up}).}. IB-relay and
8888
EB-relay rely on \Announcements{} to let consumers know when block bodies
8989
are available as well. Consumers request IB and EB bodies through the corresponding
90-
\fetch{} protocol (Sec.~\ref{ptcl:fetch}).
90+
\fetch{} mini protocol (Sec.~\ref{ptcl:fetch}). For EB-relay we specify the \datum{} to be eb-header, by which we mean the constant size part of an Endorse block, while the references (to IBs and EBs) are considered the body.
9191

9292
\begin{table}[h!]
9393
\begin{tabular}{l l l l l l l l}
@@ -288,10 +288,154 @@ \subsection{Producer and Consumer Implementation}
288288
intend on requesting any of the available datums.
289289

290290

291-
\section{\catchup{} mini-protocol}
292-
\label{ptcl:catch-up}
293-
TBD
294-
295291
\section{\fetch{} mini-protocol}
296292
\label{ptcl:fetch}
293+
294+
\renewcommand{\StIdle}{\state{StIdle}}
295+
\renewcommand{\StBusy}{\state{StBusy}}
296+
\newcommand{\StStreaming}{\state{StStreaming}}
297+
\renewcommand{\StDone}{\state{StDone}}
298+
\newcommand{\MsgRequestBodies}{\msg{MsgRequestBodies}}
299+
\newcommand{\MsgStartBatch}{\msg{MsgStartBatch}}
300+
\newcommand{\MsgNoBlocks}{\msg{MsgNoBlocks}}
301+
\newcommand{\MsgBody}{\msg{MsgBody}}
302+
\newcommand{\MsgBatchDone}{\msg{MsgBatchDone}}
303+
\newcommand{\MsgConsumerDone}{\msg{MsgConsumerDone}}
304+
\newcommand{\point}{\text{point}}
305+
\newcommand{\slot}{\text{slot}}
306+
\newcommand{\body}{\text{body}}
307+
308+
\subsection{Description}
309+
310+
The \fetch{} mini protocol enables a node to download block bodies identified by a pair of slot and block id (i.e. hash). It is intended for on-the-fly block diffusion, complementing the \relay{} mini protocol.
311+
312+
It is a minor variation of the Block Fetch mini protocol used for
313+
Praos blocks: IBs and EBs do not have a notion of range, so they are
314+
requested by individual identifiers.
315+
316+
\paragraph{Parameters} A \fetch{} instance is specified by these parameters
317+
\begin{description}
318+
\item [\id{}] Identifier for a body to fetch.
319+
\item [\body{}] Block body itself.
320+
\end{description}
321+
322+
\paragraph{Instances} are listed in Table~{table:fetch-instances}. The \body{} descriptions included here are for illustration, in particular to clarify what we mean by \body{} of an Endorse block.
323+
\begin{table}[h!]
324+
\begin{tabular}{l l l l l l l l}
325+
\header{instance} & \header{\id{}} & \header{\body{}} \\\hline
326+
IB-fetch & hash & $[\text{Tx}]$ \\
327+
EB-fetch & hash & $([\text{IBRef}],[\text{EBRef}])$\\
328+
\end{tabular}
329+
\caption{\fetch{} mini-protocol instances.}
330+
\label{table:fetch-instances}
331+
\end{table}
332+
333+
\subsection{State machine}
334+
335+
\begin{figure}[h]
336+
\begin{tikzpicture}[->,shorten >=1pt,auto,node distance=4.5cm, semithick]
337+
\tikzstyle{every state}=[fill=red,draw=none,text=white]
338+
\node[state, mygreen,initial] at (-1cm,0cm) (Idle) {\StIdle};
339+
\node[state] at (4cm,0cm) (Done) {\StDone};
340+
\node[state, myblue] at (-3cm,-3cm) (Busy) {\StBusy};
341+
\node[state, myblue] at (4cm,-3cm) (Streaming) {\StStreaming};
342+
343+
\draw (Idle) edge[above] node[fill=white]{\MsgConsumerDone} (Done);
344+
\draw (Idle) edge[left,bend right] node[fill=white]{\MsgRequestBodies} (Busy);
345+
\draw (Busy) edge[above,bend right] node[fill=white]{\MsgNoBlocks} (Idle);
346+
\draw (Busy) edge[below] node[fill=white]{\MsgStartBatch} (Streaming);
347+
\draw (Streaming) edge[loop right] node[fill=white,left=-10mm]{\MsgBody} (Streaming);
348+
\draw (Streaming) edge[right] node[fill=white,left=-15mm]{\MsgBatchDone} (Idle);
349+
\end{tikzpicture}
350+
\caption{State machine of the \fetch{} mini-protocol}
351+
\end{figure}
352+
353+
\begin{figure}[h]
354+
\begin{center}
355+
\begin{tabular}{l|l}
356+
\header{state} & \header{agency} \\\hline
357+
\StIdle & \Consumer \\
358+
\StBusy & \Producer \\
359+
\StStreaming & \Producer \\
360+
\end{tabular}
361+
\caption{\fetch{} state agencies}
362+
\end{center}
363+
\end{figure}
364+
365+
\paragraph{Protocol messages}
366+
Let \point be a pair $(\slot{},\id)$.
367+
\begin{description}
368+
\item [\MsgRequestBodies{} {\boldmath $[\point{}]$}]
369+
The consumer requests a sequence of bodies from the producer.
370+
\todo{If we keep the streaming setup, we could abstract from $[\point{}]$ to a \emph{sequence} parameter, allowing the original Block Fetch as an instance.}
371+
\item [\MsgNoBlocks]
372+
The producer tells the consumer that it does not have all of the blocks in the requested sequence.
373+
\item [\MsgStartBatch]
374+
The producer starts body streaming.
375+
\todo{Does a streaming setup still makes sense, or should we drop it in favor of pipelining?}
376+
\item [\MsgBody{} {\boldmath $(\body{})$}]
377+
Stream a single block's body.
378+
\item [\MsgBatchDone]
379+
The producer ends block streaming.
380+
\item [\MsgConsumerDone]
381+
The consumer terminates the protocol.
382+
\end{description}
383+
384+
Transition table is shown in table~\ref{table:fetch}.
385+
386+
\begin{table}[h!]
387+
\begin{center}
388+
\begin{tabular}{l|l|l|l}
389+
\header{from state} & \header{message} & \header{parameters} & \header{to state} \\\hline
390+
\StIdle & \MsgConsumerDone & & \StDone \\
391+
\StIdle & \MsgRequestBodies & $[\point{}]$ & \StBusy \\
392+
\StBusy & \MsgNoBlocks & & \StIdle \\
393+
\StBusy & \MsgStartBatch & & \StStreaming \\
394+
\StStreaming & \MsgBody & $\body{}$ & \StStreaming \\
395+
\StStreaming & \MsgBatchDone & & \StIdle \\
396+
\end{tabular}
397+
\end{center}
398+
\caption{\fetch{} mini-protocol messages.}
399+
\label{table:fetch}
400+
\end{table}
401+
402+
\iffalse
403+
\subsection{Size limits per state}
404+
405+
These limits bound how many bytes can be send in a given state, indirectly this
406+
limits payload size of each message. If a space limit is violated the
407+
connection SHOULD be torn down.
408+
409+
\begin{table}[h!]
410+
\begin{center}
411+
\begin{tabular}{l|r}
412+
\header{state} & \header{size limit in bytes} \\\hline
413+
\StIdle & \texttt{65535} \\
414+
\StBusy & \texttt{65535} \\
415+
\StStreaming & \texttt{2500000} \\
416+
\end{tabular}
417+
% \caption{size limits per state}
418+
\end{center}
419+
\end{table}
420+
421+
\subsection{Timeouts per state}
422+
423+
These limits bound how much time the receiver side can wait for arrival of
424+
a message. If a timeout is violated the connection SHOULD be torn down.
425+
426+
\begin{table}[h!]
427+
\begin{center}
428+
\begin{tabular}{l|r}
429+
\header{state} & \header{timeout} \\\hline
430+
\StIdle & - \\
431+
\StBusy & \texttt{60}s \\
432+
\StStreaming & \texttt{60}s \\
433+
\end{tabular}
434+
% \caption{timeouts per state}
435+
\end{center}
436+
\end{table}
437+
\fi
438+
439+
\section{\catchup{} mini-protocol}
440+
\label{ptcl:catch-up}
297441
TBD

0 commit comments

Comments
 (0)