\in SL_s \wedge \forall \tuple{s_s, sv_s} \in SL_s, s \geq s_s$ \\\r
$MinSlot(SL_s)= \tuple{s, sv} \mid \tuple{s, sv} \r
\in SL_s \wedge \forall \tuple{s_s, sv_s} \in SL_s, s \leq s_s$ \\\r
-$SeqN(\tuple{s, sv})=s$ \\\r
-$SlotVal(\tuple{s, sv})=sv$ \\\r
+$SeqN(slot_s = \tuple{s, sv})=s$ \\\r
+$SlotVal(slot_s = \tuple{s, sv})=sv$ \\\r
\r
\begin{algorithmic}[1]\r
\Function{GetSlot}{$s_g$}\r
\State $max \gets max'$\r
\EndIf\r
\State $\tuple{s_n,sv_n} \gets MaxSlot(SL)$\Comment{Last sv}\r
-\State $s_n \gets SeqN(\tuple{s_n,sv_n})$\r
+%\State $s_n \gets SeqN(\tuple{s_n,sv_n})$\r
\If{$(s_p = s_n + 1)$}\r
\If{$n = max$}\r
\State $\tuple{s_m,sv_m} \gets MinSlot(SL)$\Comment{First sv}\r
$SeqN(\tuple{s, sv})=s$ \\\r
$SlotVal(\tuple{s, sv})=sv$ \\\r
$CreateLastSL(s,sv,id)=\tuple{s,sv,id}=sl_{last}$ \\\r
+$CreateEntLV(kv_s,s_s)=\tuple{kv_s,s_s}$ \\\r
$Decrypt(SK_s,sv_s)=Dat_s=\tuple{s,id,hmac_p,DE,hmac_c}$ \\\r
$GetSeqN(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=s$ \\\r
$GetMacId(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=id$ \\\r
\wedge \forall ss_s \in SS_{live}, ss = ss_s$ \\\r
$GetLiveCR(CR_{live},cr_s)= cr$ \textit{such that} $cr \in CR_{live} \r
\wedge \forall cr_s \in CR_{live}, cr = cr_s$ \\\r
-$GetLivEntLastS(LV_s,de_s)= s$ \textit{such that} $\tuple{de, s} \in LV_s \r
-\wedge \forall \tuple{de_s, s_s} \in LV_s, de_s = de$ \\\r
+$GetLivEntLastS(LV_s,kv_s)= s$ \textit{such that} $\tuple{kv, s} \in LV_s \r
+\wedge \forall \tuple{kv_s, s_s} \in LV_s, kv_s = kv$ \\\r
$GetKV($key-value data entry$)=\tuple{k_s,v_s} = kv_s$ \\\r
$GetSS($slot-sequence data entry$)=\tuple{id_s,s_{s_{last}}} = ss_s$ \\\r
$GetQS($queue-state data entry$)=qs_s$ \\\r
$GetCR($collision-resolution data entry$)=\tuple{s_s,id_s} = cr_s$ \\\r
-$GetS(\tuple{s, id})=s$ \\\r
-$GetId(\tuple{s, id})=id$ \\\r
-$GetKey(\tuple{k, v})=k$ \\\r
-$GetVal(\tuple{k, v})=v$ \\\r
+$GetKey(kv = \tuple{k, v})=k$ \\\r
+$GetVal(kv = \tuple{k, v})=v$ \\\r
+$GetId(ss = \tuple{id, s_{last}})=id$ \\\r
+$GetSLast(ss = \tuple{id, s_{last}})=s_{last}$ \\\r
+$GetS(cr = \tuple{s, id})=s$ \\\r
+$GetId(cr = \tuple{s, id})=id$ \\\r
$GetKeyVal(DT_s,k_s)= \tuple{k, v}$ \textit{such that} $\tuple{k, v} \r
\in DT_s \wedge \forall \tuple{k_s, v_s} \in DT_s, k = k_s$ \\\r
$MaxLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \r
\r
\begin{algorithmic}[1]\r
\Function{GetSlotSeq}{$DE_s$}\r
-\State $DE_{ss} \gets \{de_s | de_s \in DE_s, de_s \in D \land de_s = ss\}$\r
+\State $DE_{ss} \gets \{de_s | de_s \in DE_s, de_s = ss\}$\r
\State \Return{$DE_{ss}$}\r
\EndFunction\r
\end{algorithmic}\r
\r
\begin{algorithmic}[1]\r
\Function{GetColRes}{$DE_s$}\r
-\State $DE_{cr} \gets \{de_s | de_s \in DE_s, de_s \in D \land de_s = cr\}$\r
+\State $DE_{cr} \gets \{de_s | de_s \in DE_s, de_s = cr\}$\r
\State \Return{$DE_{cr}$}\r
\EndFunction\r
\end{algorithmic}\r
\end{algorithmic}\r
\r
\begin{algorithmic}[1]\r
-\Function{UpdateKVLivEnt}{$LV_s,de_s,s_s$}\r
-\State $s_t \gets GetLivEntLastS(LV_s,de_s)$\r
+\Function{UpdateKVLivEnt}{$LV_s,kv_s,s_s$}\r
+\State $s_t \gets GetLivEntLastS(LV_s,kv_s)$\r
\If{$s_t = \emptyset$}\r
- \State $LV_s \gets LV_s \cup \{\tuple{de_s,s_s}\}$\Comment{First occurrence}\r
+ \State $LV_s \gets LV_s \cup \{\tuple{kv_s,s_s}\}$\Comment{First occurrence}\r
\Else\r
\If{$s_s > s_t$}\Comment{Update entry with a later s}\r
- \State $LV_s \gets (LV_s - \{\tuple{de_s,s_t}\}) \cup \r
- \{\tuple{de_s,s_s}\}$\r
+ \State $LV_s \gets (LV_s - \{\tuple{kv_s,s_t}\}) \cup \r
+ \{\tuple{kv_s,s_s}\}$\r
\EndIf\r
\EndIf\r
\State \Return{$LV_s$}\r
\Function{UpdateSSLivEnt}{$SS_{s_{live}},MS_s$}\r
\State $s_{s_{min}} \gets MinLastSeqN(MS_s)$\r
\ForAll{$ss_s \in SS_{s_{live}}$}\r
- \State $\tuple{id_s,s_{s_{last}}} \gets GetSS(ss_s)$\r
+ \State $s_{s_{last}} \gets GetSLast(ss_s)$\r
\If{$s_{s_{min}} > s_{s_{last}}$}\Comment{Remove if dead}\r
- \State $SS_{s_{live}} \gets SS_{s_{live}} - \{\tuple{id_s,s_{s_{last}}}\}$ \r
+ \State $SS_{s_{live}} \gets SS_{s_{live}} - \{ss_s\}$ \r
\EndIf\r
\EndFor\r
\State \Return{$SS_{s_{live}}$}\r
\Function{UpdateCRLivEnt}{$CR_{s_{live}},MS_s$}\r
\State $s_{s_{min}} \gets MinLastSeqN(MS_s)$\r
\ForAll{$cr_s \in CR_{s_{live}}$}\r
- \State $\tuple{s_s,id_s} \gets GetCR(cr_s)$\r
+ \State $s_s \gets GetS(cr_s)$\r
\If{$s_{s_{min}} > s_s$}\Comment{Remove if dead}\r
- \State $SS_{s_{live}} \gets SS_{s_{live}} - \{\tuple{s_s,id_s}\}$ \r
+ \State $CR_{s_{live}} \gets CR_{s_{live}} - \{cr_s\}$ \r
\EndIf\r
\EndFor\r
\State \Return{$CR_{s_{live}}$}\r
\end{algorithmic}\r
\r
\begin{algorithmic}[1]\r
-\Procedure{CheckLastSeqN}{$MS_s,MS_t$}\Comment{Check $MS_t$ based on the newer $MS_s$}\r
-\For {$\tuple{id, s_t}$ in $MS_t$}\r
+\Procedure{CheckLastSeqN}{$MS_s,MS_t$}\r
+\For {$\tuple{id, s_t}$ in $MS_t$}\Comment{Check $MS_t$ based on the newer $MS_s$}\r
\State $s_s \gets MS_s[id]$\r
\If{$s_s = \emptyset$}\r
\Call{Error}{'No $s$ for machine $id$'}\r
\end{algorithmic}\r
\r
\begin{algorithmic}[1]\r
-\Procedure{CheckCollision}{$MS_s,SM_s,\tuple{s_s,id_s}$}\r
-\If{$\tuple{s_s,id_s} \neq \emptyset$}\r
- \State $s_s \gets GetS(\tuple{s_s,id_s})$\r
- \State $id_s \gets GetId(\tuple{s_s,id_s})$\r
+\Procedure{CheckCollision}{$MS_s,SM_s,cr_s$}\r
+\If{$cr_s \neq \emptyset$}\r
+ \State $s_s \gets GetS(cr_s)$\r
+ \State $id_s \gets GetId(cr_s)$\r
\State $s_{s_{last}} \gets GetLastSeqN(MS_s,id_s)$\r
\If{$s_{s_{last}} < s_s$}\r
- \State $\Call{CheckColRes}{SM_s,\tuple{s_s,id_s}}$\r
+ \State $\Call{CheckColRes}{SM_s,cr_s}$\r
\EndIf\r
\EndIf\r
\EndProcedure\r
\end{algorithmic}\r
\r
\begin{algorithmic}[1]\r
-\Procedure{CheckColRes}{$SM_s,\tuple{s_t,id_t}$}\Comment{Check $id_s$ in $SM_s$}\r
+\Procedure{CheckColRes}{$SM_s,cr_t$}\Comment{Check $id_s$ in $SM_s$}\r
+\State $s_t \gets GetS(cr_t)$\r
\State $id_s \gets SM_s[s_t]$\r
\If{$id_s \neq id_t$}\r
- \State \Call{Error}{'Invalid $id_s$ for this slot update'}\r
+ \State \Call{Error}{'Invalid $id$ for this slot update'}\r
\EndIf\r
\EndProcedure\r
\end{algorithmic}\r
\r
\begin{algorithmic}[1]\r
\Function{UpdateDT}{$DT_s,DE_s,LV_s,s_s$}\r
+\State $DE_{s_{kv}} \gets \{de_s | de_s \in DE_s, de_s = kv\}$\r
\ForAll{$de_s \in DE_s$}\r
- \State $LV_s \gets \Call{UpdateKVLivEnt}{LV_s,de_s,s_s}$\r
- \If{$de_s$ \textit{such that} $de_s \in D \land de_s = kv$}\r
- \State $\tuple{k_s,v_s} \gets GetKV(de_s)$\r
- \State $\tuple{k_s,v_t} \gets GetKeyVal(DT_s,k_s)$\r
- \If{$\tuple{k_s,v_t} = \emptyset$}\r
- \State $DT_s \gets DT_s \cup \{\tuple{k_s,v_s}\}$\r
- \Else\r
- \State $DT_s \gets (DT_s - \{\tuple{k_s,v_t}\}) \cup \r
+ \State $kv_s \gets GetKV(de_s)$\r
+ \State $LV_s \gets \Call{UpdateKVLivEnt}{LV_s,kv_s,s_s}$\r
+ \State $k_s \gets GetKey(kv_s)$\r
+ \State $\tuple{k_s,v_t} \gets GetKeyVal(DT_s,k_s)$\r
+ \If{$\tuple{k_s,v_t} = \emptyset$}\r
+ \State $DT_s \gets DT_s \cup \{\tuple{k_s,v_s}\}$\r
+ \Else\r
+ \State $DT_s \gets (DT_s - \{\tuple{k_s,v_t}\}) \cup \r
\{\tuple{k_s,v_s}\}$\r
- \EndIf\r
- \EndIf\r
+ \EndIf\r
\EndFor\r
\State \Return{$DT_s$}\r
\EndFunction\r
\Procedure{ProcessSL}{$SL_g$}\r
\State $MS_g \gets \emptyset$\r
\State $SM_{curr} \gets \emptyset$\r
-\State $\tuple{s_{g_{max}},sv_{g_{max}}} \gets MaxSlot(SL_g)$\r
\State $\tuple{s_{g_{min}},sv_{g_{min}}} \gets MinSlot(SL_g)$\r
+\State $\tuple{s_{g_{max}},sv_{g_{max}}} \gets MaxSlot(SL_g)$\r
\For{$s_g \gets s_{g_{min}}$ \textbf{to} $s_{g_{max}}$}\Comment{Process slots \r
in $SL_g$ in order}\r
\State $\tuple{s_g,sv_g} \gets Slot(SL_g,s_g)$\r
\State $DE_{g_{cr}} \gets \Call{GetColRes}{DE_g}$\Comment{Handle cr}\r
\If{$DE_{g_{cr}} \neq \emptyset$}\r
\ForAll{$de_{g_{cr}} \in DE_{g_{cr}}$}\r
- \State $\tuple{s_e,id_e} \gets GetCR(de_{g_{cr}})$\r
- \State $\Call{CheckCollision}{MS,SM,\tuple{s_e,id_e}}$\r
- \State $CR_{live} \gets \Call{AddCRLivEnt}{SS_{live},de_{g_{cr}}}$\r
+ \State $cr_g \gets GetCR(de_{g_{cr}})$\r
+ \State $\Call{CheckCollision}{MS,SM,cr_g}$\r
+ \State $CR_{live} \gets \Call{AddCRLivEnt}{CR_{live},de_{g_{cr}}}$\r
\EndFor\r
\EndIf\r
\State $sl_{last} \gets \Call{StoreLastSlot}{MS,sl_{last},s_g,sv_g,id_g}$\r
\If{$m + |SL_g| \leq max_g$}\Comment{Check actual size against $max_g$}\r
\State $m \gets m + |SL_g|$\r
\Else\r
- \State \Call{Error}{'Actual queue size exceeds $max_g$'}\r
+ \State \Call{Error}{'Actual $SL$ size on server exceeds $max_g$'}\r
\EndIf\r
\State $\Call{CheckLastSeqN}{MS_g,MS}$\r
\State $\Call{UpdateSSLivEnt}{SS_{live},MS}$\r
\end{algorithmic}\r
\r
\subsubsection{Writing Slots}\r
-\textbf{Data Entry} \\\r
-$k$ is key of entry \\\r
-$v$ is value of entry \\\r
-$kv$ is a key-value entry $\tuple{k,v}$\\\r
-$D = \{kv,ss,qs,cr\}$ \\\r
-$DE = \{de \mid de \in D\}$ \\\r
-$Dat_s = \tuple{s,id,hmac_p,DE,hmac_c}$ \\\r
-$sv_s = \tuple{s, E(Dat_s)} = \r
-\tuple{s, E(\tuple{s,id,hmac_p,DE,hmac_c})}$ \\ \\\r
\textbf{States} \\\r
\textit{$cp$ = data entry $DE$ maximum size/capacity} \\\r
-\textit{$cr_p$ = saved cr entry $\tuple{s,id}$ on client if there is a collision\r
-(sent in the following slot)} \\\r
-\textit{$cr_{p_{last}}$ = saved cr entry $\tuple{s,id}$ on client if there is a \r
-collision in reinserting the last slot (sent in the following slot)} \\\r
+%\textit{$cr_p$ = saved cr entry $\tuple{s,id}$ on client if there is a collision\r
+%(sent in the following slot)} \\\r
+%\textit{$cr_{p_{last}}$ = saved cr entry $\tuple{s,id}$ on client if there is a \r
+%collision in reinserting the last slot (sent in the following slot)} \\\r
\textit{$ck_p$ = counter of $kv \in KV$ for putting pairs (initially 0)} \\\r
\textit{$ck_g$ = counter of $kv \in KV$ for getting pairs (initially 0)} \\\r
\textit{$cs_p$ = counter of $ss \in SS$ for putting pairs (initially 0)} \\\r
\EndFunction\r
\end{algorithmic}\r
\r
+\begin{algorithmic}[1]\r
+\Function{PutSSPair}{$SS_s,\tuple{id_s,s_{s_{last}}}$}\Comment{Insert a set of $ss$ entries}\r
+\State $SS_s \gets SS_s \cup \{\tuple{cs_p, \tuple{id_s,s_{s_{last}}}}\}$\r
+\State $cs_p \gets cs_p + 1$\r
+\State \Return{$SS_s$}\r
+\EndFunction\r
+\end{algorithmic}\r
+\r
+\begin{algorithmic}[1]\r
+\Function{PutCRPair}{$CR_s,\tuple{s_s,id_s}$}\Comment{Insert a set of $cr$ entries}\r
+\State $CR_s \gets CR_s \cup \{\tuple{cc_p, \tuple{s_s,id_s}}\}$\r
+\State $cc_p \gets cc_p + 1$\r
+\State \Return{$CR_s$}\r
+\EndFunction\r
+\end{algorithmic}\r
+\r
\begin{algorithmic}[1]\r
\Function{CheckResize}{$MS_s,th_s,max_t,m'_s$}\r
\State $s_{last_{min}} \gets MinLastSeqN(MS_s)$\r
\end{algorithmic}\r
\r
\begin{algorithmic}[1]\r
-\Function{CheckNeedSS}{$MS_s,max_t$}\Comment{Check if $ss$ is needed}\r
+\Function{CheckSLFull}{$MS_s,max_t$}\Comment{Check if $ss$ is needed}\r
\State $s_{last_{min}} \gets MinLastSeqN(MS_s)$\r
\State $s_{last_{max}} \gets MaxLastSeqN(MS_s)$\r
\State $n_{live} \gets s_{last_{max}} - s_{last_{min}}$\Comment{Number of live slots}\r
\EndFunction\r
\end{algorithmic}\r
\r
-%\begin{algorithmic}[1]\r
-%\Function{AddSlotSeq}{$DE_s,SS_s,cp_s$}\Comment{Insert a $ss$}\r
-%\State $DE_{ret} \gets DE_s \cup SS_s$\r
-%\State $cp_s \gets cp_s - |SS_s|$\r
-%\State \Return{$\tuple{DE_{ret},cp_s}$}\r
-%\EndFunction\r
-%\end{algorithmic}\r
-\r
-\begin{algorithmic}[1]\r
-\Function{PutSSPair}{$SS_s,\tuple{id_s,s_{s_{last}}}$}\Comment{Insert a set of $ss$ entries}\r
-\State $SS_s \gets SS_s \cup \{\tuple{cs_p, \tuple{id_s,s_{s_{last}}}}\}$\r
-\State $cs_p \gets cs_p + 1$\r
-\State \Return{$SS_s$}\r
-\EndFunction\r
-\end{algorithmic}\r
-\r
-\begin{algorithmic}[1]\r
-\Function{PutCRPair}{$CR_s,\tuple{s_s,id_s}$}\Comment{Insert a set of $cr$ entries}\r
-\State $CR_s \gets CR_s \cup \{\tuple{cc_p, \tuple{s_s,id_s}}\}$\r
-\State $cc_p \gets cc_p + 1$\r
-\State \Return{$CR_s$}\r
-\EndFunction\r
-\end{algorithmic}\r
-\r
\begin{algorithmic}[1]\r
\Function{AddQueSta}{$DE_s,max'_s,cp_s$}\Comment{Insert a $qs$}\r
\State $DE_{ret} \gets \emptyset$\r
\State $qs_s \gets max'_s$\r
-\State $DE_{ret} \gets DE_s \cup qs_s$\r
+\State $DE_{ret} \gets DE_s \cup \{qs_s\}$\r
\State $cp_s \gets cp_s - 1$\r
\State \Return{$\tuple{DE_{ret},cp_s}$}\r
\EndFunction\r
\end{algorithmic}\r
\r
-%\begin{algorithmic}[1]\r
-%\Function{AddColRes}{$DE_s,CR_s,cp_s$}\Comment{Insert a $cr$}\r
-%\State $DE_{ret} \gets \emptyset$\r
-%\State $DE_{ret} \gets DE_s \cup CR_s$\r
-%\State $cp_s \gets cp_s - |CR_s|$\r
-%\State \Return{$\tuple{DE_{ret},cp_s}$}\r
-%\EndFunction\r
-%\end{algorithmic}\r
-\r
\begin{algorithmic}[1]\r
\Function{GetKVPairs}{$DE_s,KV_s,cp_s$}\r
\State $DE_{ret} \gets \emptyset$\r
\If{$|SS_s| \leq cp_s$}\Comment{$SS$ set can span multiple slots}\r
\State $DE_{ret} \gets DE_s \cup\r
\{\tuple{id_s,s_{s_{last}}} \mid \tuple{cs_s,\tuple{id_s,s_{s_{last}}}} \in SS_s\}$\r
+ \State $cp_s \gets cp_s - |SS_s|$\r
\Else\r
\State $DE_{ret} \gets DE_s \cup\r
\{\tuple{id_s,s_{s_{last}}} \mid \tuple{cs_s,\tuple{id_s,s_{s_{last}}}} \in SS_s,\r
cs_g \leq cs_s < cs_g + cp_s\}$\r
+ \State $cp_s \gets 0$\r
\EndIf\r
-\State $cp_s \gets cp_s - |SS_s|$\r
\State \Return{$\tuple{DE_{ret},cp_s}$}\r
\EndFunction\r
\end{algorithmic}\r
\If{$|CR_s| \leq cp_s$}\Comment{$CR$ set can span multiple slots}\r
\State $DE_{ret} \gets DE_s \cup\r
\{\tuple{s_s,id_s} \mid \tuple{cc_s,\tuple{s_s,id_s}} \in CR_s\}$\r
+ \State $cp_s \gets cp_s - |CR_s|$\r
\Else\r
\State $DE_{ret} \gets DE_s \cup\r
\{\tuple{s_s,id_s} \mid \tuple{cc_s,\tuple{s_s,id_s}} \in CR_s,\r
cc_g \leq cc_s < cc_g + cp_s\}$\r
+ \State $cp_s \gets 0$\r
\EndIf\r
-\State $cp_s \gets cp_s - |CR_s|$\r
\State \Return{$\tuple{DE_{ret},cp_s}$}\r
\EndFunction\r
\end{algorithmic}\r
\State $s_p \gets MaxLastSeqN(MS)$\r
\State $cp_p \gets cp$\r
\State $max'_p \gets \Call{CheckResize}{MS,th_p,max_g,m'_p}$\r
- \If{$max'_p \neq \emptyset$}\r
- \State $\tuple{DE_p,cp_p} \gets \Call{AddQueSta}{DE_p,max'_p,cp_p}$\Comment{Add qs}\r
+ \If{$max'_p \neq \emptyset$}\Comment{Add a qs entry}\r
+ \State $\tuple{DE_p,cp_p} \gets \Call{AddQueSta}{DE_p,max'_p,cp_p}$\r
+ \State $reinsert_{qs} \gets false$\r
\Else\Comment{Check if there is $qs$ reinsertion}\r
\If{$reinsert_{qs}$}\r
\State $\tuple{DE_p,cp_p} \gets \Call{AddQueSta}{DE_p,max_g,cp_p}$\r
\State $CR \gets \Call{PutCRPair}{CR,\tuple{s_{p_{col}},id_{p_{col}}}}$\r
\EndIf\r
\EndWhile\r
-\If{$|DE_p| = cp$}\Comment{Middle of set}\r
- \State $ck_g \gets ck_g + cp_s$\r
+\State $MS \gets \Call{UpdateLastSeqN}{id_{self},s_p,MS}$\r
+\If{$|DE_p| = cp$}\Comment{Update set counters}\r
+ \State $ck_g \gets ck_g + cp_p$\Comment{Middle of set}\r
\State $cs_g \gets cs_g + |SS|$\r
\State $cc_g \gets cc_g + |CR|$\r
\Else\Comment{End of set}\r
\State $cs_g \gets 0$\r
\State $cc_g \gets 0$\r
\EndIf\r
-\State $MS \gets \Call{UpdateLastSeqN}{id_{self},s_p,MS}$\r
-\State $need_p \gets \Call{CheckNeedSS}{MS,max_g}$\r
-\If{$need_p$}\r
- \State $\Call{CheckLastSlot}{sl_{last}}$\Comment{Get ready to expunge first slot}\r
+\State $need_p \gets \Call{CheckSLFull}{MS,max_g}$\r
+\If{$need_p$}\Comment{SL on server is full}\r
+ \State $\Call{CheckLastSlot}{sl_{last}}$\Comment{Salvage entries from expunged slot}\r
\State $ss_p \gets \Call{CreateSlotSeq}{sl_{last}}$\r
\State $\tuple{id_p,s_{p_{last}}} \gets GetSS(ss_p)$\r
\State $SS \gets \Call{PutSSPair}{SS,\tuple{id_p,s_{p_{last}}}}$\Comment{Add ss}\r